From 9388ff3dbd46eedf055dc162a93589f8c7f6b653 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Wed, 19 Oct 2016 22:19:34 -0400 Subject: [PATCH 001/122] Add Vagrantfile and fix case sensitivity in src/Makefile --- .gitignore | 1 + tools/Vagrantfile | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tools/Vagrantfile diff --git a/.gitignore b/.gitignore index 23e834b3db..c5fa0989ac 100755 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ GPATH GRTAGS GSYMS GTAGS +tools/.vagrant diff --git a/tools/Vagrantfile b/tools/Vagrantfile new file mode 100644 index 0000000000..c0ea97a9bb --- /dev/null +++ b/tools/Vagrantfile @@ -0,0 +1,27 @@ +Vagrant.configure(2) do |config| + config.vm.box = "ubuntu/trusty32" + + config.vm.provider "virtualbox" do |v| + v.name = "composite_dev" + v.memory = 1024 + v.cpus = 2 + v.customize ["modifyvm", :id, "--paravirtprovider", "kvm"] + end + + # Disable the default syncing + config.vm.synced_folder ".", "/vagrant", disabled: true + # Instead sync the actual composite folder + config.vm.synced_folder "../", "/home/vagrant/composite" + + config.vm.provision "shell", inline: <<-SHELL + sudo apt-get update + sudo apt-get -y install make + sudo apt-get -y install git + sudo apt-get -y install ntp + sudo apt-get -y install bc + sudo apt-get -y install gcc-multilib + sudo apt-get -y install binutils-dev + sudo apt-get -y install binutils-dev + sudo apt-get -y install qemu-kvm + SHELL +end From a5a4420935f401ca1e58c5cb4c78aed20da81173 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sun, 23 Oct 2016 14:45:44 -0400 Subject: [PATCH 002/122] Create a new cFE_boot component and script --- .../no_interface/cFE_booter/Makefile | 10 +++++++ .../no_interface/cFE_booter/cFE_booter.c | 26 +++++++++++++++++++ src/platform/i386/runscripts/cFE_boot.sh | 4 +++ 3 files changed, 40 insertions(+) create mode 100644 src/components/implementation/no_interface/cFE_booter/Makefile create mode 100644 src/components/implementation/no_interface/cFE_booter/cFE_booter.c create mode 100644 src/platform/i386/runscripts/cFE_boot.sh diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile new file mode 100644 index 0000000000..7a3be2b843 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -0,0 +1,10 @@ +C_OBJS=cFE_booter.o +ASM_OBJS= +COMPONENT=cFE_boot.o +INTERFACES= +DEPENDENCIES= +IF_LIB= +ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api + +include ../../Makefile.subsubdir +MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_booter.c b/src/components/implementation/no_interface/cFE_booter/cFE_booter.c new file mode 100644 index 0000000000..2e5cdbdc5e --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/cFE_booter.c @@ -0,0 +1,26 @@ +#include +#include + +#include +#include +#include + +static void +cos_llprint(char *s, int len) +{ call_cap(PRINT_CAP_TEMP, (int)s, len, 0, 0); } + + +int +prints(char *s) +{ + int len = strlen(s); + + cos_llprint(s, len); + + return len; +} + +void cos_init(void) +{ + prints("We live!"); +} diff --git a/src/platform/i386/runscripts/cFE_boot.sh b/src/platform/i386/runscripts/cFE_boot.sh new file mode 100644 index 0000000000..da55381326 --- /dev/null +++ b/src/platform/i386/runscripts/cFE_boot.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cp cFE_boot.o llboot.o +./cos_linker "llboot.o, ;llpong.o, :" ./gen_client_stub From 8214daac3727165eebec783dd6bbac0903885bc2 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Thu, 27 Oct 2016 16:10:45 -0400 Subject: [PATCH 003/122] Implement printc for the cFE booter, and clean up its Makefile --- .../no_interface/cFE_booter/Makefile | 1 - .../no_interface/cFE_booter/cFE_booter.c | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index 7a3be2b843..3dfb5dd44d 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -7,4 +7,3 @@ IF_LIB= ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api include ../../Makefile.subsubdir -MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_booter.c b/src/components/implementation/no_interface/cFE_booter/cFE_booter.c index 2e5cdbdc5e..b42f84ebd0 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_booter.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_booter.c @@ -2,8 +2,8 @@ #include #include -#include #include +#include static void cos_llprint(char *s, int len) @@ -20,6 +20,22 @@ prints(char *s) return len; } +int __attribute__((format(printf,1,2))) +printc(char *fmt, ...) +{ + char s[128]; + va_list arg_ptr; + int ret, len = 128; + + va_start(arg_ptr, fmt); + ret = vsnprintf(s, len, fmt, arg_ptr); + va_end(arg_ptr); + cos_llprint(s, ret); + + return ret; +} + + void cos_init(void) { prints("We live!"); From 01b1f199f5bebf51b36afc334fa9f7598530d190 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Wed, 2 Nov 2016 22:52:44 -0400 Subject: [PATCH 004/122] Change the cFE_booter Makefile to include the core-composite cFE object --- .gitmodules | 2 +- src/components/implementation/no_interface/cFE_booter/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index f2f7f19cf6..1db936cae1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "src/components/lib/ps"] path = src/components/lib/ps - url = https://github.com/gparmer/ps.git + url = git@github.com:gparmer/ps.git diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index 3dfb5dd44d..3c610e1bf1 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -1,4 +1,4 @@ -C_OBJS=cFE_booter.o +C_OBJS=cFE_booter.o core-composite.o ASM_OBJS= COMPONENT=cFE_boot.o INTERFACES= From 5132ac3775b65d6aac70b51575e189299ea604f1 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Thu, 3 Nov 2016 18:33:16 -0400 Subject: [PATCH 005/122] Fix build issues in the cFE_booter component --- .../implementation/no_interface/cFE_booter/Makefile | 7 ++++--- .../no_interface/cFE_booter/{cFE_booter.c => cFE_stub.c} | 6 ------ .../i386/runscripts/{cFE_boot.sh => cFE_booter.sh} | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) rename src/components/implementation/no_interface/cFE_booter/{cFE_booter.c => cFE_stub.c} (91%) rename src/platform/i386/runscripts/{cFE_boot.sh => cFE_booter.sh} (72%) diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index 3c610e1bf1..1f85e092c4 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -1,9 +1,10 @@ -C_OBJS=cFE_booter.o core-composite.o +C_OBJS=cFE_stub.o ASM_OBJS= -COMPONENT=cFE_boot.o +COMPONENT=cFE_booter.o INTERFACES= DEPENDENCIES= -IF_LIB= +IF_LIB=./composite_cFE.o ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api include ../../Makefile.subsubdir +MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_booter.c b/src/components/implementation/no_interface/cFE_booter/cFE_stub.c similarity index 91% rename from src/components/implementation/no_interface/cFE_booter/cFE_booter.c rename to src/components/implementation/no_interface/cFE_booter/cFE_stub.c index b42f84ebd0..e09c59553e 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_booter.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_stub.c @@ -34,9 +34,3 @@ printc(char *fmt, ...) return ret; } - - -void cos_init(void) -{ - prints("We live!"); -} diff --git a/src/platform/i386/runscripts/cFE_boot.sh b/src/platform/i386/runscripts/cFE_booter.sh similarity index 72% rename from src/platform/i386/runscripts/cFE_boot.sh rename to src/platform/i386/runscripts/cFE_booter.sh index da55381326..1369b07050 100644 --- a/src/platform/i386/runscripts/cFE_boot.sh +++ b/src/platform/i386/runscripts/cFE_booter.sh @@ -1,4 +1,4 @@ #!/bin/sh -cp cFE_boot.o llboot.o +cp cFE_booter.o llboot.o ./cos_linker "llboot.o, ;llpong.o, :" ./gen_client_stub From 4362aa294e9ee32c70e5a466995989dad527e1b6 Mon Sep 17 00:00:00 2001 From: Joseph Espy Date: Sat, 5 Nov 2016 18:22:31 -0400 Subject: [PATCH 006/122] Added a directory and empty methods for OSAL's queues --- .../cFE_booter/Queue/OS_QueueCreate.c | 17 +++++++++++++++++ .../no_interface/cFE_booter/Queue/QueueDelete.c | 15 +++++++++++++++ .../no_interface/cFE_booter/Queue/QueueGet.c | 15 +++++++++++++++ .../cFE_booter/Queue/QueueGetIdByName.c | 15 +++++++++++++++ .../cFE_booter/Queue/QueueGetInfo.c | 15 +++++++++++++++ .../no_interface/cFE_booter/Queue/QueuePut.c | 15 +++++++++++++++ .../no_interface/cFE_booter/Queue/queue_test.c | 15 +++++++++++++++ 7 files changed, 107 insertions(+) create mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/OS_QueueCreate.c create mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueueDelete.c create mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueueGet.c create mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueueGetIdByName.c create mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueueGetInfo.c create mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueuePut.c create mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/queue_test.c diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/OS_QueueCreate.c b/src/components/implementation/no_interface/cFE_booter/Queue/OS_QueueCreate.c new file mode 100644 index 0000000000..f5e42bef06 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/Queue/OS_QueueCreate.c @@ -0,0 +1,17 @@ +#include +#include +#include +#include + +/** +* Description: (From NASA's OSAL Library API documentation) +* +* This is the function used to create a queue in the operating system. Depending on the +* underlying operating system, the memory for the queue will be allocated automatically or +* allocated by the code that sets up the queue. Queue names must be unique; if the name +* already exists this function fails. Names cannot be NULL. +**/ + +int32 OS_QueueCreate( uint32 *queue_id, const char *queue_name, uint32 queue_depth, uint32 data_size, uint32 flags ){ + +} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueueDelete.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueueDelete.c new file mode 100644 index 0000000000..643ed462d4 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/Queue/QueueDelete.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +/** +* Description: (From NASA's OSAL Library API documentation) +* +* This is the function used to delete a queue in the operating system. This also frees the +* respective queue_id to be used again when another queue is created. +**/ + +int32 OS_QueueDelete ( uint32 queue_id ){ + +} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGet.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGet.c new file mode 100644 index 0000000000..dc9ee91f1a --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGet.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +/** +* Description: (From NASA's OSAL Library API documentation) + +* This function is used to retrieve a data item from an existing queue. The queue can be +* checked, pended on, or pended on with a timeout. +**/ + +int32 OS_QueueGet ( uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout){ + +} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetIdByName.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetIdByName.c new file mode 100644 index 0000000000..0463510507 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetIdByName.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +/** +* Description: (From NASA's OSAL Library API documentation) + +* This function takes a queue name and looks for a valid queue with this name and returns +* the id of that queue. +**/ + +int32 OS_QueueGetIdByName (uint32 *queue_id, const char *queue_name){ + +} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetInfo.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetInfo.c new file mode 100644 index 0000000000..f2c0d4b1de --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetInfo.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +/** +* Description: (From NASA's OSAL Library API documentation) + +* This function takes queue_id, and looks it up in the OS table. It puts all of the +* information known about that queue into a structure pointer to by queue_prop. +**/ + +int32 OS_QueueGetInfo (uint32 queue_id, OS_queue_prop_t *queue_prop){ + +} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueuePut.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueuePut.c new file mode 100644 index 0000000000..3993c77e28 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/Queue/QueuePut.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +/** +* Description: (From NASA's OSAL Library API documentation) + +* This function is used to send data on an existing queue. The flags can be used to specify +* the behavior of the queue if it is full. +**/ + +int32 OS_QueuePut ( uint32 queue_id, void *data, uint32 size, uint32 flags){ + +} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/queue_test.c b/src/components/implementation/no_interface/cFE_booter/Queue/queue_test.c new file mode 100644 index 0000000000..0ed1687f16 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/Queue/queue_test.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +/** +* Description: +* +* A temporary method used to test the function of queue related methods +**/ + +void queue_test(){ + + prints("queue test works"); +} From 545f25d6b2cb2ecddd103457f72e016538b40eb1 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sun, 6 Nov 2016 23:46:19 -0500 Subject: [PATCH 007/122] Add cFE mocks to the cFE_booter component --- .../no_interface/cFE_booter/.gitignore | 1 + .../no_interface/cFE_booter/Makefile | 4 +- .../no_interface/cFE_booter/osapi.c | 516 ++++++++++++++++++ .../no_interface/cFE_booter/osfiles.c | 334 ++++++++++++ .../no_interface/cFE_booter/osloader.c | 41 ++ .../no_interface/cFE_booter/osnetwork.c | 105 ++++ .../no_interface/cFE_booter/ostimer.c | 74 +++ .../no_interface/cFE_booter/psp.c | 482 ++++++++++++++++ 8 files changed, 1556 insertions(+), 1 deletion(-) create mode 100644 src/components/implementation/no_interface/cFE_booter/.gitignore create mode 100644 src/components/implementation/no_interface/cFE_booter/osapi.c create mode 100644 src/components/implementation/no_interface/cFE_booter/osfiles.c create mode 100644 src/components/implementation/no_interface/cFE_booter/osloader.c create mode 100644 src/components/implementation/no_interface/cFE_booter/osnetwork.c create mode 100644 src/components/implementation/no_interface/cFE_booter/ostimer.c create mode 100644 src/components/implementation/no_interface/cFE_booter/psp.c diff --git a/src/components/implementation/no_interface/cFE_booter/.gitignore b/src/components/implementation/no_interface/cFE_booter/.gitignore new file mode 100644 index 0000000000..4f62b849d5 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/.gitignore @@ -0,0 +1 @@ +gen diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index 1f85e092c4..0bdea3351b 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -1,4 +1,4 @@ -C_OBJS=cFE_stub.o +C_OBJS=cFE_stub.o osapi.o osfiles.o osloader.o ostimer.o osnetwork.o psp.o ASM_OBJS= COMPONENT=cFE_booter.o INTERFACES= @@ -7,4 +7,6 @@ IF_LIB=./composite_cFE.o ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api include ../../Makefile.subsubdir +CFLAGS += -I./gen + MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c new file mode 100644 index 0000000000..798e42ec72 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -0,0 +1,516 @@ +#include "gen/osapi.h" +#include "gen/common_types.h" + +/* +** Initialization of API +*/ +int32 OS_API_Init(void) +{ + // TODO: Implement me! + return 0; +} + +/* +** OS-specific background thread implementation - waits forever for events to occur. +** +** This should be called from the BSP main routine / initial thread after all other +** board / application initialization has taken place and all other tasks are running. +*/ +void OS_IdleLoop(void) +{ + // TODO: Implement me! +} + +/* +** OS_DeleteAllObjects() provides a means to clean up all resources allocated by this +** instance of OSAL. It would typically be used during an orderly shutdown but may also +** be helpful for testing purposes. +*/ +void OS_DeleteAllObjects(void) +{ + // TODO: Implement me! +} + +/* +** OS_ApplicationShutdown() provides a means for a user-created thread to request the orderly +** shutdown of the whole system, such as part of a user-commanded reset command. +** This is preferred over e.g. ApplicationExit() which exits immediately and does not +** provide for any means to clean up first. +*/ +void OS_ApplicationShutdown(uint8 flag) +{ + // TODO: Implement me! +} + + +/* +** Task API +*/ + +int32 OS_TaskCreate(uint32 *task_id, const char *task_name, + osal_task_entry function_pointer, + uint32 *stack_pointer, + uint32 stack_size, + uint32 priority, uint32 flags) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_TaskDelete(uint32 task_id) +{ + // TODO: Implement me! + return 0; +} + +void OS_TaskExit(void) +{ + // TODO: Implement me! +} + +int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer){ + // TODO: Implement me! + return 0; +} + +int32 OS_TaskDelay(uint32 millisecond) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_TaskRegister(void) +{ + // TODO: Implement me! + return 0; +} + +uint32 OS_TaskGetId(void) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_TaskGetIdByName(uint32 *task_id, const char *task_name) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) +{ + // TODO: Implement me! + return 0; +} + +/* +** Message Queue API +*/ + +/* +** Queue Create now has the Queue ID returned to the caller. +*/ +int32 OS_QueueCreate(uint32 *queue_id, const char *queue_name, + uint32 queue_depth, uint32 data_size, uint32 flags) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_QueueDelete(uint32 queue_id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_QueueGet(uint32 queue_id, void *data, uint32 size, + uint32 *size_copied, int32 timeout) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_QueuePut(uint32 queue_id, const void *data, uint32 size, + uint32 flags) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_QueueGetIdByName(uint32 *queue_id, const char *queue_name) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_QueueGetInfo(uint32 queue_id, OS_queue_prop_t *queue_prop) +{ + // TODO: Implement me! + return 0; +} + +/* +** Semaphore API +*/ + +int32 OS_BinSemCreate(uint32 *sem_id, const char *sem_name, + uint32 sem_initial_value, uint32 options) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_BinSemFlush(uint32 sem_id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_BinSemGive(uint32 sem_id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_BinSemTake(uint32 sem_id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_BinSemTimedWait(uint32 sem_id, uint32 msecs) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_BinSemDelete(uint32 sem_id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_BinSemGetIdByName(uint32 *sem_id, const char *sem_name) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_BinSemGetInfo(uint32 sem_id, OS_bin_sem_prop_t *bin_prop) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_CountSemCreate(uint32 *sem_id, const char *sem_name, + uint32 sem_initial_value, uint32 options) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_CountSemGive(uint32 sem_id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_CountSemTake(uint32 sem_id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_CountSemTimedWait(uint32 sem_id, uint32 msecs) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_CountSemDelete(uint32 sem_id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_CountSemGetIdByName(uint32 *sem_id, const char *sem_name) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_CountSemGetInfo(uint32 sem_id, OS_count_sem_prop_t *count_prop) +{ + // TODO: Implement me! + return 0; +} + +/* +** Mutex API +*/ + +int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_MutSemGive(uint32 sem_id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_MutSemTake(uint32 sem_id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_MutSemDelete(uint32 sem_id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_MutSemGetIdByName(uint32 *sem_id, const char *sem_name) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) +{ + // TODO: Implement me! + return 0; +} + +/* +** OS Time/Tick related API +*/ + +int32 OS_Milli2Ticks(uint32 milli_seconds) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_Tick2Micros(void) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_GetLocalTime(OS_time_t *time_struct) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_SetLocalTime(OS_time_t *time_struct) +{ + // TODO: Implement me! + return 0; +} + +/* +** Exception API +*/ + +int32 OS_ExcAttachHandler(uint32 ExceptionNumber, + void (*ExceptionHandler)(uint32, const void *,uint32), + int32 parameter) +{ + // TODO: Implement me! + return 0; +} + + +int32 OS_ExcEnable (int32 ExceptionNumber) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_ExcDisable (int32 ExceptionNumber) +{ + // TODO: Implement me! + return 0; +} + +/* +** Floating Point Unit API +*/ + +int32 OS_FPUExcAttachHandler(uint32 ExceptionNumber, void * ExceptionHandler, + int32 parameter) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_FPUExcEnable(int32 ExceptionNumber) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_FPUExcDisable(int32 ExceptionNumber) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_FPUExcSetMask(uint32 mask) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_FPUExcGetMask(uint32 *mask) +{ + // TODO: Implement me! + return 0; +} + +/* +** Interrupt API +*/ +int32 OS_IntAttachHandler(uint32 InterruptNumber, osal_task_entry InterruptHandler, int32 parameter) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_IntUnlock(int32 IntLevel) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_IntLock(void) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_IntEnable(int32 Level) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_IntDisable(int32 Level) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_IntSetMask(uint32 mask) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_IntGetMask(uint32 *mask) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_IntAck(int32 InterruptNumber) +{ + // TODO: Implement me! + return 0; +} + +/* +** Shared memory API +*/ +int32 OS_ShMemInit(void) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_ShMemCreate(uint32 *Id, uint32 NBytes, const char* SegName) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_ShMemSemTake(uint32 Id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_ShMemSemGive(uint32 Id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_ShMemAttach(cpuaddr * Address, uint32 Id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_ShMemGetIdByName(uint32 *ShMemId, const char *SegName ) +{ + // TODO: Implement me! + return 0; +} + +/* +** Heap API +*/ +int32 OS_HeapGetInfo(OS_heap_prop_t *heap_prop) +{ + // TODO: Implement me! + return 0; +} + +/* +** API for useful debugging function +*/ +int32 OS_GetErrorName(int32 error_num, os_err_name_t* err_name) +{ + // TODO: Implement me! + return 0; +} + + +/* +** Abstraction for printf statements +*/ +void OS_printf( const char *string, ...) { + // TODO: Implement me! +} + +void OS_printf_disable(void) +{ + // TODO: Implement me! +} + +void OS_printf_enable(void) +{ + // TODO: Implement me! +} + +/* +** Call to exit the running application +** Normally embedded applications run forever, but for debugging purposes +** (unit testing for example) this is needed in order to end the test +*/ +void OS_ApplicationExit(int32 Status) +{ + // TODO: Implement me! +} diff --git a/src/components/implementation/no_interface/cFE_booter/osfiles.c b/src/components/implementation/no_interface/cFE_booter/osfiles.c new file mode 100644 index 0000000000..b28c466643 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/osfiles.c @@ -0,0 +1,334 @@ +#include "gen/osapi.h" +#include "gen/common_types.h" + + +/****************************************************************************** +** Standard File system API +******************************************************************************/ +/* + * Initializes the File System functions +*/ + +int32 OS_FS_Init(void) +{ + // TODO: Implement me! + return 0; +} + +/* + * Creates a file specified by path +*/ +int32 OS_creat(const char *path, int32 access) +{ + // TODO: Implement me! + return 0; +} + +/* + * Opend a file for reading/writing. Returns file descriptor +*/ +int32 OS_open(const char *path, int32 access, uint32 mode) +{ + // TODO: Implement me! + return 0; +} + +/* + * Closes an open file. +*/ +int32 OS_close(int32 filedes) +{ + // TODO: Implement me! + return 0; +} + +/* + * Reads nbytes bytes from file into buffer +*/ +int32 OS_read(int32 filedes, void *buffer, uint32 nbytes) +{ + // TODO: Implement me! + return 0; +} + +/* + * Write nybytes bytes of buffer into the file +*/ +int32 OS_write(int32 filedes, void *buffer, uint32 nbytes) +{ + // TODO: Implement me! + return 0; +} + +/* + * Changes the permissions of a file +*/ +int32 OS_chmod(const char *path, uint32 access) +{ + // TODO: Implement me! + return 0; +} + +/* + * Returns file status information in filestats +*/ +int32 OS_stat(const char *path, os_fstat_t *filestats) +{ + // TODO: Implement me! + return 0; +} + +/* + * Seeks to the specified position of an open file +*/ +int32 OS_lseek(int32 filedes, int32 offset, uint32 whence) +{ + // TODO: Implement me! + return 0; +} + +/* + * Removes a file from the file system +*/ +int32 OS_remove(const char *path) +{ + // TODO: Implement me! + return 0; +} + +/* + * Renames a file in the file system +*/ +int32 OS_rename(const char *old_filename, const char *new_filename) +{ + // TODO: Implement me! + return 0; +} + +/* + * copies a single file from src to dest +*/ +int32 OS_cp(const char *src, const char *dest) +{ + // TODO: Implement me! + return 0; +} + +/* + * moves a single file from src to dest +*/ +int32 OS_mv(const char *src, const char *dest) +{ + // TODO: Implement me! + return 0; +} + +/* + * Copies the info of an open file to the structure +*/ +int32 OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) +{ + // TODO: Implement me! + return 0; +} + +/* +** Check to see if a file is open +*/ +int32 OS_FileOpenCheck(char *Filename) +{ + // TODO: Implement me! + return 0; +} + +/* +** Close all open files +*/ +int32 OS_CloseAllFiles(void) +{ + // TODO: Implement me! + return 0; +} + +/* +** Close a file by filename +*/ +int32 OS_CloseFileByName(char *Filename) +{ + // TODO: Implement me! + return 0; +} + + +/****************************************************************************** +** Directory API +******************************************************************************/ + +/* + * Makes a new directory +*/ +int32 OS_mkdir(const char *path, uint32 access) +{ + // TODO: Implement me! + return 0; +} + +/* + * Opens a directory for searching +*/ +os_dirp_t OS_opendir(const char *path) +{ + // TODO: Implement me! + return 0; +} + +/* + * Closes an open directory +*/ +int32 OS_closedir(os_dirp_t directory) +{ + // TODO: Implement me! + return 0; +} + +/* + * Rewinds an open directory +*/ +void OS_rewinddir(os_dirp_t directory) +{ + // TODO: Implement me! +} + +/* + * Reads the next object in the directory +*/ +os_dirent_t * OS_readdir(os_dirp_t directory) +{ + // TODO: Implement me! + return 0; +} + +/* + * Removes an empty directory from the file system. +*/ +int32 OS_rmdir(const char *path) +{ + // TODO: Implement me! + return 0; +} + +/****************************************************************************** +** System Level API +******************************************************************************/ +/* + * Makes a file system +*/ +int32 OS_mkfs(char *address,char *devname, char *volname, + uint32 blocksize, uint32 numblocks) +{ + // TODO: Implement me! + return 0; +} +/* + * Mounts a file system +*/ +int32 OS_mount(const char *devname, char *mountpoint) +{ + // TODO: Implement me! + return 0; +} + +/* + * Initializes an existing file system +*/ +int32 OS_initfs(char *address,char *devname, char *volname, uint32 blocksize, uint32 numblocks) +{ + // TODO: Implement me! + return 0; +} + +/* + * removes a file system +*/ +int32 OS_rmfs(char *devname) +{ + // TODO: Implement me! + return 0; +} + +/* + * Unmounts a mounted file system +*/ +int32 OS_unmount(const char *mountpoint) +{ + // TODO: Implement me! + return 0; +} + +/* + * Returns the number of free blocks in a file system +*/ +int32 OS_fsBlocksFree(const char *name) +{ + // TODO: Implement me! + return 0; +} + +/* +** Returns the number of free bytes in a file system +** Note the 64 bit data type to support filesystems that +** are greater than 4 Gigabytes +*/ +int32 OS_fsBytesFree(const char *name, uint64 *bytes_free) +{ + // TODO: Implement me! + return 0; +} + +/* + * Checks the health of a file system and repairs it if neccesary +*/ +os_fshealth_t OS_chkfs(const char *name, boolean repair) +{ + // TODO: Implement me! + return 0; +} + +/* + * Returns in the parameter the physical drive underneith the mount point +*/ +int32 OS_FS_GetPhysDriveName(char * PhysDriveName, char * MountPoint) +{ + // TODO: Implement me! + return 0; +} + +/* +** Translates a OSAL Virtual file system path to a host Local path +*/ +int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) +{ + // TODO: Implement me! + return 0; +} + +/* +** Returns information about the file system in an os_fsinfo_t +*/ +int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) +{ + // TODO: Implement me! + return 0; +} + +/****************************************************************************** +** Shell API +******************************************************************************/ + +/* executes the shell command passed into is and writes the output of that + * command to the file specified by the given OSAPI file descriptor */ +int32 OS_ShellOutputToFile(char* Cmd, int32 OS_fd) +{ + // TODO: Implement me! + return 0; +} diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c new file mode 100644 index 0000000000..3ff9f4b7ff --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -0,0 +1,41 @@ +#include "gen/osapi.h" +#include "gen/common_types.h" + +/* +** Loader API +*/ +int32 OS_ModuleTableInit(void) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_SymbolTableDump(const char *filename, uint32 size_limit) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_ModuleLoad(uint32 *module_id, const char *module_name, const char *filename) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_ModuleUnload(uint32 module_id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_ModuleInfo(uint32 module_id, OS_module_prop_t *module_info) +{ + // TODO: Implement me! + return 0; +} diff --git a/src/components/implementation/no_interface/cFE_booter/osnetwork.c b/src/components/implementation/no_interface/cFE_booter/osnetwork.c new file mode 100644 index 0000000000..e7a2767146 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/osnetwork.c @@ -0,0 +1,105 @@ +#include "gen/osapi.h" +#include "gen/common_types.h" + +/* +** Networking API +*/ +int32 OS_SocketOpen(uint32 *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t Type) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_SocketClose(uint32 sock_id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_SocketBind(uint32 sock_id, const OS_SockAddr_t *Addr) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_SocketConnect(uint32 sock_id, const OS_SockAddr_t *Addr, int32 timeout) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_SocketAccept(uint32 sock_id, uint32 *connsock_id, OS_SockAddr_t *Addr, int32 timeout) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_SocketRecvFrom(uint32 sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_SocketSendTo(uint32 sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_SocketGetIdByName (uint32 *sock_id, const char *sock_name) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_SocketGetInfo (uint32 sock_id, OS_socket_prop_t *sock_prop) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_SocketAddrToString(char *buffer, uint32 buflen, const OS_SockAddr_t *Addr) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_SocketAddrFromString(OS_SockAddr_t *Addr, const char *string) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_SocketAddrGetPort(uint16 *PortNum, const OS_SockAddr_t *Addr) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum) +{ + // TODO: Implement me! + return 0; +} + +/* +** OS_NetworkGetID is currently [[deprecated]] as its behavior is +** unknown and not consistent across operating systems. +*/ +int32 OS_NetworkGetID(void) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_NetworkGetHostName(char *host_name, uint32 name_len) +{ + // TODO: Implement me! + return 0; +} diff --git a/src/components/implementation/no_interface/cFE_booter/ostimer.c b/src/components/implementation/no_interface/cFE_booter/ostimer.c new file mode 100644 index 0000000000..2818ec4426 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/ostimer.c @@ -0,0 +1,74 @@ +#include "gen/osapi.h" +#include "gen/common_types.h" + +/* +** Timer API +*/ + +int32 OS_TimerAPIInit(void) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_TimeBaseCreate(uint32 *timer_id, const char *timebase_name, OS_TimerSync_t external_sync) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_TimeBaseSet(uint32 timer_id, uint32 start_time, uint32 interval_time) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_TimeBaseDelete(uint32 timer_id) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_TimeBaseGetIdByName(uint32 *timer_id, const char *timebase_name) +{ + // TODO: Implement me! + return 0; +} + + +int32 OS_TimerCreate(uint32 *timer_id, const char *timer_name, uint32 *clock_accuracy, OS_TimerCallback_t callback_ptr) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_TimerAdd(uint32 *timer_id, const char *timer_name, uint32 timebase_id, OS_ArgCallback_t callback_ptr, void *callback_arg) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_TimerSet(uint32 timer_id, uint32 start_time, uint32 interval_time) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_TimerDelete(uint32 timer_id) +{ + // TODO: Implement me! + return 0; +} + + +int32 OS_TimerGetIdByName(uint32 *timer_id, const char *timer_name) +{ + // TODO: Implement me! + return 0; +} + +int32 OS_TimerGetInfo(uint32 timer_id, OS_timer_prop_t *timer_prop) +{ + // TODO: Implement me! + return 0; +} diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c new file mode 100644 index 0000000000..1b827eb03a --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -0,0 +1,482 @@ +#include "gen/cfe_psp.h" + +/* +** Function prototypes +*/ + +/* +** PSP entry point and reset routines +*/ +void CFE_PSP_Main(uint32 ModeId, char *StartupFilePath) +{ + // TODO: Implement me! +} + +/* +** CFE_PSP_Main is the entry point that the real time OS calls to start our +** software. This routine will do any BSP/OS specific setup, then call the +** entrypoint of the flight software ( i.e. the cFE main entry point ). +** The flight software (i.e. cFE ) should not call this routine. +*/ + +void CFE_PSP_GetTime(OS_time_t *LocalTime) +{ + // TODO: Implement me! +} +/* This call gets the local time from the hardware on the Vxworks system + * on the mcp750s + * on the other os/hardware setup, it will get the time the normal way */ + + +void CFE_PSP_Restart(uint32 resetType) +{ + // TODO: Implement me! +} +/* +** CFE_PSP_Restart is the entry point back to the BSP to restart the processor. +** The flight software calls this routine to restart the processor. +*/ + + +uint32 CFE_PSP_GetRestartType(uint32 *restartSubType ) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_GetRestartType returns the last reset type and if a pointer to a valid +** memory space is passed in, it returns the reset sub-type in that memory. +** Right now the reset types are application specific. For the cFE they +** are defined in the cfe_es.h file. +*/ + + +void CFE_PSP_FlushCaches(uint32 type, cpuaddr address, uint32 size); +/* +** This is a BSP specific cache flush routine +*/ + +uint32 CFE_PSP_GetProcessorId(void) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_GetProcessorId returns the CPU ID as defined by the specific board +** and BSP. +*/ + + +uint32 CFE_PSP_GetSpacecraftId(void) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_GetSpacecraftId retuns the Spacecraft ID (if any ) +*/ + + +uint32 CFE_PSP_Get_Timer_Tick(void) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_Get_Timer_Tick returns the underlying OS timer tick value +** It is used for the performance monitoring software +*/ + +uint32 CFE_PSP_GetTimerTicksPerSecond(void) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_GetTimerTicksPerSecond provides the resolution of the least significant +** 32 bits of the 64 bit time stamp returned by CFE_PSP_Get_Timebase in timer +** ticks per second. The timer resolution for accuracy should not be any slower +** than 1000000 ticks per second or 1 us per tick +*/ + +uint32 CFE_PSP_GetTimerLow32Rollover(void) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_GetTimerLow32Rollover provides the number that the least significant +** 32 bits of the 64 bit time stamp returned by CFE_PSP_Get_Timebase rolls over. +** If the lower 32 bits rolls at 1 second, then the CFE_PSP_TIMER_LOW32_ROLLOVER +** will be 1000000. if the lower 32 bits rolls at its maximum value (2^32) then +** CFE_PSP_TIMER_LOW32_ROLLOVER will be 0. +*/ + +void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32 *Tbl) +{ + // TODO: Implement me! +} +/* +** CFE_PSP_Get_Timebase +*/ + +uint32 CFE_PSP_Get_Dec(void) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_Get_Dec +*/ + + +int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType ) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_InitProcessorReservedMemory initializes all of the memory in the +** BSP that is preserved on a processor reset. The memory includes the +** Critical Data Store, the ES Reset Area, the Volatile Disk Memory, and +** the User Reserved Memory. In general, the memory areas will be initialized +** ( cleared ) on a Power On reset, and preserved during a processor reset. +*/ + +int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_GetCDSSize fetches the size of the OS Critical Data Store area. +*/ + +int32 CFE_PSP_WriteToCDS(void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumBytes) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_WriteToCDS writes to the CDS Block. +*/ + +int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumBytes) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_ReadFromCDS reads from the CDS Block +*/ + +int32 CFE_PSP_GetResetArea (cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_GetResetArea returns the location and size of the ES Reset information area. +** This area is preserved during a processor reset and is used to store the +** ER Log, System Log and reset related variables +*/ + +int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea ) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_GetUserReservedArea returns the location and size of the memory used for the cFE +** User reserved area. +*/ + +int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk ) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_GetVolatileDiskMem returns the location and size of the memory used for the cFE +** volatile disk. +*/ + +int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *SizeOfKernelSegment) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_GetKernelTextSegmentInfo returns the location and size of the kernel memory. +*/ + +int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFESegment) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_GetCFETextSegmentInfo returns the location and size of the kernel memory. +*/ + +void CFE_PSP_WatchdogInit(void) +{ + // TODO: Implement me! +} +/* +** CFE_PSP_WatchdogInit configures the watchdog timer. +*/ + +void CFE_PSP_WatchdogEnable(void) +{ + // TODO: Implement me! +} +/* +** CFE_PSP_WatchdogEnable enables the watchdog timer. +*/ + +void CFE_PSP_WatchdogDisable(void) +{ + // TODO: Implement me! +} +/* +** CFE_PSP_WatchdogDisable disables the watchdog timer. +*/ + +void CFE_PSP_WatchdogService(void) +{ + // TODO: Implement me! +} +/* +** CFE_PSP_WatchdogService services the watchdog timer according to the +** value set in WatchDogSet. +*/ + +uint32 CFE_PSP_WatchdogGet(void) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_WatchdogGet gets the watchdog time in milliseconds +*/ + +void CFE_PSP_WatchdogSet(uint32 WatchdogValue) +{ + // TODO: Implement me! +} +/* +** CFE_PSP_WatchdogSet sets the watchdog time in milliseconds +*/ + +void CFE_PSP_Panic(int32 ErrorCode) +{ + // TODO: Implement me! +} +/* +** CFE_PSP_Panic is called by the cFE Core startup code when it needs to abort the +** cFE startup. This should not be called by applications. +*/ + +int32 CFE_PSP_InitSSR(uint32 bus, uint32 device, char *DeviceName) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_InitSSR will initialize the Solid state recorder memory for a particular platform +*/ + +int32 CFE_PSP_Decompress( char * srcFileName, char * dstFileName) +{ + // TODO: Implement me! + return 0; +} +/* +** CFE_PSP_Decompress will uncompress the source file to the file specified in the +** destination file name. The Decompress uses the "gzip" algorithm. Files can +** be compressed using the "gzip" program available on almost all host platforms. +*/ + +void CFE_PSP_AttachExceptions(void) +{ + // TODO: Implement me! +} +/* +** CFE_PSP_AttachExceptions will setup the exception environment for the chosen platform +** On a board, this can be configured to look at a debug flag or switch in order to +** keep the standard OS exeption handlers, rather than restarting the system +*/ + + +void CFE_PSP_SetDefaultExceptionEnvironment(void) +{ + // TODO: Implement me! + return 0; +} +/* +** +** CFE_PSP_SetDefaultExceptionEnvironment defines the CPU and FPU exceptions that are enabled for each cFE Task/App +** +** Notes: The exception environment is local to each task Therefore this must be +** called for each task that that wants to do floating point and catch exceptions +*/ + + +/* +** I/O Port API +*/ +int32 CFE_PSP_PortRead8(cpuaddr PortAddress, uint8 *ByteValue) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_PortWrite8(cpuaddr PortAddress, uint8 ByteValue) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_PortRead16(cpuaddr PortAddress, uint16 *uint16Value) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_PortWrite16(cpuaddr PortAddress, uint16 uint16Value) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_PortRead32(cpuaddr PortAddress, uint32 *uint32Value) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_PortWrite32(cpuaddr PortAddress, uint32 uint32Value) +{ + // TODO: Implement me! + return 0; +} + +/* +** Memory API +*/ +int32 CFE_PSP_MemRead8(cpuaddr MemoryAddress, uint8 *ByteValue) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_MemWrite8(cpuaddr MemoryAddress, uint8 ByteValue) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_MemRead16(cpuaddr MemoryAddress, uint16 *uint16Value) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_MemWrite16(cpuaddr MemoryAddress, uint16 uint16Value) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_MemRead32(cpuaddr MemoryAddress, uint32 *uint32Value) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_MemWrite32(cpuaddr MemoryAddress, uint32 uint32Value) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_MemCpy(void *dest, void *src, uint32 n) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType) +{ + // TODO: Implement me! + return 0; +} + +uint32 CFE_PSP_MemRanges(void) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_MemRangeSet(uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, + uint32 Size, uint32 WordSize, uint32 Attributes) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_MemRangeGet (uint32 RangeNum, uint32 *MemoryType, cpuaddr *StartAddr, + uint32 *Size, uint32 *WordSize, uint32 *Attributes) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_EepromWrite8(cpuaddr MemoryAddress, uint8 ByteValue) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_EepromWrite16(cpuaddr MemoryAddress, uint16 uint16Value) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_EepromWrite32(cpuaddr MemoryAddress, uint32 uint32Value) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_EepromWriteEnable(uint32 Bank) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_EepromWriteDisable(uint32 Bank) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_EepromPowerUp(uint32 Bank) +{ + // TODO: Implement me! + return 0; +} + +int32 CFE_PSP_EepromPowerDown(uint32 Bank) +{ + // TODO: Implement me! + return 0; +} From 454243b989f1dbd110294881593fad970b54f3d4 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 7 Nov 2016 21:16:56 -0500 Subject: [PATCH 008/122] Add hack in the cFE for the missing sscanf function, and improve the cFE mocks --- .../cFE_booter/{cFE_stub.c => cFE_util.c} | 10 ++ .../no_interface/cFE_booter/cFE_util.h | 20 +++ .../no_interface/cFE_booter/osapi.c | 148 +++++++++--------- .../no_interface/cFE_booter/osfiles.c | 72 ++++----- .../no_interface/cFE_booter/osloader.c | 14 +- .../no_interface/cFE_booter/osnetwork.c | 34 ++-- .../no_interface/cFE_booter/ostimer.c | 24 +-- .../no_interface/cFE_booter/psp.c | 115 +++++++------- 8 files changed, 239 insertions(+), 198 deletions(-) rename src/components/implementation/no_interface/cFE_booter/{cFE_stub.c => cFE_util.c} (76%) create mode 100644 src/components/implementation/no_interface/cFE_booter/cFE_util.h diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_stub.c b/src/components/implementation/no_interface/cFE_booter/cFE_util.c similarity index 76% rename from src/components/implementation/no_interface/cFE_booter/cFE_stub.c rename to src/components/implementation/no_interface/cFE_booter/cFE_util.c index e09c59553e..b1bfc3eb3e 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_stub.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.c @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -34,3 +35,12 @@ printc(char *fmt, ...) return ret; } + +void panic(char* message){ + printc("cFE panic: %s", message); + assert(0); +} + +void __isoc99_sscanf(void){ + panic("__isoc99_sscanf not implemented!"); +} diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.h b/src/components/implementation/no_interface/cFE_booter/cFE_util.h new file mode 100644 index 0000000000..867cf7dc81 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.h @@ -0,0 +1,20 @@ +#include +#include + +#include +#include +#include + +#ifndef _cFE_util_ +#define _cFE_util_ + +int +prints(char *s); + +int __attribute__((format(printf,1,2))) printc(char *fmt, ...); + +void panic(char* message); + +void __isoc99_sscanf(void); + +#endif diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 798e42ec72..7ad50c62d6 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -1,3 +1,5 @@ +#include "cFE_util.h" + #include "gen/osapi.h" #include "gen/common_types.h" @@ -6,7 +8,7 @@ */ int32 OS_API_Init(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -18,7 +20,7 @@ int32 OS_API_Init(void) */ void OS_IdleLoop(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } /* @@ -28,7 +30,7 @@ void OS_IdleLoop(void) */ void OS_DeleteAllObjects(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } /* @@ -39,7 +41,7 @@ void OS_DeleteAllObjects(void) */ void OS_ApplicationShutdown(uint8 flag) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } @@ -53,59 +55,59 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, uint32 stack_size, uint32 priority, uint32 flags) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TaskDelete(uint32 task_id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } void OS_TaskExit(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer){ - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TaskDelay(uint32 millisecond) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TaskRegister(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } uint32 OS_TaskGetId(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TaskGetIdByName(uint32 *task_id, const char *task_name) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -119,39 +121,39 @@ int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) int32 OS_QueueCreate(uint32 *queue_id, const char *queue_name, uint32 queue_depth, uint32 data_size, uint32 flags) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_QueueDelete(uint32 queue_id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_QueueGet(uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_QueuePut(uint32 queue_id, const void *data, uint32 size, uint32 flags) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_QueueGetIdByName(uint32 *queue_id, const char *queue_name) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_QueueGetInfo(uint32 queue_id, OS_queue_prop_t *queue_prop) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -162,92 +164,92 @@ int32 OS_QueueGetInfo(uint32 queue_id, OS_queue_prop_t *queue_prop) int32 OS_BinSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_BinSemFlush(uint32 sem_id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_BinSemGive(uint32 sem_id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_BinSemTake(uint32 sem_id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_BinSemTimedWait(uint32 sem_id, uint32 msecs) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_BinSemDelete(uint32 sem_id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_BinSemGetIdByName(uint32 *sem_id, const char *sem_name) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_BinSemGetInfo(uint32 sem_id, OS_bin_sem_prop_t *bin_prop) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_CountSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_CountSemGive(uint32 sem_id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_CountSemTake(uint32 sem_id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_CountSemTimedWait(uint32 sem_id, uint32 msecs) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_CountSemDelete(uint32 sem_id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_CountSemGetIdByName(uint32 *sem_id, const char *sem_name) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_CountSemGetInfo(uint32 sem_id, OS_count_sem_prop_t *count_prop) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -257,37 +259,37 @@ int32 OS_CountSemGetInfo(uint32 sem_id, OS_count_sem_prop_t *count_prop) int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_MutSemGive(uint32 sem_id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_MutSemTake(uint32 sem_id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_MutSemDelete(uint32 sem_id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_MutSemGetIdByName(uint32 *sem_id, const char *sem_name) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -297,25 +299,25 @@ int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) int32 OS_Milli2Ticks(uint32 milli_seconds) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_Tick2Micros(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_GetLocalTime(OS_time_t *time_struct) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SetLocalTime(OS_time_t *time_struct) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -327,20 +329,20 @@ int32 OS_ExcAttachHandler(uint32 ExceptionNumber, void (*ExceptionHandler)(uint32, const void *,uint32), int32 parameter) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ExcEnable (int32 ExceptionNumber) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ExcDisable (int32 ExceptionNumber) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -351,31 +353,31 @@ int32 OS_ExcDisable (int32 ExceptionNumber) int32 OS_FPUExcAttachHandler(uint32 ExceptionNumber, void * ExceptionHandler, int32 parameter) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_FPUExcEnable(int32 ExceptionNumber) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_FPUExcDisable(int32 ExceptionNumber) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_FPUExcSetMask(uint32 mask) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_FPUExcGetMask(uint32 *mask) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -384,49 +386,49 @@ int32 OS_FPUExcGetMask(uint32 *mask) */ int32 OS_IntAttachHandler(uint32 InterruptNumber, osal_task_entry InterruptHandler, int32 parameter) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_IntUnlock(int32 IntLevel) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_IntLock(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_IntEnable(int32 Level) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_IntDisable(int32 Level) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_IntSetMask(uint32 mask) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_IntGetMask(uint32 *mask) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_IntAck(int32 InterruptNumber) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -435,37 +437,37 @@ int32 OS_IntAck(int32 InterruptNumber) */ int32 OS_ShMemInit(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ShMemCreate(uint32 *Id, uint32 NBytes, const char* SegName) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ShMemSemTake(uint32 Id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ShMemSemGive(uint32 Id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ShMemAttach(cpuaddr * Address, uint32 Id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ShMemGetIdByName(uint32 *ShMemId, const char *SegName ) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -474,7 +476,7 @@ int32 OS_ShMemGetIdByName(uint32 *ShMemId, const char *SegName ) */ int32 OS_HeapGetInfo(OS_heap_prop_t *heap_prop) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -483,7 +485,7 @@ int32 OS_HeapGetInfo(OS_heap_prop_t *heap_prop) */ int32 OS_GetErrorName(int32 error_num, os_err_name_t* err_name) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -492,17 +494,17 @@ int32 OS_GetErrorName(int32 error_num, os_err_name_t* err_name) ** Abstraction for printf statements */ void OS_printf( const char *string, ...) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } void OS_printf_disable(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } void OS_printf_enable(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } /* @@ -512,5 +514,5 @@ void OS_printf_enable(void) */ void OS_ApplicationExit(int32 Status) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } diff --git a/src/components/implementation/no_interface/cFE_booter/osfiles.c b/src/components/implementation/no_interface/cFE_booter/osfiles.c index b28c466643..055ecfc5bf 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfiles.c +++ b/src/components/implementation/no_interface/cFE_booter/osfiles.c @@ -1,3 +1,5 @@ +#include "cFE_util.h" + #include "gen/osapi.h" #include "gen/common_types.h" @@ -11,7 +13,7 @@ int32 OS_FS_Init(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -20,7 +22,7 @@ int32 OS_FS_Init(void) */ int32 OS_creat(const char *path, int32 access) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -29,7 +31,7 @@ int32 OS_creat(const char *path, int32 access) */ int32 OS_open(const char *path, int32 access, uint32 mode) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -38,7 +40,7 @@ int32 OS_open(const char *path, int32 access, uint32 mode) */ int32 OS_close(int32 filedes) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -47,7 +49,7 @@ int32 OS_close(int32 filedes) */ int32 OS_read(int32 filedes, void *buffer, uint32 nbytes) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -56,7 +58,7 @@ int32 OS_read(int32 filedes, void *buffer, uint32 nbytes) */ int32 OS_write(int32 filedes, void *buffer, uint32 nbytes) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -65,7 +67,7 @@ int32 OS_write(int32 filedes, void *buffer, uint32 nbytes) */ int32 OS_chmod(const char *path, uint32 access) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -74,7 +76,7 @@ int32 OS_chmod(const char *path, uint32 access) */ int32 OS_stat(const char *path, os_fstat_t *filestats) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -83,7 +85,7 @@ int32 OS_stat(const char *path, os_fstat_t *filestats) */ int32 OS_lseek(int32 filedes, int32 offset, uint32 whence) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -92,7 +94,7 @@ int32 OS_lseek(int32 filedes, int32 offset, uint32 whence) */ int32 OS_remove(const char *path) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -101,7 +103,7 @@ int32 OS_remove(const char *path) */ int32 OS_rename(const char *old_filename, const char *new_filename) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -110,7 +112,7 @@ int32 OS_rename(const char *old_filename, const char *new_filename) */ int32 OS_cp(const char *src, const char *dest) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -119,7 +121,7 @@ int32 OS_cp(const char *src, const char *dest) */ int32 OS_mv(const char *src, const char *dest) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -128,7 +130,7 @@ int32 OS_mv(const char *src, const char *dest) */ int32 OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -137,7 +139,7 @@ int32 OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) */ int32 OS_FileOpenCheck(char *Filename) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -146,7 +148,7 @@ int32 OS_FileOpenCheck(char *Filename) */ int32 OS_CloseAllFiles(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -155,7 +157,7 @@ int32 OS_CloseAllFiles(void) */ int32 OS_CloseFileByName(char *Filename) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -169,7 +171,7 @@ int32 OS_CloseFileByName(char *Filename) */ int32 OS_mkdir(const char *path, uint32 access) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -178,7 +180,7 @@ int32 OS_mkdir(const char *path, uint32 access) */ os_dirp_t OS_opendir(const char *path) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -187,7 +189,7 @@ os_dirp_t OS_opendir(const char *path) */ int32 OS_closedir(os_dirp_t directory) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -196,7 +198,7 @@ int32 OS_closedir(os_dirp_t directory) */ void OS_rewinddir(os_dirp_t directory) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } /* @@ -204,7 +206,7 @@ void OS_rewinddir(os_dirp_t directory) */ os_dirent_t * OS_readdir(os_dirp_t directory) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -213,7 +215,7 @@ os_dirent_t * OS_readdir(os_dirp_t directory) */ int32 OS_rmdir(const char *path) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -226,7 +228,7 @@ int32 OS_rmdir(const char *path) int32 OS_mkfs(char *address,char *devname, char *volname, uint32 blocksize, uint32 numblocks) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -234,7 +236,7 @@ int32 OS_mkfs(char *address,char *devname, char *volname, */ int32 OS_mount(const char *devname, char *mountpoint) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -243,7 +245,7 @@ int32 OS_mount(const char *devname, char *mountpoint) */ int32 OS_initfs(char *address,char *devname, char *volname, uint32 blocksize, uint32 numblocks) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -252,7 +254,7 @@ int32 OS_initfs(char *address,char *devname, char *volname, uint32 blocksize, ui */ int32 OS_rmfs(char *devname) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -261,7 +263,7 @@ int32 OS_rmfs(char *devname) */ int32 OS_unmount(const char *mountpoint) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -270,7 +272,7 @@ int32 OS_unmount(const char *mountpoint) */ int32 OS_fsBlocksFree(const char *name) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -281,7 +283,7 @@ int32 OS_fsBlocksFree(const char *name) */ int32 OS_fsBytesFree(const char *name, uint64 *bytes_free) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -290,7 +292,7 @@ int32 OS_fsBytesFree(const char *name, uint64 *bytes_free) */ os_fshealth_t OS_chkfs(const char *name, boolean repair) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -299,7 +301,7 @@ os_fshealth_t OS_chkfs(const char *name, boolean repair) */ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, char * MountPoint) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -308,7 +310,7 @@ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, char * MountPoint) */ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -317,7 +319,7 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) */ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -329,6 +331,6 @@ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) * command to the file specified by the given OSAPI file descriptor */ int32 OS_ShellOutputToFile(char* Cmd, int32 OS_fd) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index 3ff9f4b7ff..ae51c41cfb 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -1,3 +1,5 @@ +#include "cFE_util.h" + #include "gen/osapi.h" #include "gen/common_types.h" @@ -6,36 +8,36 @@ */ int32 OS_ModuleTableInit(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SymbolTableDump(const char *filename, uint32 size_limit) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ModuleLoad(uint32 *module_id, const char *module_name, const char *filename) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ModuleUnload(uint32 module_id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ModuleInfo(uint32 module_id, OS_module_prop_t *module_info) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } diff --git a/src/components/implementation/no_interface/cFE_booter/osnetwork.c b/src/components/implementation/no_interface/cFE_booter/osnetwork.c index e7a2767146..0bdedec2d4 100644 --- a/src/components/implementation/no_interface/cFE_booter/osnetwork.c +++ b/src/components/implementation/no_interface/cFE_booter/osnetwork.c @@ -1,3 +1,5 @@ +#include "cFE_util.h" + #include "gen/osapi.h" #include "gen/common_types.h" @@ -6,85 +8,85 @@ */ int32 OS_SocketOpen(uint32 *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t Type) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketClose(uint32 sock_id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketBind(uint32 sock_id, const OS_SockAddr_t *Addr) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketConnect(uint32 sock_id, const OS_SockAddr_t *Addr, int32 timeout) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketAccept(uint32 sock_id, uint32 *connsock_id, OS_SockAddr_t *Addr, int32 timeout) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketRecvFrom(uint32 sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketSendTo(uint32 sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketGetIdByName (uint32 *sock_id, const char *sock_name) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketGetInfo (uint32 sock_id, OS_socket_prop_t *sock_prop) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketAddrToString(char *buffer, uint32 buflen, const OS_SockAddr_t *Addr) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketAddrFromString(OS_SockAddr_t *Addr, const char *string) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketAddrGetPort(uint16 *PortNum, const OS_SockAddr_t *Addr) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -94,12 +96,12 @@ int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum) */ int32 OS_NetworkGetID(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_NetworkGetHostName(char *host_name, uint32 name_len) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } diff --git a/src/components/implementation/no_interface/cFE_booter/ostimer.c b/src/components/implementation/no_interface/cFE_booter/ostimer.c index 2818ec4426..3afed45c2c 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostimer.c +++ b/src/components/implementation/no_interface/cFE_booter/ostimer.c @@ -1,3 +1,5 @@ +#include "cFE_util.h" + #include "gen/osapi.h" #include "gen/common_types.h" @@ -7,68 +9,68 @@ int32 OS_TimerAPIInit(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimeBaseCreate(uint32 *timer_id, const char *timebase_name, OS_TimerSync_t external_sync) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimeBaseSet(uint32 timer_id, uint32 start_time, uint32 interval_time) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimeBaseDelete(uint32 timer_id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimeBaseGetIdByName(uint32 *timer_id, const char *timebase_name) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimerCreate(uint32 *timer_id, const char *timer_name, uint32 *clock_accuracy, OS_TimerCallback_t callback_ptr) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimerAdd(uint32 *timer_id, const char *timer_name, uint32 timebase_id, OS_ArgCallback_t callback_ptr, void *callback_arg) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimerSet(uint32 timer_id, uint32 start_time, uint32 interval_time) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimerDelete(uint32 timer_id) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimerGetIdByName(uint32 *timer_id, const char *timer_name) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimerGetInfo(uint32 timer_id, OS_timer_prop_t *timer_prop) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c index 1b827eb03a..9d006acbcf 100644 --- a/src/components/implementation/no_interface/cFE_booter/psp.c +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -1,3 +1,5 @@ +#include "cFE_util.h" + #include "gen/cfe_psp.h" /* @@ -9,7 +11,7 @@ */ void CFE_PSP_Main(uint32 ModeId, char *StartupFilePath) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } /* @@ -21,7 +23,7 @@ void CFE_PSP_Main(uint32 ModeId, char *StartupFilePath) void CFE_PSP_GetTime(OS_time_t *LocalTime) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } /* This call gets the local time from the hardware on the Vxworks system * on the mcp750s @@ -30,7 +32,7 @@ void CFE_PSP_GetTime(OS_time_t *LocalTime) void CFE_PSP_Restart(uint32 resetType) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_Restart is the entry point back to the BSP to restart the processor. @@ -40,7 +42,7 @@ void CFE_PSP_Restart(uint32 resetType) uint32 CFE_PSP_GetRestartType(uint32 *restartSubType ) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -58,7 +60,7 @@ void CFE_PSP_FlushCaches(uint32 type, cpuaddr address, uint32 size); uint32 CFE_PSP_GetProcessorId(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -69,7 +71,7 @@ uint32 CFE_PSP_GetProcessorId(void) uint32 CFE_PSP_GetSpacecraftId(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -79,7 +81,7 @@ uint32 CFE_PSP_GetSpacecraftId(void) uint32 CFE_PSP_Get_Timer_Tick(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -89,7 +91,7 @@ uint32 CFE_PSP_Get_Timer_Tick(void) uint32 CFE_PSP_GetTimerTicksPerSecond(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -101,7 +103,7 @@ uint32 CFE_PSP_GetTimerTicksPerSecond(void) uint32 CFE_PSP_GetTimerLow32Rollover(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -114,7 +116,7 @@ uint32 CFE_PSP_GetTimerLow32Rollover(void) void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32 *Tbl) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_Get_Timebase @@ -122,7 +124,7 @@ void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32 *Tbl) uint32 CFE_PSP_Get_Dec(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -132,7 +134,7 @@ uint32 CFE_PSP_Get_Dec(void) int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType ) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -145,7 +147,7 @@ int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType ) int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -154,7 +156,7 @@ int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS) int32 CFE_PSP_WriteToCDS(void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumBytes) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -163,7 +165,7 @@ int32 CFE_PSP_WriteToCDS(void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumByt int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumBytes) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -172,7 +174,7 @@ int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumByt int32 CFE_PSP_GetResetArea (cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -183,7 +185,7 @@ int32 CFE_PSP_GetResetArea (cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea ) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -193,7 +195,7 @@ int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk ) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -203,7 +205,7 @@ int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk ) int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *SizeOfKernelSegment) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -212,7 +214,7 @@ int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *Size int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFESegment) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -221,7 +223,7 @@ int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFES void CFE_PSP_WatchdogInit(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_WatchdogInit configures the watchdog timer. @@ -229,7 +231,7 @@ void CFE_PSP_WatchdogInit(void) void CFE_PSP_WatchdogEnable(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_WatchdogEnable enables the watchdog timer. @@ -237,7 +239,7 @@ void CFE_PSP_WatchdogEnable(void) void CFE_PSP_WatchdogDisable(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_WatchdogDisable disables the watchdog timer. @@ -245,7 +247,7 @@ void CFE_PSP_WatchdogDisable(void) void CFE_PSP_WatchdogService(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_WatchdogService services the watchdog timer according to the @@ -254,7 +256,7 @@ void CFE_PSP_WatchdogService(void) uint32 CFE_PSP_WatchdogGet(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -263,7 +265,7 @@ uint32 CFE_PSP_WatchdogGet(void) void CFE_PSP_WatchdogSet(uint32 WatchdogValue) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_WatchdogSet sets the watchdog time in milliseconds @@ -271,7 +273,7 @@ void CFE_PSP_WatchdogSet(uint32 WatchdogValue) void CFE_PSP_Panic(int32 ErrorCode) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_Panic is called by the cFE Core startup code when it needs to abort the @@ -280,7 +282,7 @@ void CFE_PSP_Panic(int32 ErrorCode) int32 CFE_PSP_InitSSR(uint32 bus, uint32 device, char *DeviceName) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -289,7 +291,7 @@ int32 CFE_PSP_InitSSR(uint32 bus, uint32 device, char *DeviceName) int32 CFE_PSP_Decompress( char * srcFileName, char * dstFileName) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -300,7 +302,7 @@ int32 CFE_PSP_Decompress( char * srcFileName, char * dstFileName) void CFE_PSP_AttachExceptions(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_AttachExceptions will setup the exception environment for the chosen platform @@ -311,8 +313,7 @@ void CFE_PSP_AttachExceptions(void) void CFE_PSP_SetDefaultExceptionEnvironment(void) { - // TODO: Implement me! - return 0; + panic("Unimplemented method!"); // TODO: Implement me! } /* ** @@ -328,37 +329,37 @@ void CFE_PSP_SetDefaultExceptionEnvironment(void) */ int32 CFE_PSP_PortRead8(cpuaddr PortAddress, uint8 *ByteValue) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_PortWrite8(cpuaddr PortAddress, uint8 ByteValue) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_PortRead16(cpuaddr PortAddress, uint16 *uint16Value) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_PortWrite16(cpuaddr PortAddress, uint16 uint16Value) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_PortRead32(cpuaddr PortAddress, uint32 *uint32Value) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_PortWrite32(cpuaddr PortAddress, uint32 uint32Value) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -367,116 +368,116 @@ int32 CFE_PSP_PortWrite32(cpuaddr PortAddress, uint32 uint32Value) */ int32 CFE_PSP_MemRead8(cpuaddr MemoryAddress, uint8 *ByteValue) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemWrite8(cpuaddr MemoryAddress, uint8 ByteValue) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemRead16(cpuaddr MemoryAddress, uint16 *uint16Value) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemWrite16(cpuaddr MemoryAddress, uint16 uint16Value) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemRead32(cpuaddr MemoryAddress, uint32 *uint32Value) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemWrite32(cpuaddr MemoryAddress, uint32 uint32Value) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemCpy(void *dest, void *src, uint32 n) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } uint32 CFE_PSP_MemRanges(void) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemRangeSet(uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, uint32 Size, uint32 WordSize, uint32 Attributes) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemRangeGet (uint32 RangeNum, uint32 *MemoryType, cpuaddr *StartAddr, uint32 *Size, uint32 *WordSize, uint32 *Attributes) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_EepromWrite8(cpuaddr MemoryAddress, uint8 ByteValue) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_EepromWrite16(cpuaddr MemoryAddress, uint16 uint16Value) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_EepromWrite32(cpuaddr MemoryAddress, uint32 uint32Value) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_EepromWriteEnable(uint32 Bank) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_EepromWriteDisable(uint32 Bank) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_EepromPowerUp(uint32 Bank) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_EepromPowerDown(uint32 Bank) { - // TODO: Implement me! + panic("Unimplemented method!"); // TODO: Implement me! return 0; } From 4087a1d51aabd9a830f2e89193203bac7c44c8ee Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 8 Nov 2016 14:14:27 -0500 Subject: [PATCH 009/122] Split up osal methods better in the cFE_booter --- .../no_interface/cFE_booter/Makefile | 2 +- .../no_interface/cFE_booter/osapi.c | 249 ------------------ .../no_interface/cFE_booter/osqueue.c | 50 ++++ .../no_interface/cFE_booter/ostask.c | 208 +++++++++++++++ 4 files changed, 259 insertions(+), 250 deletions(-) create mode 100644 src/components/implementation/no_interface/cFE_booter/osqueue.c create mode 100644 src/components/implementation/no_interface/cFE_booter/ostask.c diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index 0bdea3351b..cbf6cf50b9 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -1,4 +1,4 @@ -C_OBJS=cFE_stub.o osapi.o osfiles.o osloader.o ostimer.o osnetwork.o psp.o +C_OBJS=cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o ASM_OBJS= COMPONENT=cFE_booter.o INTERFACES= diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 7ad50c62d6..2711fd5afe 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -44,255 +44,6 @@ void OS_ApplicationShutdown(uint8 flag) panic("Unimplemented method!"); // TODO: Implement me! } - -/* -** Task API -*/ - -int32 OS_TaskCreate(uint32 *task_id, const char *task_name, - osal_task_entry function_pointer, - uint32 *stack_pointer, - uint32 stack_size, - uint32 priority, uint32 flags) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_TaskDelete(uint32 task_id) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -void OS_TaskExit(void) -{ - panic("Unimplemented method!"); // TODO: Implement me! -} - -int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer){ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_TaskDelay(uint32 millisecond) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_TaskRegister(void) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -uint32 OS_TaskGetId(void) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_TaskGetIdByName(uint32 *task_id, const char *task_name) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -/* -** Message Queue API -*/ - -/* -** Queue Create now has the Queue ID returned to the caller. -*/ -int32 OS_QueueCreate(uint32 *queue_id, const char *queue_name, - uint32 queue_depth, uint32 data_size, uint32 flags) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_QueueDelete(uint32 queue_id) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_QueueGet(uint32 queue_id, void *data, uint32 size, - uint32 *size_copied, int32 timeout) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_QueuePut(uint32 queue_id, const void *data, uint32 size, - uint32 flags) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_QueueGetIdByName(uint32 *queue_id, const char *queue_name) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_QueueGetInfo(uint32 queue_id, OS_queue_prop_t *queue_prop) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -/* -** Semaphore API -*/ - -int32 OS_BinSemCreate(uint32 *sem_id, const char *sem_name, - uint32 sem_initial_value, uint32 options) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_BinSemFlush(uint32 sem_id) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_BinSemGive(uint32 sem_id) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_BinSemTake(uint32 sem_id) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_BinSemTimedWait(uint32 sem_id, uint32 msecs) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_BinSemDelete(uint32 sem_id) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_BinSemGetIdByName(uint32 *sem_id, const char *sem_name) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_BinSemGetInfo(uint32 sem_id, OS_bin_sem_prop_t *bin_prop) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_CountSemCreate(uint32 *sem_id, const char *sem_name, - uint32 sem_initial_value, uint32 options) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_CountSemGive(uint32 sem_id) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_CountSemTake(uint32 sem_id) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_CountSemTimedWait(uint32 sem_id, uint32 msecs) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_CountSemDelete(uint32 sem_id) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_CountSemGetIdByName(uint32 *sem_id, const char *sem_name) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_CountSemGetInfo(uint32 sem_id, OS_count_sem_prop_t *count_prop) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -/* -** Mutex API -*/ - -int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_MutSemGive(uint32 sem_id) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_MutSemTake(uint32 sem_id) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_MutSemDelete(uint32 sem_id) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_MutSemGetIdByName(uint32 *sem_id, const char *sem_name) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; -} - /* ** OS Time/Tick related API */ diff --git a/src/components/implementation/no_interface/cFE_booter/osqueue.c b/src/components/implementation/no_interface/cFE_booter/osqueue.c new file mode 100644 index 0000000000..f7c9b4396f --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/osqueue.c @@ -0,0 +1,50 @@ +#include "cFE_util.h" + +#include "gen/osapi.h" +#include "gen/common_types.h" + +/* +** Message Queue API +*/ + +/* +** Queue Create now has the Queue ID returned to the caller. +*/ +int32 OS_QueueCreate(uint32 *queue_id, const char *queue_name, + uint32 queue_depth, uint32 data_size, uint32 flags) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_QueueDelete(uint32 queue_id) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_QueueGet(uint32 queue_id, void *data, uint32 size, + uint32 *size_copied, int32 timeout) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_QueuePut(uint32 queue_id, const void *data, uint32 size, + uint32 flags) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_QueueGetIdByName(uint32 *queue_id, const char *queue_name) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_QueueGetInfo(uint32 queue_id, OS_queue_prop_t *queue_prop) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c new file mode 100644 index 0000000000..d789841040 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -0,0 +1,208 @@ +#include "cFE_util.h" + +#include "gen/osapi.h" +#include "gen/common_types.h" + + +/* +** Task API +*/ + +int32 OS_TaskCreate(uint32 *task_id, const char *task_name, + osal_task_entry function_pointer, + uint32 *stack_pointer, + uint32 stack_size, + uint32 priority, uint32 flags) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_TaskDelete(uint32 task_id) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +void OS_TaskExit(void) +{ + panic("Unimplemented method!"); // TODO: Implement me! +} + +int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer){ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_TaskDelay(uint32 millisecond) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_TaskRegister(void) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +uint32 OS_TaskGetId(void) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_TaskGetIdByName(uint32 *task_id, const char *task_name) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + + +/* +** Mutex API +*/ + +int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_MutSemGive(uint32 sem_id) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_MutSemTake(uint32 sem_id) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_MutSemDelete(uint32 sem_id) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_MutSemGetIdByName(uint32 *sem_id, const char *sem_name) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +/* +** Semaphore API +*/ + +int32 OS_BinSemCreate(uint32 *sem_id, const char *sem_name, + uint32 sem_initial_value, uint32 options) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_BinSemFlush(uint32 sem_id) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_BinSemGive(uint32 sem_id) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_BinSemTake(uint32 sem_id) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_BinSemTimedWait(uint32 sem_id, uint32 msecs) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_BinSemDelete(uint32 sem_id) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_BinSemGetIdByName(uint32 *sem_id, const char *sem_name) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_BinSemGetInfo(uint32 sem_id, OS_bin_sem_prop_t *bin_prop) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_CountSemCreate(uint32 *sem_id, const char *sem_name, + uint32 sem_initial_value, uint32 options) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_CountSemGive(uint32 sem_id) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_CountSemTake(uint32 sem_id) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_CountSemTimedWait(uint32 sem_id, uint32 msecs) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_CountSemDelete(uint32 sem_id) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_CountSemGetIdByName(uint32 *sem_id, const char *sem_name) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} + +int32 OS_CountSemGetInfo(uint32 sem_id, OS_count_sem_prop_t *count_prop) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; +} From a06dab4d71fa1b4b7217cfae7987e20193f6663b Mon Sep 17 00:00:00 2001 From: Joseph Espy Date: Thu, 10 Nov 2016 14:28:40 -0500 Subject: [PATCH 010/122] the meager sum of my efforts to implement nothing more than a simple queue --- .../cFE_booter/Queue/OS_QueueCreate.c | 17 -- .../cFE_booter/Queue/QueueDelete.c | 15 -- .../no_interface/cFE_booter/Queue/QueueGet.c | 15 -- .../cFE_booter/Queue/QueueGetIdByName.c | 15 -- .../cFE_booter/Queue/QueueGetInfo.c | 15 -- .../no_interface/cFE_booter/Queue/QueuePut.c | 15 -- .../cFE_booter/Queue/queue_test.c | 15 -- .../no_interface/cFE_booter/osqueue.c | 159 ++++++++++++++---- 8 files changed, 122 insertions(+), 144 deletions(-) delete mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/OS_QueueCreate.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueueDelete.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueueGet.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueueGetIdByName.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueueGetInfo.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueuePut.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/queue_test.c diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/OS_QueueCreate.c b/src/components/implementation/no_interface/cFE_booter/Queue/OS_QueueCreate.c deleted file mode 100644 index f5e42bef06..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/Queue/OS_QueueCreate.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include -#include -#include - -/** -* Description: (From NASA's OSAL Library API documentation) -* -* This is the function used to create a queue in the operating system. Depending on the -* underlying operating system, the memory for the queue will be allocated automatically or -* allocated by the code that sets up the queue. Queue names must be unique; if the name -* already exists this function fails. Names cannot be NULL. -**/ - -int32 OS_QueueCreate( uint32 *queue_id, const char *queue_name, uint32 queue_depth, uint32 data_size, uint32 flags ){ - -} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueueDelete.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueueDelete.c deleted file mode 100644 index 643ed462d4..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/Queue/QueueDelete.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include -#include - -/** -* Description: (From NASA's OSAL Library API documentation) -* -* This is the function used to delete a queue in the operating system. This also frees the -* respective queue_id to be used again when another queue is created. -**/ - -int32 OS_QueueDelete ( uint32 queue_id ){ - -} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGet.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGet.c deleted file mode 100644 index dc9ee91f1a..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGet.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include -#include - -/** -* Description: (From NASA's OSAL Library API documentation) - -* This function is used to retrieve a data item from an existing queue. The queue can be -* checked, pended on, or pended on with a timeout. -**/ - -int32 OS_QueueGet ( uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout){ - -} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetIdByName.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetIdByName.c deleted file mode 100644 index 0463510507..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetIdByName.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include -#include - -/** -* Description: (From NASA's OSAL Library API documentation) - -* This function takes a queue name and looks for a valid queue with this name and returns -* the id of that queue. -**/ - -int32 OS_QueueGetIdByName (uint32 *queue_id, const char *queue_name){ - -} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetInfo.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetInfo.c deleted file mode 100644 index f2c0d4b1de..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetInfo.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include -#include - -/** -* Description: (From NASA's OSAL Library API documentation) - -* This function takes queue_id, and looks it up in the OS table. It puts all of the -* information known about that queue into a structure pointer to by queue_prop. -**/ - -int32 OS_QueueGetInfo (uint32 queue_id, OS_queue_prop_t *queue_prop){ - -} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueuePut.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueuePut.c deleted file mode 100644 index 3993c77e28..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/Queue/QueuePut.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include -#include - -/** -* Description: (From NASA's OSAL Library API documentation) - -* This function is used to send data on an existing queue. The flags can be used to specify -* the behavior of the queue if it is full. -**/ - -int32 OS_QueuePut ( uint32 queue_id, void *data, uint32 size, uint32 flags){ - -} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/queue_test.c b/src/components/implementation/no_interface/cFE_booter/Queue/queue_test.c deleted file mode 100644 index 0ed1687f16..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/Queue/queue_test.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include -#include - -/** -* Description: -* -* A temporary method used to test the function of queue related methods -**/ - -void queue_test(){ - - prints("queue test works"); -} diff --git a/src/components/implementation/no_interface/cFE_booter/osqueue.c b/src/components/implementation/no_interface/cFE_booter/osqueue.c index f7c9b4396f..5081096333 100644 --- a/src/components/implementation/no_interface/cFE_booter/osqueue.c +++ b/src/components/implementation/no_interface/cFE_booter/osqueue.c @@ -1,50 +1,135 @@ +#include +#include +#include + +#include +#include +#include + #include "cFE_util.h" -#include "gen/osapi.h" -#include "gen/common_types.h" - -/* -** Message Queue API -*/ - -/* -** Queue Create now has the Queue ID returned to the caller. -*/ -int32 OS_QueueCreate(uint32 *queue_id, const char *queue_name, - uint32 queue_depth, uint32 data_size, uint32 flags) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; +typedef unsigned long uint32;//remove wnen cFE header correctly implement uint32 + +struct queue{ + + const char *queue_name; + uint32 queue_id; //should MAXNUMOFQUEUES be the max number of unique ids, or 2,494,967,295 + uint32 data_size; + queue_depth; + queue* head; //pointer to head of queue + queue* tail; //pointer to last filled elemnt of queue } -int32 OS_QueueDelete(uint32 queue_id) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; +const int MAXNUMOFQUEUES=256;//change this + +int numofqueues; + +queue queuelist[MAXNUMOFQUEUES]; + +/** +* Description: (From NASA's OSAL Library API documentation) +* +* This is the function used to create a queue in the operating system. Depending on the +* underlying operating system, the memory for the queue will be allocated automatically or +* allocated by the code that sets up the queue. Queue names must be unique; if the name +* already exists this function fails. Names cannot be NULL. +**/ + +int32 OS_QueueCreate( uint32 *queue_id, const char *queue_name, uint32 queue_depth, uint32 data_size, uint32 flags ){ + + //how do I get a page of memory from composite + //should I use an entire page for each queue + //should I allow a queue to span more than one page in a single mem ring + + if(numofqueues==MAXNUMOFQUEUES)return OS_ERR_NO_FREE_IDS; + //other error checking + + numofqueues++; + queue newqueue; + //somehow get a page(?) of memory to store the memory ring in + } -int32 OS_QueueGet(uint32 queue_id, void *data, uint32 size, - uint32 *size_copied, int32 timeout) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; + +/** +* Description: (From NASA's OSAL Library API documentation) +* +* This is the function used to delete a queue in the operating system. This also frees the +* respective queue_id to be used again when another queue is created. +**/ + +int32 OS_QueueDelete ( uint32 queue_id ){ + } -int32 OS_QueuePut(uint32 queue_id, const void *data, uint32 size, - uint32 flags) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; +/** +* Description: (From NASA's OSAL Library API documentation) + +* This function is used to retrieve a data item from an existing queue. The queue can be +* checked, pended on, or pended on with a timeout. +**/ + +int32 OS_QueueGet ( uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout){ + } -int32 OS_QueueGetIdByName(uint32 *queue_id, const char *queue_name) -{ - panic("Unimplemented method!"); // TODO: Implement me! - return 0; +/** +* Description: (From NASA's OSAL Library API documentation) + +* This function takes a queue name and looks for a valid queue with this name and returns +* the id of that queue. +**/ + +int32 OS_QueueGetIdByName (uint32 *queue_id, const char *queue_name){ + + for(int i=0;i Date: Thu, 10 Nov 2016 21:03:21 -0500 Subject: [PATCH 011/122] Write out a stub for the cFE's entrypoint --- .../no_interface/cFE_booter/Makefile | 2 +- .../no_interface/cFE_booter/cFE_entrypoint.c | 96 +++++++++++++++++++ 2 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index cbf6cf50b9..0ff2dd892e 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -1,4 +1,4 @@ -C_OBJS=cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o +C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o ASM_OBJS= COMPONENT=cFE_booter.o INTERFACES= diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c new file mode 100644 index 0000000000..fc88b09628 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c @@ -0,0 +1,96 @@ +#include + +#include "cFE_util.h" +#include "gen/cfe_psp.h" +#include "gen/common_types.h" +#include "gen/osapi.h" + +// This is based on an old build technique, so we can ignore this warning. +// But I'm leaving it in, just in case we ever switch to cmake +/* + * cfe_platform_cfg.h needed for CFE_ES_NONVOL_STARTUP_FILE, CFE_CPU_ID/CPU_NAME/SPACECRAFT_ID + * + * - this should NOT be included here - + * + * it is only for compatibility with the old makefiles. Including this makes the PSP build + * ONLY compatible with a CFE build using this exact same CFE platform config. + */ + +#include "gen/cfe_platform_cfg.h" + +extern void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId, const char *StartFilePath ); +extern void CFE_TIME_Local1HzISR(void); + +#define CFE_ES_MAIN_FUNCTION CFE_ES_Main +#define CFE_TIME_1HZ_FUNCTION CFE_TIME_Local1HzISR + +/* + * The classic build does not support static modules, + * so stub the ModuleInit() function out right here + */ +void CFE_PSP_ModuleInit(void) +{ +} + +// Mandatory defines +#define CFE_PSP_CPU_NAME_LENGTH 32 +#define CFE_PSP_RESET_NAME_LENGTH 10 + +/* +* Structure for the Command line parameters +* Stolen from the Linux psp_start function... +*/ +struct CFE_PSP_CommandData_t { + char ResetType[CFE_PSP_RESET_NAME_LENGTH]; /* Reset type can be "PO" for Power on or "PR" for Processor Reset */ + + uint32 SubType; /* Reset Sub Type ( 1 - 5 ) */ + + char CpuName[CFE_PSP_CPU_NAME_LENGTH]; /* CPU Name */ + + uint32 CpuId; /* CPU ID */ + + uint32 SpacecraftId; /* Spacecraft ID */ +}; + +void command_line_set_defaults(struct CFE_PSP_CommandData_t* args) { + strncpy(args->ResetType, "PO", 2); + args->SubType = 1; + args->CpuId = 1; + args->SpacecraftId = CFE_SPACECRAFT_ID; +} + +void cos_init(void) { + struct CFE_PSP_CommandData_t args; + + command_line_set_defaults(&args); + + /* + ** Set the reset type + */ + uint32 reset_type; + if (strncmp("PR", args.ResetType, 2 ) == 0) + { + reset_type = CFE_PSP_RST_TYPE_PROCESSOR; + OS_printf("CFE_PSP: Starting the cFE with a PROCESSOR reset.\n"); + } + else + { + reset_type = CFE_PSP_RST_TYPE_POWERON; + OS_printf("CFE_PSP: Starting the cFE with a POWER ON reset.\n"); + } + + /* + ** Call cFE entry point. + */ + CFE_ES_MAIN_FUNCTION(reset_type, args.SubType, 1, CFE_ES_NONVOL_STARTUP_FILE); + + /* + ** Let the main thread sleep. + ** + ** OS_IdleLoop() will wait forever and return if + ** someone calls OS_ApplicationShutdown(TRUE) + */ + OS_IdleLoop(); + + panic("Application was shutdown!"); +} From b365e982d99e6e97d7d815d35be9c73311c409e6 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sat, 12 Nov 2016 17:16:00 -0500 Subject: [PATCH 012/122] Revert "the meager sum of my efforts to implement nothing more than a simple queue" This reverts commit 2d0a3583e8c3ac4a8fe4cc56352f91fdce57ca77. --- .../cFE_booter/Queue/OS_QueueCreate.c | 17 ++ .../cFE_booter/Queue/QueueDelete.c | 15 ++ .../no_interface/cFE_booter/Queue/QueueGet.c | 15 ++ .../cFE_booter/Queue/QueueGetIdByName.c | 15 ++ .../cFE_booter/Queue/QueueGetInfo.c | 15 ++ .../no_interface/cFE_booter/Queue/QueuePut.c | 15 ++ .../cFE_booter/Queue/queue_test.c | 15 ++ .../no_interface/cFE_booter/osqueue.c | 159 ++++-------------- 8 files changed, 144 insertions(+), 122 deletions(-) create mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/OS_QueueCreate.c create mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueueDelete.c create mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueueGet.c create mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueueGetIdByName.c create mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueueGetInfo.c create mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueuePut.c create mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/queue_test.c diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/OS_QueueCreate.c b/src/components/implementation/no_interface/cFE_booter/Queue/OS_QueueCreate.c new file mode 100644 index 0000000000..f5e42bef06 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/Queue/OS_QueueCreate.c @@ -0,0 +1,17 @@ +#include +#include +#include +#include + +/** +* Description: (From NASA's OSAL Library API documentation) +* +* This is the function used to create a queue in the operating system. Depending on the +* underlying operating system, the memory for the queue will be allocated automatically or +* allocated by the code that sets up the queue. Queue names must be unique; if the name +* already exists this function fails. Names cannot be NULL. +**/ + +int32 OS_QueueCreate( uint32 *queue_id, const char *queue_name, uint32 queue_depth, uint32 data_size, uint32 flags ){ + +} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueueDelete.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueueDelete.c new file mode 100644 index 0000000000..643ed462d4 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/Queue/QueueDelete.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +/** +* Description: (From NASA's OSAL Library API documentation) +* +* This is the function used to delete a queue in the operating system. This also frees the +* respective queue_id to be used again when another queue is created. +**/ + +int32 OS_QueueDelete ( uint32 queue_id ){ + +} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGet.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGet.c new file mode 100644 index 0000000000..dc9ee91f1a --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGet.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +/** +* Description: (From NASA's OSAL Library API documentation) + +* This function is used to retrieve a data item from an existing queue. The queue can be +* checked, pended on, or pended on with a timeout. +**/ + +int32 OS_QueueGet ( uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout){ + +} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetIdByName.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetIdByName.c new file mode 100644 index 0000000000..0463510507 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetIdByName.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +/** +* Description: (From NASA's OSAL Library API documentation) + +* This function takes a queue name and looks for a valid queue with this name and returns +* the id of that queue. +**/ + +int32 OS_QueueGetIdByName (uint32 *queue_id, const char *queue_name){ + +} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetInfo.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetInfo.c new file mode 100644 index 0000000000..f2c0d4b1de --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetInfo.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +/** +* Description: (From NASA's OSAL Library API documentation) + +* This function takes queue_id, and looks it up in the OS table. It puts all of the +* information known about that queue into a structure pointer to by queue_prop. +**/ + +int32 OS_QueueGetInfo (uint32 queue_id, OS_queue_prop_t *queue_prop){ + +} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueuePut.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueuePut.c new file mode 100644 index 0000000000..3993c77e28 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/Queue/QueuePut.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +/** +* Description: (From NASA's OSAL Library API documentation) + +* This function is used to send data on an existing queue. The flags can be used to specify +* the behavior of the queue if it is full. +**/ + +int32 OS_QueuePut ( uint32 queue_id, void *data, uint32 size, uint32 flags){ + +} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/queue_test.c b/src/components/implementation/no_interface/cFE_booter/Queue/queue_test.c new file mode 100644 index 0000000000..0ed1687f16 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/Queue/queue_test.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +/** +* Description: +* +* A temporary method used to test the function of queue related methods +**/ + +void queue_test(){ + + prints("queue test works"); +} diff --git a/src/components/implementation/no_interface/cFE_booter/osqueue.c b/src/components/implementation/no_interface/cFE_booter/osqueue.c index 5081096333..f7c9b4396f 100644 --- a/src/components/implementation/no_interface/cFE_booter/osqueue.c +++ b/src/components/implementation/no_interface/cFE_booter/osqueue.c @@ -1,135 +1,50 @@ -#include -#include -#include - -#include -#include -#include - #include "cFE_util.h" -typedef unsigned long uint32;//remove wnen cFE header correctly implement uint32 - -struct queue{ - - const char *queue_name; - uint32 queue_id; //should MAXNUMOFQUEUES be the max number of unique ids, or 2,494,967,295 - uint32 data_size; - queue_depth; - queue* head; //pointer to head of queue - queue* tail; //pointer to last filled elemnt of queue +#include "gen/osapi.h" +#include "gen/common_types.h" + +/* +** Message Queue API +*/ + +/* +** Queue Create now has the Queue ID returned to the caller. +*/ +int32 OS_QueueCreate(uint32 *queue_id, const char *queue_name, + uint32 queue_depth, uint32 data_size, uint32 flags) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; } -const int MAXNUMOFQUEUES=256;//change this - -int numofqueues; - -queue queuelist[MAXNUMOFQUEUES]; - -/** -* Description: (From NASA's OSAL Library API documentation) -* -* This is the function used to create a queue in the operating system. Depending on the -* underlying operating system, the memory for the queue will be allocated automatically or -* allocated by the code that sets up the queue. Queue names must be unique; if the name -* already exists this function fails. Names cannot be NULL. -**/ - -int32 OS_QueueCreate( uint32 *queue_id, const char *queue_name, uint32 queue_depth, uint32 data_size, uint32 flags ){ - - //how do I get a page of memory from composite - //should I use an entire page for each queue - //should I allow a queue to span more than one page in a single mem ring - - if(numofqueues==MAXNUMOFQUEUES)return OS_ERR_NO_FREE_IDS; - //other error checking - - numofqueues++; - queue newqueue; - //somehow get a page(?) of memory to store the memory ring in - +int32 OS_QueueDelete(uint32 queue_id) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; } - -/** -* Description: (From NASA's OSAL Library API documentation) -* -* This is the function used to delete a queue in the operating system. This also frees the -* respective queue_id to be used again when another queue is created. -**/ - -int32 OS_QueueDelete ( uint32 queue_id ){ - +int32 OS_QueueGet(uint32 queue_id, void *data, uint32 size, + uint32 *size_copied, int32 timeout) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; } -/** -* Description: (From NASA's OSAL Library API documentation) - -* This function is used to retrieve a data item from an existing queue. The queue can be -* checked, pended on, or pended on with a timeout. -**/ - -int32 OS_QueueGet ( uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout){ - +int32 OS_QueuePut(uint32 queue_id, const void *data, uint32 size, + uint32 flags) +{ + panic("Unimplemented method!"); // TODO: Implement me! + return 0; } -/** -* Description: (From NASA's OSAL Library API documentation) - -* This function takes a queue name and looks for a valid queue with this name and returns -* the id of that queue. -**/ - -int32 OS_QueueGetIdByName (uint32 *queue_id, const char *queue_name){ - - for(int i=0;i Date: Sun, 13 Nov 2016 16:41:55 -0500 Subject: [PATCH 013/122] Add more information to cFE panics --- .../no_interface/cFE_booter/cFE_entrypoint.c | 2 +- .../no_interface/cFE_booter/cFE_util.c | 8 +- .../no_interface/cFE_booter/cFE_util.h | 4 +- .../no_interface/cFE_booter/osapi.c | 72 +++++------ .../no_interface/cFE_booter/osfiles.c | 70 +++++------ .../no_interface/cFE_booter/osloader.c | 12 +- .../no_interface/cFE_booter/osnetwork.c | 32 ++--- .../no_interface/cFE_booter/osqueue.c | 12 +- .../no_interface/cFE_booter/ostask.c | 62 +++++----- .../no_interface/cFE_booter/ostimer.c | 22 ++-- .../no_interface/cFE_booter/psp.c | 112 +++++++++--------- 11 files changed, 206 insertions(+), 202 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c index fc88b09628..c33ff94953 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c @@ -92,5 +92,5 @@ void cos_init(void) { */ OS_IdleLoop(); - panic("Application was shutdown!"); + PANIC("Application was shutdown!"); } diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.c b/src/components/implementation/no_interface/cFE_booter/cFE_util.c index b1bfc3eb3e..9014213663 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.c @@ -6,6 +6,8 @@ #include #include +#include "cFE_util.h" + static void cos_llprint(char *s, int len) { call_cap(PRINT_CAP_TEMP, (int)s, len, 0, 0); } @@ -36,11 +38,11 @@ printc(char *fmt, ...) return ret; } -void panic(char* message){ - printc("cFE panic: %s", message); +void panic_impl(const char* function, char* message){ + printc("cFE panic in %s: %s", function, message); assert(0); } void __isoc99_sscanf(void){ - panic("__isoc99_sscanf not implemented!"); + PANIC("__isoc99_sscanf not implemented!"); } diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.h b/src/components/implementation/no_interface/cFE_booter/cFE_util.h index 867cf7dc81..e3b0ad9fae 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.h +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.h @@ -13,7 +13,9 @@ prints(char *s); int __attribute__((format(printf,1,2))) printc(char *fmt, ...); -void panic(char* message); +#define PANIC(a) panic_impl(__func__, a) + +void panic_impl(const char* function, char* message); void __isoc99_sscanf(void); diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 2711fd5afe..ab1121adf8 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -8,7 +8,7 @@ */ int32 OS_API_Init(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -20,7 +20,7 @@ int32 OS_API_Init(void) */ void OS_IdleLoop(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* @@ -30,7 +30,7 @@ void OS_IdleLoop(void) */ void OS_DeleteAllObjects(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* @@ -41,7 +41,7 @@ void OS_DeleteAllObjects(void) */ void OS_ApplicationShutdown(uint8 flag) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* @@ -50,25 +50,25 @@ void OS_ApplicationShutdown(uint8 flag) int32 OS_Milli2Ticks(uint32 milli_seconds) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_Tick2Micros(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_GetLocalTime(OS_time_t *time_struct) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SetLocalTime(OS_time_t *time_struct) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -80,20 +80,20 @@ int32 OS_ExcAttachHandler(uint32 ExceptionNumber, void (*ExceptionHandler)(uint32, const void *,uint32), int32 parameter) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ExcEnable (int32 ExceptionNumber) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ExcDisable (int32 ExceptionNumber) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -104,31 +104,31 @@ int32 OS_ExcDisable (int32 ExceptionNumber) int32 OS_FPUExcAttachHandler(uint32 ExceptionNumber, void * ExceptionHandler, int32 parameter) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_FPUExcEnable(int32 ExceptionNumber) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_FPUExcDisable(int32 ExceptionNumber) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_FPUExcSetMask(uint32 mask) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_FPUExcGetMask(uint32 *mask) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -137,49 +137,49 @@ int32 OS_FPUExcGetMask(uint32 *mask) */ int32 OS_IntAttachHandler(uint32 InterruptNumber, osal_task_entry InterruptHandler, int32 parameter) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_IntUnlock(int32 IntLevel) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_IntLock(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_IntEnable(int32 Level) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_IntDisable(int32 Level) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_IntSetMask(uint32 mask) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_IntGetMask(uint32 *mask) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_IntAck(int32 InterruptNumber) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -188,37 +188,37 @@ int32 OS_IntAck(int32 InterruptNumber) */ int32 OS_ShMemInit(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ShMemCreate(uint32 *Id, uint32 NBytes, const char* SegName) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ShMemSemTake(uint32 Id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ShMemSemGive(uint32 Id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ShMemAttach(cpuaddr * Address, uint32 Id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ShMemGetIdByName(uint32 *ShMemId, const char *SegName ) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -227,7 +227,7 @@ int32 OS_ShMemGetIdByName(uint32 *ShMemId, const char *SegName ) */ int32 OS_HeapGetInfo(OS_heap_prop_t *heap_prop) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -236,7 +236,7 @@ int32 OS_HeapGetInfo(OS_heap_prop_t *heap_prop) */ int32 OS_GetErrorName(int32 error_num, os_err_name_t* err_name) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -245,17 +245,17 @@ int32 OS_GetErrorName(int32 error_num, os_err_name_t* err_name) ** Abstraction for printf statements */ void OS_printf( const char *string, ...) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } void OS_printf_disable(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } void OS_printf_enable(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* @@ -265,5 +265,5 @@ void OS_printf_enable(void) */ void OS_ApplicationExit(int32 Status) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } diff --git a/src/components/implementation/no_interface/cFE_booter/osfiles.c b/src/components/implementation/no_interface/cFE_booter/osfiles.c index 055ecfc5bf..642179d58f 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfiles.c +++ b/src/components/implementation/no_interface/cFE_booter/osfiles.c @@ -13,7 +13,7 @@ int32 OS_FS_Init(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -22,7 +22,7 @@ int32 OS_FS_Init(void) */ int32 OS_creat(const char *path, int32 access) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -31,7 +31,7 @@ int32 OS_creat(const char *path, int32 access) */ int32 OS_open(const char *path, int32 access, uint32 mode) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -40,7 +40,7 @@ int32 OS_open(const char *path, int32 access, uint32 mode) */ int32 OS_close(int32 filedes) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -49,7 +49,7 @@ int32 OS_close(int32 filedes) */ int32 OS_read(int32 filedes, void *buffer, uint32 nbytes) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -58,7 +58,7 @@ int32 OS_read(int32 filedes, void *buffer, uint32 nbytes) */ int32 OS_write(int32 filedes, void *buffer, uint32 nbytes) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -67,7 +67,7 @@ int32 OS_write(int32 filedes, void *buffer, uint32 nbytes) */ int32 OS_chmod(const char *path, uint32 access) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -76,7 +76,7 @@ int32 OS_chmod(const char *path, uint32 access) */ int32 OS_stat(const char *path, os_fstat_t *filestats) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -85,7 +85,7 @@ int32 OS_stat(const char *path, os_fstat_t *filestats) */ int32 OS_lseek(int32 filedes, int32 offset, uint32 whence) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -94,7 +94,7 @@ int32 OS_lseek(int32 filedes, int32 offset, uint32 whence) */ int32 OS_remove(const char *path) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -103,7 +103,7 @@ int32 OS_remove(const char *path) */ int32 OS_rename(const char *old_filename, const char *new_filename) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -112,7 +112,7 @@ int32 OS_rename(const char *old_filename, const char *new_filename) */ int32 OS_cp(const char *src, const char *dest) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -121,7 +121,7 @@ int32 OS_cp(const char *src, const char *dest) */ int32 OS_mv(const char *src, const char *dest) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -130,7 +130,7 @@ int32 OS_mv(const char *src, const char *dest) */ int32 OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -139,7 +139,7 @@ int32 OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) */ int32 OS_FileOpenCheck(char *Filename) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -148,7 +148,7 @@ int32 OS_FileOpenCheck(char *Filename) */ int32 OS_CloseAllFiles(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -157,7 +157,7 @@ int32 OS_CloseAllFiles(void) */ int32 OS_CloseFileByName(char *Filename) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -171,7 +171,7 @@ int32 OS_CloseFileByName(char *Filename) */ int32 OS_mkdir(const char *path, uint32 access) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -180,7 +180,7 @@ int32 OS_mkdir(const char *path, uint32 access) */ os_dirp_t OS_opendir(const char *path) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -189,7 +189,7 @@ os_dirp_t OS_opendir(const char *path) */ int32 OS_closedir(os_dirp_t directory) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -198,7 +198,7 @@ int32 OS_closedir(os_dirp_t directory) */ void OS_rewinddir(os_dirp_t directory) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* @@ -206,7 +206,7 @@ void OS_rewinddir(os_dirp_t directory) */ os_dirent_t * OS_readdir(os_dirp_t directory) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -215,7 +215,7 @@ os_dirent_t * OS_readdir(os_dirp_t directory) */ int32 OS_rmdir(const char *path) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -228,7 +228,7 @@ int32 OS_rmdir(const char *path) int32 OS_mkfs(char *address,char *devname, char *volname, uint32 blocksize, uint32 numblocks) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -236,7 +236,7 @@ int32 OS_mkfs(char *address,char *devname, char *volname, */ int32 OS_mount(const char *devname, char *mountpoint) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -245,7 +245,7 @@ int32 OS_mount(const char *devname, char *mountpoint) */ int32 OS_initfs(char *address,char *devname, char *volname, uint32 blocksize, uint32 numblocks) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -254,7 +254,7 @@ int32 OS_initfs(char *address,char *devname, char *volname, uint32 blocksize, ui */ int32 OS_rmfs(char *devname) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -263,7 +263,7 @@ int32 OS_rmfs(char *devname) */ int32 OS_unmount(const char *mountpoint) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -272,7 +272,7 @@ int32 OS_unmount(const char *mountpoint) */ int32 OS_fsBlocksFree(const char *name) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -283,7 +283,7 @@ int32 OS_fsBlocksFree(const char *name) */ int32 OS_fsBytesFree(const char *name, uint64 *bytes_free) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -292,7 +292,7 @@ int32 OS_fsBytesFree(const char *name, uint64 *bytes_free) */ os_fshealth_t OS_chkfs(const char *name, boolean repair) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -301,7 +301,7 @@ os_fshealth_t OS_chkfs(const char *name, boolean repair) */ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, char * MountPoint) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -310,7 +310,7 @@ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, char * MountPoint) */ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -319,7 +319,7 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) */ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -331,6 +331,6 @@ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) * command to the file specified by the given OSAPI file descriptor */ int32 OS_ShellOutputToFile(char* Cmd, int32 OS_fd) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index ae51c41cfb..4c0a962fb6 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -8,36 +8,36 @@ */ int32 OS_ModuleTableInit(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SymbolTableDump(const char *filename, uint32 size_limit) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ModuleLoad(uint32 *module_id, const char *module_name, const char *filename) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ModuleUnload(uint32 module_id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_ModuleInfo(uint32 module_id, OS_module_prop_t *module_info) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } diff --git a/src/components/implementation/no_interface/cFE_booter/osnetwork.c b/src/components/implementation/no_interface/cFE_booter/osnetwork.c index 0bdedec2d4..c269ef9de7 100644 --- a/src/components/implementation/no_interface/cFE_booter/osnetwork.c +++ b/src/components/implementation/no_interface/cFE_booter/osnetwork.c @@ -8,85 +8,85 @@ */ int32 OS_SocketOpen(uint32 *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t Type) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketClose(uint32 sock_id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketBind(uint32 sock_id, const OS_SockAddr_t *Addr) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketConnect(uint32 sock_id, const OS_SockAddr_t *Addr, int32 timeout) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketAccept(uint32 sock_id, uint32 *connsock_id, OS_SockAddr_t *Addr, int32 timeout) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketRecvFrom(uint32 sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketSendTo(uint32 sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketGetIdByName (uint32 *sock_id, const char *sock_name) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketGetInfo (uint32 sock_id, OS_socket_prop_t *sock_prop) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketAddrToString(char *buffer, uint32 buflen, const OS_SockAddr_t *Addr) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketAddrFromString(OS_SockAddr_t *Addr, const char *string) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketAddrGetPort(uint16 *PortNum, const OS_SockAddr_t *Addr) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -96,12 +96,12 @@ int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum) */ int32 OS_NetworkGetID(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_NetworkGetHostName(char *host_name, uint32 name_len) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } diff --git a/src/components/implementation/no_interface/cFE_booter/osqueue.c b/src/components/implementation/no_interface/cFE_booter/osqueue.c index f7c9b4396f..83c94c12b4 100644 --- a/src/components/implementation/no_interface/cFE_booter/osqueue.c +++ b/src/components/implementation/no_interface/cFE_booter/osqueue.c @@ -13,38 +13,38 @@ int32 OS_QueueCreate(uint32 *queue_id, const char *queue_name, uint32 queue_depth, uint32 data_size, uint32 flags) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_QueueDelete(uint32 queue_id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_QueueGet(uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_QueuePut(uint32 queue_id, const void *data, uint32 size, uint32 flags) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_QueueGetIdByName(uint32 *queue_id, const char *queue_name) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_QueueGetInfo(uint32 queue_id, OS_queue_prop_t *queue_prop) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index d789841040..1e1bd2cb79 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -14,59 +14,59 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, uint32 stack_size, uint32 priority, uint32 flags) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TaskDelete(uint32 task_id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } void OS_TaskExit(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer){ - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TaskDelay(uint32 millisecond) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TaskRegister(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } uint32 OS_TaskGetId(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TaskGetIdByName(uint32 *task_id, const char *task_name) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -77,37 +77,37 @@ int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_MutSemGive(uint32 sem_id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_MutSemTake(uint32 sem_id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_MutSemDelete(uint32 sem_id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_MutSemGetIdByName(uint32 *sem_id, const char *sem_name) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -118,91 +118,91 @@ int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) int32 OS_BinSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_BinSemFlush(uint32 sem_id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_BinSemGive(uint32 sem_id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_BinSemTake(uint32 sem_id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_BinSemTimedWait(uint32 sem_id, uint32 msecs) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_BinSemDelete(uint32 sem_id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_BinSemGetIdByName(uint32 *sem_id, const char *sem_name) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_BinSemGetInfo(uint32 sem_id, OS_bin_sem_prop_t *bin_prop) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_CountSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_CountSemGive(uint32 sem_id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_CountSemTake(uint32 sem_id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_CountSemTimedWait(uint32 sem_id, uint32 msecs) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_CountSemDelete(uint32 sem_id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_CountSemGetIdByName(uint32 *sem_id, const char *sem_name) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_CountSemGetInfo(uint32 sem_id, OS_count_sem_prop_t *count_prop) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } diff --git a/src/components/implementation/no_interface/cFE_booter/ostimer.c b/src/components/implementation/no_interface/cFE_booter/ostimer.c index 3afed45c2c..5971691bbf 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostimer.c +++ b/src/components/implementation/no_interface/cFE_booter/ostimer.c @@ -9,68 +9,68 @@ int32 OS_TimerAPIInit(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimeBaseCreate(uint32 *timer_id, const char *timebase_name, OS_TimerSync_t external_sync) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimeBaseSet(uint32 timer_id, uint32 start_time, uint32 interval_time) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimeBaseDelete(uint32 timer_id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimeBaseGetIdByName(uint32 *timer_id, const char *timebase_name) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimerCreate(uint32 *timer_id, const char *timer_name, uint32 *clock_accuracy, OS_TimerCallback_t callback_ptr) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimerAdd(uint32 *timer_id, const char *timer_name, uint32 timebase_id, OS_ArgCallback_t callback_ptr, void *callback_arg) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimerSet(uint32 timer_id, uint32 start_time, uint32 interval_time) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimerDelete(uint32 timer_id) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimerGetIdByName(uint32 *timer_id, const char *timer_name) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TimerGetInfo(uint32 timer_id, OS_timer_prop_t *timer_prop) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c index 9d006acbcf..865038409a 100644 --- a/src/components/implementation/no_interface/cFE_booter/psp.c +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -11,7 +11,7 @@ */ void CFE_PSP_Main(uint32 ModeId, char *StartupFilePath) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* @@ -23,7 +23,7 @@ void CFE_PSP_Main(uint32 ModeId, char *StartupFilePath) void CFE_PSP_GetTime(OS_time_t *LocalTime) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* This call gets the local time from the hardware on the Vxworks system * on the mcp750s @@ -32,7 +32,7 @@ void CFE_PSP_GetTime(OS_time_t *LocalTime) void CFE_PSP_Restart(uint32 resetType) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_Restart is the entry point back to the BSP to restart the processor. @@ -42,7 +42,7 @@ void CFE_PSP_Restart(uint32 resetType) uint32 CFE_PSP_GetRestartType(uint32 *restartSubType ) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -60,7 +60,7 @@ void CFE_PSP_FlushCaches(uint32 type, cpuaddr address, uint32 size); uint32 CFE_PSP_GetProcessorId(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -71,7 +71,7 @@ uint32 CFE_PSP_GetProcessorId(void) uint32 CFE_PSP_GetSpacecraftId(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -81,7 +81,7 @@ uint32 CFE_PSP_GetSpacecraftId(void) uint32 CFE_PSP_Get_Timer_Tick(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -91,7 +91,7 @@ uint32 CFE_PSP_Get_Timer_Tick(void) uint32 CFE_PSP_GetTimerTicksPerSecond(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -103,7 +103,7 @@ uint32 CFE_PSP_GetTimerTicksPerSecond(void) uint32 CFE_PSP_GetTimerLow32Rollover(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -116,7 +116,7 @@ uint32 CFE_PSP_GetTimerLow32Rollover(void) void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32 *Tbl) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_Get_Timebase @@ -124,7 +124,7 @@ void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32 *Tbl) uint32 CFE_PSP_Get_Dec(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -134,7 +134,7 @@ uint32 CFE_PSP_Get_Dec(void) int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType ) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -147,7 +147,7 @@ int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType ) int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -156,7 +156,7 @@ int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS) int32 CFE_PSP_WriteToCDS(void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumBytes) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -165,7 +165,7 @@ int32 CFE_PSP_WriteToCDS(void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumByt int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumBytes) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -174,7 +174,7 @@ int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumByt int32 CFE_PSP_GetResetArea (cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -185,7 +185,7 @@ int32 CFE_PSP_GetResetArea (cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea ) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -195,7 +195,7 @@ int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk ) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -205,7 +205,7 @@ int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk ) int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *SizeOfKernelSegment) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -214,7 +214,7 @@ int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *Size int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFESegment) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -223,7 +223,7 @@ int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFES void CFE_PSP_WatchdogInit(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_WatchdogInit configures the watchdog timer. @@ -231,7 +231,7 @@ void CFE_PSP_WatchdogInit(void) void CFE_PSP_WatchdogEnable(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_WatchdogEnable enables the watchdog timer. @@ -239,7 +239,7 @@ void CFE_PSP_WatchdogEnable(void) void CFE_PSP_WatchdogDisable(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_WatchdogDisable disables the watchdog timer. @@ -247,7 +247,7 @@ void CFE_PSP_WatchdogDisable(void) void CFE_PSP_WatchdogService(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_WatchdogService services the watchdog timer according to the @@ -256,7 +256,7 @@ void CFE_PSP_WatchdogService(void) uint32 CFE_PSP_WatchdogGet(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -265,7 +265,7 @@ uint32 CFE_PSP_WatchdogGet(void) void CFE_PSP_WatchdogSet(uint32 WatchdogValue) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_WatchdogSet sets the watchdog time in milliseconds @@ -273,7 +273,7 @@ void CFE_PSP_WatchdogSet(uint32 WatchdogValue) void CFE_PSP_Panic(int32 ErrorCode) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_Panic is called by the cFE Core startup code when it needs to abort the @@ -282,7 +282,7 @@ void CFE_PSP_Panic(int32 ErrorCode) int32 CFE_PSP_InitSSR(uint32 bus, uint32 device, char *DeviceName) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -291,7 +291,7 @@ int32 CFE_PSP_InitSSR(uint32 bus, uint32 device, char *DeviceName) int32 CFE_PSP_Decompress( char * srcFileName, char * dstFileName) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } /* @@ -302,7 +302,7 @@ int32 CFE_PSP_Decompress( char * srcFileName, char * dstFileName) void CFE_PSP_AttachExceptions(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_AttachExceptions will setup the exception environment for the chosen platform @@ -313,7 +313,7 @@ void CFE_PSP_AttachExceptions(void) void CFE_PSP_SetDefaultExceptionEnvironment(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** @@ -329,37 +329,37 @@ void CFE_PSP_SetDefaultExceptionEnvironment(void) */ int32 CFE_PSP_PortRead8(cpuaddr PortAddress, uint8 *ByteValue) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_PortWrite8(cpuaddr PortAddress, uint8 ByteValue) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_PortRead16(cpuaddr PortAddress, uint16 *uint16Value) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_PortWrite16(cpuaddr PortAddress, uint16 uint16Value) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_PortRead32(cpuaddr PortAddress, uint32 *uint32Value) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_PortWrite32(cpuaddr PortAddress, uint32 uint32Value) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } @@ -368,116 +368,116 @@ int32 CFE_PSP_PortWrite32(cpuaddr PortAddress, uint32 uint32Value) */ int32 CFE_PSP_MemRead8(cpuaddr MemoryAddress, uint8 *ByteValue) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemWrite8(cpuaddr MemoryAddress, uint8 ByteValue) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemRead16(cpuaddr MemoryAddress, uint16 *uint16Value) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemWrite16(cpuaddr MemoryAddress, uint16 uint16Value) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemRead32(cpuaddr MemoryAddress, uint32 *uint32Value) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemWrite32(cpuaddr MemoryAddress, uint32 uint32Value) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemCpy(void *dest, void *src, uint32 n) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } uint32 CFE_PSP_MemRanges(void) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemRangeSet(uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, uint32 Size, uint32 WordSize, uint32 Attributes) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_MemRangeGet (uint32 RangeNum, uint32 *MemoryType, cpuaddr *StartAddr, uint32 *Size, uint32 *WordSize, uint32 *Attributes) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_EepromWrite8(cpuaddr MemoryAddress, uint8 ByteValue) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_EepromWrite16(cpuaddr MemoryAddress, uint16 uint16Value) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_EepromWrite32(cpuaddr MemoryAddress, uint32 uint32Value) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_EepromWriteEnable(uint32 Bank) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_EepromWriteDisable(uint32 Bank) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_EepromPowerUp(uint32 Bank) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 CFE_PSP_EepromPowerDown(uint32 Bank) { - panic("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } From 786ba2b978264e7b29d59d231be970e5080b495f Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sun, 13 Nov 2016 19:16:06 -0500 Subject: [PATCH 014/122] Improve stubs so the cFE can get to its real entrypoint --- .../no_interface/cFE_booter/cFE_entrypoint.c | 20 +++ .../no_interface/cFE_booter/cFE_util.c | 16 +-- .../no_interface/cFE_booter/cFE_util.h | 3 +- .../no_interface/cFE_booter/osapi.c | 121 +++++++++++++----- .../no_interface/cFE_booter/ostask.c | 25 ++++ .../no_interface/cFE_booter/psp.c | 5 +- 6 files changed, 142 insertions(+), 48 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c index c33ff94953..eed5cd234f 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c @@ -79,6 +79,26 @@ void cos_init(void) { OS_printf("CFE_PSP: Starting the cFE with a POWER ON reset.\n"); } + /* + ** Initialize the OS API + */ + OS_API_Init(); + + /* + ** Initialize the statically linked modules (if any) + ** This is only applicable to CMake build - classic build + ** does not have the logic to selectively include/exclude modules + ** + ** This is useless until we support cmake + */ + CFE_PSP_ModuleInit(); + + /* + ** Initialize the reserved memory + */ + CFE_PSP_InitProcessorReservedMemory(reset_type); + + /* ** Call cFE entry point. */ diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.c b/src/components/implementation/no_interface/cFE_booter/cFE_util.c index 9014213663..6225fb6613 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.c @@ -8,19 +8,9 @@ #include "cFE_util.h" -static void -cos_llprint(char *s, int len) -{ call_cap(PRINT_CAP_TEMP, (int)s, len, 0, 0); } - - -int -prints(char *s) +void llprint(const char *s, int len) { - int len = strlen(s); - - cos_llprint(s, len); - - return len; + call_cap(PRINT_CAP_TEMP, (int)s, len, 0, 0); } int __attribute__((format(printf,1,2))) @@ -33,7 +23,7 @@ printc(char *fmt, ...) va_start(arg_ptr, fmt); ret = vsnprintf(s, len, fmt, arg_ptr); va_end(arg_ptr); - cos_llprint(s, ret); + llprint(s, ret); return ret; } diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.h b/src/components/implementation/no_interface/cFE_booter/cFE_util.h index e3b0ad9fae..76604a1b13 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.h +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.h @@ -8,8 +8,7 @@ #ifndef _cFE_util_ #define _cFE_util_ -int -prints(char *s); +void llprint(const char *s, int len); int __attribute__((format(printf,1,2))) printc(char *fmt, ...); diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index ab1121adf8..cec9a08dbd 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -8,19 +8,7 @@ */ int32 OS_API_Init(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -/* -** OS-specific background thread implementation - waits forever for events to occur. -** -** This should be called from the BSP main routine / initial thread after all other -** board / application initialization has taken place and all other tasks are running. -*/ -void OS_IdleLoop(void) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! + // It's safe for this method to do nothing for now } /* @@ -30,19 +18,10 @@ void OS_IdleLoop(void) */ void OS_DeleteAllObjects(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + // It's safe for this method to do nothing for now } -/* -** OS_ApplicationShutdown() provides a means for a user-created thread to request the orderly -** shutdown of the whole system, such as part of a user-commanded reset command. -** This is preferred over e.g. ApplicationExit() which exits immediately and does not -** provide for any means to clean up first. -*/ -void OS_ApplicationShutdown(uint8 flag) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! -} + /* ** OS Time/Tick related API @@ -234,28 +213,108 @@ int32 OS_HeapGetInfo(OS_heap_prop_t *heap_prop) /* ** API for useful debugging function */ + +// Implementation stolen from the posix os api int32 OS_GetErrorName(int32 error_num, os_err_name_t* err_name) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + /* + * Implementation note for developers: + * + * The size of the string literals below (including the terminating null) + * must fit into os_err_name_t. Always check the string length when + * adding or modifying strings in this function. If changing os_err_name_t + * then confirm these strings will fit. + */ + + os_err_name_t local_name; + uint32 return_code = OS_SUCCESS; + + if ( err_name == NULL ) + { + return(OS_INVALID_POINTER); + } + + switch (error_num) + { + case OS_SUCCESS: + strcpy(local_name,"OS_SUCCESS"); break; + case OS_ERROR: + strcpy(local_name,"OS_ERROR"); break; + case OS_INVALID_POINTER: + strcpy(local_name,"OS_INVALID_POINTER"); break; + case OS_ERROR_ADDRESS_MISALIGNED: + strcpy(local_name,"OS_ADDRESS_MISALIGNED"); break; + case OS_ERROR_TIMEOUT: + strcpy(local_name,"OS_ERROR_TIMEOUT"); break; + case OS_INVALID_INT_NUM: + strcpy(local_name,"OS_INVALID_INT_NUM"); break; + case OS_SEM_FAILURE: + strcpy(local_name,"OS_SEM_FAILURE"); break; + case OS_SEM_TIMEOUT: + strcpy(local_name,"OS_SEM_TIMEOUT"); break; + case OS_QUEUE_EMPTY: + strcpy(local_name,"OS_QUEUE_EMPTY"); break; + case OS_QUEUE_FULL: + strcpy(local_name,"OS_QUEUE_FULL"); break; + case OS_QUEUE_TIMEOUT: + strcpy(local_name,"OS_QUEUE_TIMEOUT"); break; + case OS_QUEUE_INVALID_SIZE: + strcpy(local_name,"OS_QUEUE_INVALID_SIZE"); break; + case OS_QUEUE_ID_ERROR: + strcpy(local_name,"OS_QUEUE_ID_ERROR"); break; + case OS_ERR_NAME_TOO_LONG: + strcpy(local_name,"OS_ERR_NAME_TOO_LONG"); break; + case OS_ERR_NO_FREE_IDS: + strcpy(local_name,"OS_ERR_NO_FREE_IDS"); break; + case OS_ERR_NAME_TAKEN: + strcpy(local_name,"OS_ERR_NAME_TAKEN"); break; + case OS_ERR_INVALID_ID: + strcpy(local_name,"OS_ERR_INVALID_ID"); break; + case OS_ERR_NAME_NOT_FOUND: + strcpy(local_name,"OS_ERR_NAME_NOT_FOUND"); break; + case OS_ERR_SEM_NOT_FULL: + strcpy(local_name,"OS_ERR_SEM_NOT_FULL"); break; + case OS_ERR_INVALID_PRIORITY: + strcpy(local_name,"OS_ERR_INVALID_PRIORITY"); break; + + default: strcpy(local_name,"ERROR_UNKNOWN"); + return_code = OS_ERROR; + } + + strcpy((char*) err_name, local_name); + + return return_code; } /* ** Abstraction for printf statements */ -void OS_printf( const char *string, ...) { - PANIC("Unimplemented method!"); // TODO: Implement me! +int is_printf_enabled = TRUE; + +void OS_printf(const char *string, ...) +{ + if(is_printf_enabled) { + char s[OS_BUFFER_SIZE]; + va_list arg_ptr; + int ret, len = OS_BUFFER_SIZE; + + va_start(arg_ptr, string); + ret = vsnprintf(s, len, string, arg_ptr); + va_end(arg_ptr); + llprint(s, ret); + } } + void OS_printf_disable(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + is_printf_enabled = FALSE; } void OS_printf_enable(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + is_printf_enabled = TRUE; } /* @@ -265,5 +324,5 @@ void OS_printf_enable(void) */ void OS_ApplicationExit(int32 Status) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Application exit invoked!"); } diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 1e1bd2cb79..3ea911c0fb 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -70,6 +70,31 @@ int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) return 0; } +/* +** Main thread waiting API +*/ + +/* +** OS-specific background thread implementation - waits forever for events to occur. +** +** This should be called from the BSP main routine / initial thread after all other +** board / application initialization has taken place and all other tasks are running. +*/ +void OS_IdleLoop(void) +{ + PANIC("Unimplemented method!"); // TODO: Implement me! +} + +/* +** OS_ApplicationShutdown() provides a means for a user-created thread to request the orderly +** shutdown of the whole system, such as part of a user-commanded reset command. +** This is preferred over e.g. ApplicationExit() which exits immediately and does not +** provide for any means to clean up first. +*/ +void OS_ApplicationShutdown(uint8 flag) +{ + PANIC("Unimplemented method!"); // TODO: Implement me! +} /* ** Mutex API diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c index 865038409a..12a6d56aad 100644 --- a/src/components/implementation/no_interface/cFE_booter/psp.c +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -132,9 +132,10 @@ uint32 CFE_PSP_Get_Dec(void) */ -int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType ) +int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType) { - PANIC("Unimplemented method!"); // TODO: Implement me! + // Since all operations on reserved memory are unimplemented, it's safe to + // do nothing here return 0; } /* From fdc75ab25071a96e3cabe3df601f55f501752348 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Thu, 17 Nov 2016 15:08:59 -0500 Subject: [PATCH 015/122] Add testing infrastructure to the cFE entrypoint --- .../no_interface/cFE_booter/cFE_entrypoint.c | 10 ++++++++-- .../implementation/no_interface/cFE_booter/cFE_util.c | 7 +++++++ .../implementation/no_interface/cFE_booter/cFE_util.h | 3 +++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c index eed5cd234f..83221530da 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c @@ -32,7 +32,10 @@ void CFE_PSP_ModuleInit(void) { } -// Mandatory defines +// If RUN_TESTING_CODE is defined, testing code will be run +// #define RUN_TESTING_CODE + +// "Magic" constants #define CFE_PSP_CPU_NAME_LENGTH 32 #define CFE_PSP_RESET_NAME_LENGTH 10 @@ -98,7 +101,9 @@ void cos_init(void) { */ CFE_PSP_InitProcessorReservedMemory(reset_type); - + #ifdef RUN_TESTING_CODE + // Testing code goes here + #else /* ** Call cFE entry point. */ @@ -111,6 +116,7 @@ void cos_init(void) { ** someone calls OS_ApplicationShutdown(TRUE) */ OS_IdleLoop(); + #endif PANIC("Application was shutdown!"); } diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.c b/src/components/implementation/no_interface/cFE_booter/cFE_util.c index 6225fb6613..0293c8df38 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.c @@ -13,6 +13,13 @@ void llprint(const char *s, int len) call_cap(PRINT_CAP_TEMP, (int)s, len, 0, 0); } +int prints(char *s) +{ + int len = strlen(s); + llprint(s, len); + return len; +} + int __attribute__((format(printf,1,2))) printc(char *fmt, ...) { diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.h b/src/components/implementation/no_interface/cFE_booter/cFE_util.h index 76604a1b13..5510f243af 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.h +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.h @@ -10,6 +10,9 @@ void llprint(const char *s, int len); +// I'm not sure why we even have to reimplement prints... +int prints(char *s); + int __attribute__((format(printf,1,2))) printc(char *fmt, ...); #define PANIC(a) panic_impl(__func__, a) From 449b2d6bdff480334bdbf204de358924a6de762a Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sat, 19 Nov 2016 15:14:26 -0500 Subject: [PATCH 016/122] Improve the cFE entrypoint --- .gitignore | 1 + .../no_interface/cFE_booter/cFE_entrypoint.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/.gitignore b/.gitignore index c5fa0989ac..4e7bd2b27f 100755 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ *.sw* *# .#* +**/.DS_Store .fn_dependencies .fn_exports .exported_interfaces diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c index 83221530da..2c9d2cc84b 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c @@ -82,11 +82,14 @@ void cos_init(void) { OS_printf("CFE_PSP: Starting the cFE with a POWER ON reset.\n"); } + OS_printf("CFE_PSP: Initializing the OS API...\n"); /* ** Initialize the OS API */ OS_API_Init(); + OS_printf("CFE_PSP: The the OS API was successfully initialized!\n"); + OS_printf("CFE_PSP: Doing PSP setup...\n"); /* ** Initialize the statically linked modules (if any) ** This is only applicable to CMake build - classic build @@ -101,14 +104,23 @@ void cos_init(void) { */ CFE_PSP_InitProcessorReservedMemory(reset_type); + OS_printf("CFE_PSP: PSP setup successful!\n"); + + #ifdef RUN_TESTING_CODE // Testing code goes here + OS_printf("CFE_PSP: Running testing code...\n"); + + OS_printf("CFE_PSP: Running testing code completed\n"); #else + + OS_printf("CFE_PSP: Starting the cFE proper...\n"); /* ** Call cFE entry point. */ CFE_ES_MAIN_FUNCTION(reset_type, args.SubType, 1, CFE_ES_NONVOL_STARTUP_FILE); + OS_printf("CFE_PSP: cFE started, main thread sleeping\n"); /* ** Let the main thread sleep. ** From 1fce2f535f2eda3ca57a63b0d1322f6fce37cc0c Mon Sep 17 00:00:00 2001 From: Zach Day Date: Tue, 18 Apr 2017 18:59:42 -0400 Subject: [PATCH 017/122] Preliminary queue implementation --- .../no_interface/cFE_booter/osqueue.c | 232 +++++++++++++++--- 1 file changed, 203 insertions(+), 29 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osqueue.c b/src/components/implementation/no_interface/cFE_booter/osqueue.c index 83c94c12b4..635754f541 100644 --- a/src/components/implementation/no_interface/cFE_booter/osqueue.c +++ b/src/components/implementation/no_interface/cFE_booter/osqueue.c @@ -1,50 +1,224 @@ #include "cFE_util.h" -#include "gen/osapi.h" #include "gen/common_types.h" +#include "gen/osapi.h" -/* -** Message Queue API -*/ +#include -/* -** Queue Create now has the Queue ID returned to the caller. -*/ -int32 OS_QueueCreate(uint32 *queue_id, const char *queue_name, - uint32 queue_depth, uint32 data_size, uint32 flags) +#define MAX_QUEUE_DATA_SIZE (1024 * 1024) + +/* The main queue data structure. */ +struct queue { + /* Whether or not the index of this queue is already taken. */ + int32 free; + + /* The number of elements allowed in the queue. */ + int32 depth; + + /* The size, in bytes, of each element in the queue. */ + int32 data_size; + + /* The name of the queue. For display purposes only. */ + char name[OS_MAX_API_NAME]; + + uint32 head; + uint32 tail; +}; + +/* The global queue bank. */ +struct queue queues[OS_MAX_QUEUES]; + +/* The bank of data that queues have access to. */ +char queue_data[OS_MAX_QUEUES][MAX_QUEUE_DATA_SIZE]; + +int32 +OS_QueueCreate(uint32* queue_id, const char* queue_name, uint32 queue_depth, uint32 data_size, uint32 flags) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + int32 i; + uint32 qid; + + /* Check validity of parameters. */ + if (queue_id == NULL || queue_name == NULL) { + return OS_INVALID_POINTER; + } + + /* Check name length. */ + if (strlen(queue_name) >= OS_MAX_API_NAME) { + return OS_ERR_NAME_TOO_LONG; + } + + /* Check to see if the name is already taken. */ + for (i = 0 ; i < OS_MAX_QUEUES ; i++) { + if ((queues[i].free == FALSE) && strcmp((char*)queue_name, queues[i].name) == 0) { + return OS_ERR_NAME_TAKEN; + } + } + + /* Calculate the queue ID. */ + for (qid = 0 ; qid < OS_MAX_QUEUES ; qid++) { + if (queues[qid].free == TRUE) { + break; + } + } + + /* Fail if there are too many queues. */ + if (qid >= OS_MAX_QUEUES || queues[qid].free != TRUE) { + return OS_ERR_NO_FREE_IDS; + } + + /* OS_ERROR may also be returned in the event that an OS call fails, but none are used here. */ + + *queue_id = qid; + queues[*queue_id].free = FALSE; + queues[*queue_id].depth = queue_depth; + queues[*queue_id].data_size = data_size; + strcpy(queues[*queue_id].name, queue_name); + + return OS_SUCCESS; } -int32 OS_QueueDelete(uint32 queue_id) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; +int32 +OS_QueueDelete(uint32 queue_id) { + /* Check if there is a queue to be deleted at the ID. */ + if (queues[queue_id].free == TRUE) { + return OS_ERR_INVALID_ID; + } + + /* Reset all values in the queue. */ + queues[queue_id].free = TRUE; + queues[queue_id].depth = 0; + queues[queue_id].data_size = 0; + strcpy(queues[queue_id].name, ""); + queues[queue_id].head = 0; + queues[queue_id].tail = 0; + + /* OS_ERROR may also be returned in the event that an OS call fails, but none are used here. */ + + return OS_SUCCESS; } -int32 OS_QueueGet(uint32 queue_id, void *data, uint32 size, - uint32 *size_copied, int32 timeout) +int32 +OS_QueueGet(uint32 queue_id, void* data, uint32 size, uint32* size_copied, int32 timeout) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + uint32 i; + + /* Check if the requested queue exists. */ + if (queues[queue_id].free == TRUE) { + return OS_ERR_INVALID_ID; + } + + /* Check for a NULL pointer. */ + if (data == NULL) { + return OS_INVALID_POINTER; + } + + /* Check if there are messages to be received. */ + if (queues[queue_id].head == queues[queue_id].tail) { + return OS_QUEUE_EMPTY; + } + + /* A helper reference to the currently selected queue. */ + struct queue* cur = &queues[queue_id]; + + /* Walk through the bytes at the head of the queue and write them to buffer `data`. */ + for (i = 0; i < size; i++) { + *((char*)data + i) = queue_data[queue_id][cur->head * cur->data_size + i]; + } + + /* Advance the queue head, wrapping if it is passed `depth`. */ + cur->head = (cur->head + 1) % cur->depth; + + return OS_SUCCESS; } -int32 OS_QueuePut(uint32 queue_id, const void *data, uint32 size, - uint32 flags) +/* + * This function is used to send data on an existing queue. The flags can be used to specify + * the behavior of the queue if it is full. + */ +int32 +OS_QueuePut(uint32 queue_id, const void* data, uint32 size, uint32 flags) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + uint32 i; + + /* Check if the requested queue exists. */ + if (queues[queue_id].free == TRUE) { + return OS_ERR_INVALID_ID; + } + + /* Check for invalid pointers. */ + if (data == NULL) { + return OS_INVALID_POINTER; + } + + /* Check if space remains in the queue. */ + if ((queues[queue_id].tail + 1) % queues[queue_id].depth == queues[queue_id].head) { + return OS_QUEUE_FULL; + } + + /* A helper pointer to the currently selected queue. */ + struct queue* cur = &queues[queue_id]; + + /* Walk through the bytes in `data` and write them to the tail of the specified queue. */ + for (i = 0 ; i < size ; i++) { + queue_data[queue_id][cur->tail * cur->data_size + i] = *((char*)data + i); + } + + /* Advance the queue tail, wrapping if it is past `depth`. */ + cur->tail = (cur->tail + 1) % cur->depth; + + return OS_SUCCESS; } -int32 OS_QueueGetIdByName(uint32 *queue_id, const char *queue_name) + +int32 +OS_QueueGetIdByName(uint32* queue_id, const char* queue_name) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + uint32 i; + uint32 queue_found = FALSE; + + if (queue_id == NULL || queue_name == NULL) { + return OS_INVALID_POINTER; + } + + if (strlen(queue_name) > OS_MAX_API_NAME) { + return OS_ERR_NAME_TOO_LONG; + } + + for (i = 0 ; i < OS_MAX_QUEUES ; ++i) { + if (strcmp(queue_name, queues[i].name) == 0) { + *queue_id = i; + queue_found = TRUE; + break; + } + } + + if (queue_found == FALSE) { + return OS_ERR_NAME_NOT_FOUND; + } + + return OS_SUCCESS; } -int32 OS_QueueGetInfo(uint32 queue_id, OS_queue_prop_t *queue_prop) +int32 +OS_QueueGetInfo(uint32 queue_id, OS_queue_prop_t* queue_prop) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if (queue_prop == NULL) { + return OS_INVALID_POINTER; + } + + if (queues[queue_id].free == TRUE) { + return OS_ERR_INVALID_ID; + } + + /* TODO: Identify creator; `0` is a dummy value. */ + queue_prop->creator = 0; + + strcpy(queue_prop->name, queues[queue_id].name); + + /* + * NOTE: The OSAL documentation claims that there are two additional fields in `OS_queue_prop_t` called `free` + * and `id`. These members do not appear in our working version. + */ + + return OS_SUCCESS; } From 9a51c1945d50bbfb0d310a88ce67d27906774bf0 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 25 Apr 2017 21:16:09 -0400 Subject: [PATCH 018/122] Add an ugly hack that makes the reset area work --- .../implementation/no_interface/cFE_booter/psp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c index 12a6d56aad..8ca9f2c7b3 100644 --- a/src/components/implementation/no_interface/cFE_booter/psp.c +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -173,10 +173,14 @@ int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumByt ** CFE_PSP_ReadFromCDS reads from the CDS Block */ +#define RESET_AREA_SIZE 4096 +char RESET_AREA[RESET_AREA_SIZE]; + int32 CFE_PSP_GetResetArea (cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + *PtrToResetArea = RESET_AREA; + *SizeOfResetArea = RESET_AREA_SIZE; + return OS_SUCCESS; } /* ** CFE_PSP_GetResetArea returns the location and size of the ES Reset information area. From 7ee5df4a95e653a21440104dc71454afd5bbd618 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 30 May 2017 13:31:54 -0400 Subject: [PATCH 019/122] Add thread API implementations There are known issues, but it should be fine for now --- .../no_interface/cFE_booter/Makefile | 4 +- .../no_interface/cFE_booter/cFE_entrypoint.c | 75 +++-- .../no_interface/cFE_booter/osapi.c | 10 +- .../no_interface/cFE_booter/ostask.c | 163 ++++++++++- .../no_interface/cFE_booter/ostask.h | 6 + .../no_interface/cFE_booter/psp.c | 8 +- .../no_interface/cFE_booter/scheddev/Makefile | 9 + .../cFE_booter/scheddev/README.md | 66 +++++ .../no_interface/cFE_booter/scheddev/sl.c | 255 ++++++++++++++++ .../no_interface/cFE_booter/scheddev/sl.h | 274 ++++++++++++++++++ .../cFE_booter/scheddev/sl_consts.h | 6 + .../cFE_booter/scheddev/sl_mod_fprr.c | 88 ++++++ .../cFE_booter/scheddev/sl_mod_policy.h | 23 ++ .../cFE_booter/scheddev/sl_plugins.h | 51 ++++ .../cFE_booter/scheddev/sl_policy.h | 23 ++ .../no_interface/cFE_booter/scheddev/sl_thd.h | 35 +++ .../scheddev/sl_thd_static_backend.c | 44 +++ .../scheddev/sl_timer_mod_periodic.c | 18 ++ .../cFE_booter/scheddev/unit_schedlib.c | 86 ++++++ .../no_interface/cFE_booter/sl.c | 255 ++++++++++++++++ .../no_interface/cFE_booter/sl.h | 274 ++++++++++++++++++ .../no_interface/cFE_booter/sl_consts.h | 6 + .../no_interface/cFE_booter/sl_mod_fprr.c | 88 ++++++ .../no_interface/cFE_booter/sl_mod_policy.h | 23 ++ .../no_interface/cFE_booter/sl_plugins.h | 51 ++++ .../no_interface/cFE_booter/sl_policy.h | 23 ++ .../no_interface/cFE_booter/sl_thd.h | 35 +++ .../cFE_booter/sl_thd_static_backend.c | 44 +++ .../cFE_booter/sl_timer_mod_periodic.c | 18 ++ 29 files changed, 2002 insertions(+), 59 deletions(-) create mode 100644 src/components/implementation/no_interface/cFE_booter/ostask.h create mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/Makefile create mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/README.md create mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl.c create mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl.h create mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl_consts.h create mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl_mod_fprr.c create mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl_mod_policy.h create mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl_plugins.h create mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl_policy.h create mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl_thd.h create mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl_thd_static_backend.c create mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl_timer_mod_periodic.c create mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/unit_schedlib.c create mode 100644 src/components/implementation/no_interface/cFE_booter/sl.c create mode 100644 src/components/implementation/no_interface/cFE_booter/sl.h create mode 100644 src/components/implementation/no_interface/cFE_booter/sl_consts.h create mode 100644 src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c create mode 100644 src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h create mode 100644 src/components/implementation/no_interface/cFE_booter/sl_plugins.h create mode 100644 src/components/implementation/no_interface/cFE_booter/sl_policy.h create mode 100644 src/components/implementation/no_interface/cFE_booter/sl_thd.h create mode 100644 src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c create mode 100644 src/components/implementation/no_interface/cFE_booter/sl_timer_mod_periodic.c diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index 0ff2dd892e..9a642fa2d6 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -1,10 +1,10 @@ -C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o +# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c ASM_OBJS= COMPONENT=cFE_booter.o INTERFACES= DEPENDENCIES= IF_LIB=./composite_cFE.o -ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api +ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api -lcos_defkernel_api include ../../Makefile.subsubdir CFLAGS += -I./gen diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c index 2c9d2cc84b..97598aa082 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c @@ -1,6 +1,8 @@ #include #include "cFE_util.h" +#include "ostask.h" + #include "gen/cfe_psp.h" #include "gen/common_types.h" #include "gen/osapi.h" @@ -32,9 +34,6 @@ void CFE_PSP_ModuleInit(void) { } -// If RUN_TESTING_CODE is defined, testing code will be run -// #define RUN_TESTING_CODE - // "Magic" constants #define CFE_PSP_CPU_NAME_LENGTH 32 #define CFE_PSP_RESET_NAME_LENGTH 10 @@ -62,33 +61,13 @@ void command_line_set_defaults(struct CFE_PSP_CommandData_t* args) { args->SpacecraftId = CFE_SPACECRAFT_ID; } -void cos_init(void) { - struct CFE_PSP_CommandData_t args; - - command_line_set_defaults(&args); - - /* - ** Set the reset type - */ - uint32 reset_type; - if (strncmp("PR", args.ResetType, 2 ) == 0) - { - reset_type = CFE_PSP_RST_TYPE_PROCESSOR; - OS_printf("CFE_PSP: Starting the cFE with a PROCESSOR reset.\n"); - } - else - { - reset_type = CFE_PSP_RST_TYPE_POWERON; - OS_printf("CFE_PSP: Starting the cFE with a POWER ON reset.\n"); - } - - OS_printf("CFE_PSP: Initializing the OS API...\n"); - /* - ** Initialize the OS API - */ - OS_API_Init(); - OS_printf("CFE_PSP: The the OS API was successfully initialized!\n"); +// This must be global so that cos_init_delegate can read it +// TODO: Consider passing cos_init_delegate this data instead +uint32 reset_type; +struct CFE_PSP_CommandData_t args; +// This is the delegate function called by the scheduler +void cos_init_delegate(void* data) { OS_printf("CFE_PSP: Doing PSP setup...\n"); /* ** Initialize the statically linked modules (if any) @@ -106,14 +85,6 @@ void cos_init(void) { OS_printf("CFE_PSP: PSP setup successful!\n"); - - #ifdef RUN_TESTING_CODE - // Testing code goes here - OS_printf("CFE_PSP: Running testing code...\n"); - - OS_printf("CFE_PSP: Running testing code completed\n"); - #else - OS_printf("CFE_PSP: Starting the cFE proper...\n"); /* ** Call cFE entry point. @@ -121,6 +92,7 @@ void cos_init(void) { CFE_ES_MAIN_FUNCTION(reset_type, args.SubType, 1, CFE_ES_NONVOL_STARTUP_FILE); OS_printf("CFE_PSP: cFE started, main thread sleeping\n"); + /* ** Let the main thread sleep. ** @@ -128,7 +100,34 @@ void cos_init(void) { ** someone calls OS_ApplicationShutdown(TRUE) */ OS_IdleLoop(); - #endif PANIC("Application was shutdown!"); } + +void cos_init(void) { + command_line_set_defaults(&args); + + /* + ** Set the reset type + */ + if (strncmp("PR", args.ResetType, 2 ) == 0) + { + reset_type = CFE_PSP_RST_TYPE_PROCESSOR; + OS_printf("CFE_PSP: Starting the cFE with a PROCESSOR reset.\n"); + } + else + { + reset_type = CFE_PSP_RST_TYPE_POWERON; + OS_printf("CFE_PSP: Starting the cFE with a POWER ON reset.\n"); + } + + /* + ** Initialize the OS API + */ + OS_printf("CFE_PSP: Initializing the OS API...\n"); + OS_API_Init(); + OS_printf("CFE_PSP: The the OS API was successfully initialized!\n"); + + OS_printf("CFE_PSP: Delegating to scheduler setup... \n"); + OS_SchedulerStart(&cos_init_delegate); +} diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index cec9a08dbd..35f28b875e 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -3,12 +3,20 @@ #include "gen/osapi.h" #include "gen/common_types.h" +#include +#include + + /* ** Initialization of API */ int32 OS_API_Init(void) { - // It's safe for this method to do nothing for now + struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); + struct cos_compinfo *ci = cos_compinfo_get(defci); + + cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); + cos_defcompinfo_init(); } /* diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 3ea911c0fb..f9075b59b2 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -1,12 +1,53 @@ #include "cFE_util.h" +#include "ostask.h" #include "gen/osapi.h" #include "gen/common_types.h" +#include "sl.h" + +#include + +// TODO: sl_policy thread +struct os_task { + int non_empty; + thdid_t thdid; + char name[OS_MAX_API_NAME]; +}; +struct os_task tasks[OS_MAX_TASKS]; + +/* +** Internal Task helper functions +*/ +void OS_SchedulerStart(cos_thd_fn_t main_delegate) { + sl_init(); + + struct sl_thd* main_delegate_thread = sl_thd_alloc(main_delegate, NULL); + union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = 1}}; + sl_thd_param_set(main_delegate_thread, sp.v); + + + sl_sched_loop(); +} + +void osal_task_entry_wrapper(void* task_entry) { + ((osal_task_entry) task_entry)(); +} + +int is_valid_name(const char* name) { + int i; + for(i = 0; i < OS_MAX_API_NAME; i++) { + if(name[i] == '\0') { + return TRUE; + } + } + return FALSE; +} /* ** Task API */ +// FIXME: Put all these within a critical section... int32 OS_TaskCreate(uint32 *task_id, const char *task_name, osal_task_entry function_pointer, @@ -14,19 +55,89 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, uint32 stack_size, uint32 priority, uint32 flags) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if(task_name == NULL || stack_pointer == NULL){ + return OS_INVALID_POINTER; + } + + // Validate the name + if(!is_valid_name(task_name)) { + return OS_ERR_NAME_TOO_LONG; + } + + if(priority > 255 || priority < 1) { + return OS_ERR_INVALID_PRIORITY; + } + + int i; + int selected_task_id = -1; + for(i = 0; i < OS_MAX_TASKS; i++) { + if(tasks[i].non_empty) { + if(strcmp(tasks[i].name, task_name) == 0) { + return OS_ERR_NAME_TAKEN; + } + }else if(selected_task_id == -1){ + selected_task_id = i; + } + } + if(selected_task_id == -1) { + return OS_ERR_NO_FREE_IDS; + } + + + struct sl_thd* thd = sl_thd_alloc(osal_task_entry_wrapper, function_pointer); + union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = priority}}; + sl_thd_param_set(thd, sp.v); + + + tasks[selected_task_id] = (struct os_task) { + .non_empty = TRUE, + .thdid = thd->thdid + }; + strcpy(tasks[selected_task_id].name, task_name); + + *task_id = selected_task_id; + + return OS_SUCCESS; } int32 OS_TaskDelete(uint32 task_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! + if(task_id > OS_MAX_TASKS || !tasks[task_id].non_empty) { + return OS_ERR_INVALID_ID; + } + + int delete_id = tasks[task_id].thdid; + tasks[task_id].non_empty = FALSE; + + struct sl_thd* thd = sl_thd_lkup(delete_id); + if(!thd) { + return OS_ERROR; + } + sl_thd_free(thd); + + return OS_SUCCESS; +} + +uint32 OS_TaskGetId(void) +{ + struct sl_thd* thd = sl_thd_curr(); + thdid_t t = thd->thdid; + int i; + for(i = 0; i < OS_MAX_TASKS; i++) { + if(tasks[i].thdid == t) { + return i; + } + } + + PANIC("Broken invariant, should be unreacheable!"); return 0; } void OS_TaskExit(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + OS_TaskDelete(OS_TaskGetId()); + // TODO: Figure out if this is the right thing to do in case of failure + PANIC("Broken invariant, should be unreacheable!"); } int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer){ @@ -36,32 +147,54 @@ int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer){ int32 OS_TaskDelay(uint32 millisecond) { + // TODO: Use Phanis extension + // Meanwhile: Busy loop yielding PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if(task_id > OS_MAX_TASKS || !tasks[task_id].non_empty) { + return OS_ERR_INVALID_ID; + } + + if(new_priority < 1 || new_priority > 255) { + return OS_ERR_INVALID_PRIORITY; + } + + union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = new_priority}}; + sl_thd_param_set(sl_thd_lkup(tasks[task_id].thdid), sp.v); + + return OS_SUCCESS; } int32 OS_TaskRegister(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + // Think it is safe for this to do nothing + return OS_SUCCESS; } -uint32 OS_TaskGetId(void) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} int32 OS_TaskGetIdByName(uint32 *task_id, const char *task_name) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if(!task_name) { + return OS_INVALID_POINTER; + } + + if(!is_valid_name(task_name)) { + return OS_ERR_NAME_TOO_LONG; + } + + int i; + for(i = 0; i < OS_MAX_TASKS; i++) { + if(tasks[i].non_empty && strcmp(tasks[i].name, task_name) == 0) { + *task_id = i; + return OS_SUCCESS; + } + } + + return OS_ERR_NAME_NOT_FOUND; } int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.h b/src/components/implementation/no_interface/cFE_booter/ostask.h new file mode 100644 index 0000000000..c0d057c769 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/ostask.h @@ -0,0 +1,6 @@ +#ifndef OSTASK_H +#define OSTASK_H + +void OS_SchedulerStart(cos_thd_fn_t main_delegate); + +#endif diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c index 8ca9f2c7b3..a75270b08a 100644 --- a/src/components/implementation/no_interface/cFE_booter/psp.c +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -1,3 +1,5 @@ +#include + #include "cFE_util.h" #include "gen/cfe_psp.h" @@ -173,7 +175,7 @@ int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumByt ** CFE_PSP_ReadFromCDS reads from the CDS Block */ -#define RESET_AREA_SIZE 4096 +#define RESET_AREA_SIZE 132000 char RESET_AREA[RESET_AREA_SIZE]; int32 CFE_PSP_GetResetArea (cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) @@ -415,8 +417,8 @@ int32 CFE_PSP_MemCpy(void *dest, void *src, uint32 n) int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + memset(dest, value, n); + return OS_SUCCESS; } int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType) diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/Makefile b/src/components/implementation/no_interface/cFE_booter/scheddev/Makefile new file mode 100644 index 0000000000..07e0a81b11 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/scheddev/Makefile @@ -0,0 +1,9 @@ +#C_OBJS=unit_schedlib.o +COMPONENT=unit_sl.o +INTERFACES= +DEPENDENCIES= +IF_LIB= +ADDITIONAL_LIBS=-lcos_defkernel_api -lcos_kernel_api + +include ../../Makefile.subsubdir +MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/README.md b/src/components/implementation/no_interface/cFE_booter/scheddev/README.md new file mode 100644 index 0000000000..22d7366c71 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/scheddev/README.md @@ -0,0 +1,66 @@ +# What + +The is the *Speck* version of the scheduler library. +It encodes some default behaviors (i.e. fixed capability offsets for rcv, tcap, initial thread), and handles most of the esoteric synchronization required by the interaction between user and kernel. +It has a plugin infrastructure with three main parts: + +- *Scheduling policy* - encoded in `sl_mod_.c` and `sl_mod_policy.h`. + There will be a separate version of this per scheduling policy (each in a subdirectory as in the current `src/components/implementation/sched/fprr/` organization). +- *Allocation policy* - how the actual thread data-structure is allocated and referenced. + This is encoded in `sl_thd__backend.c`. +- *Timer policy* - The policy for when timer interrupts are set to fire. + This is encoded in `sl_timer_mod_.c`. + +# How + +The API for each of these plugins is encoded in `sl_plugins.h`. +Though I'll try not to change this greatly, it likely will. +Of course the intention is that this is a stable API which can support a great many implementations behind it. +At the very least, it was designed with the following in mind: + +- FPRR, EDF +- `ps`-based dynamic allocation and reclamation +- Oneshot and periodic timers +- Extensions to multicore + +## Client API + +The client API is relatively simple, and is populated with the `sl_*` functions. +The main (`cos_init`) thread should enter the event loop after initialization as such: + +``` +cos_meminfo_init(&cos_defcompinfo_curr_get()->mi, BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); +cos_defcompinfo_init(); + +sl_init() +... +sl_sched_loop(); +``` + +Other threads can be created using `sl_thd_alloc(fn, data)` within the same component, or using the `cos_defkernel_api` and `sl_thd_comp_alloc(target_comp)` to create execution in another component. +Threads will *not* be executed until their parameters are set; at least their priority, via `sl_thd_param_set`. + +Once executing, threads can `sl_block(...)`, and `sl_wakeup(target_thd)` another blocked thread. +They can also leverage `sl_cs_enter` and `sl_cs_exit_schedule` for a critical section on this core to protect data-strutures. +Do note that most of the `sl_*` API does take the critical section itself, and recursive critical sections are not allowed. + +The entire timing API is in the unit of finest granularity provided by the hardware (`cycles_t`). +There are conversion functions between that unit and microseconds (`sl_usec2cyc` and `sl_cyc2usec`). +We don't hide the internal, fine-grained unit to avoid costly translation between the units when that can be avoided. + +# FIXME + +- The current timing seems to be way off, but it is hard to tell if that is just qemu or not. +- `sl_thd_prio` needs integration with `param_set`. +- Needs more thorough testing + +# TODO + +- More policies in all dimensions +- Either add a queue of timers, or a facility for a separate thread/component to maintain that queue +- tcap modification facilities such as binding threads to specific tcaps +- tcap timeout handlers to suspend those threads (via policy) +- `aep` endpoints: asynchronous rcv + tcap + thread tuples with asynchronous activations; most of this should already work, but we need an API for this +- schedule not just threads, but also aep endpoints to enable hierarchical scheduling, and in doing so, integrate with APIs for tcap transfer (i.e. period-based?, larger?) +- a separate API to virtually "disable interrupts" might be necessary to support the likes of the rump kernel +- idle processing should be wrapped into the `sl_sched_loop` processing, so that when idle, `rcv` can be called, thus switching to a parent scheduler. `rcv`ing on the root rcv end-point should likely idle the processor, which could get complicated. In the mean time, returning immediately would help. To make this work, 1. the sched loop needs to disambiguate between different types of activations, and 2. the `cos_sched_rcv` should have a flag to allow it to be called in blocking (idle) or non-blocking (scheduler event retrieval) modes. diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl.c b/src/components/implementation/no_interface/cFE_booter/scheddev/sl.c new file mode 100644 index 0000000000..5c0b6c16cb --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/scheddev/sl.c @@ -0,0 +1,255 @@ +/** + * Redistribution of this file is permitted under the BSD two clause license. + * + * Copyright 2017, The George Washington University + * Author: Gabriel Parmer, gparmer@gwu.edu + */ + +#include +#include +#include +#include +#include + +struct sl_global sl_global_data; + +/* + * These functions are removed from the inlined fast-paths of the + * critical section (cs) code to save on code size/locality + */ +void +sl_cs_enter_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, thdcap_t curr, sched_tok_t tok) +{ + struct sl_thd *t = sl_thd_curr(); + struct sl_global *g = sl__globals(); + + /* recursive locks are not allowed */ + assert(csi->s.owner != t->thdcap); + if (!csi->s.contention) { + csi->s.contention = 1; + if (!ps_cas(&g->lock.u.v, cached->v, csi->v)) return; + } + /* Switch to the owner of the critical section, with inheritance using our tcap/priority */ + cos_defswitch(csi->s.owner, t->prio, g->timer_next, tok); + /* if we have an outdated token, then we want to use the same repeat loop, so return to that */ +} + +/* Return 1 if we need a retry, 0 otherwise */ +int +sl_cs_exit_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, sched_tok_t tok) +{ + struct sl_thd *t = sl_thd_curr(); + struct sl_global *g = sl__globals(); + + if (!ps_cas(&g->lock.u.v, cached->v, 0)) return 1; + /* let the scheduler thread decide which thread to run next, inheriting our budget/priority */ + cos_defswitch(g->sched_thdcap, t->prio, g->timer_next, tok); + + return 0; +} + +void +sl_thd_block(thdid_t tid) +{ + struct sl_thd *t; + + /* TODO: dependencies not yet supported */ + assert(!tid); + + sl_cs_enter(); + t = sl_thd_curr(); + if (unlikely(t->state == SL_THD_WOKEN)) { + t->state = SL_THD_RUNNABLE; + sl_cs_exit(); + return; + } + + assert(t->state == SL_THD_RUNNABLE); + t->state = SL_THD_BLOCKED; + sl_mod_block(sl_mod_thd_policy_get(t)); + sl_cs_exit_schedule(); + + return; +} + +void +sl_thd_wakeup(thdid_t tid) +{ + struct sl_thd *t; + thdcap_t thdcap; + tcap_t tcap; + tcap_prio_t prio; + + sl_cs_enter(); + t = sl_thd_lkup(tid); + if (unlikely(!t)) goto done; + + if (unlikely(t->state == SL_THD_RUNNABLE)) { + t->state = SL_THD_WOKEN; + goto done; + } + + assert(t->state = SL_THD_BLOCKED); + t->state = SL_THD_RUNNABLE; + sl_mod_wakeup(sl_mod_thd_policy_get(t)); + sl_cs_exit_schedule(); + + return; +done: + sl_cs_exit(); + return; +} + +void +sl_thd_yield(thdid_t tid) +{ + struct sl_thd *t = sl_thd_curr(); + + /* directed yields not yet supported! */ + assert(!tid); + + sl_cs_enter(); + sl_mod_yield(sl_mod_thd_policy_get(t), NULL); + sl_cs_exit_schedule(); + + return; +} + +static struct sl_thd * +sl_thd_alloc_init(thdid_t tid, thdcap_t thdcap) +{ + struct sl_thd_policy *tp = NULL; + struct sl_thd *t = NULL; + + tp = sl_thd_alloc_backend(tid); + if (!tp) goto done; + t = sl_mod_thd_get(tp); + + t->thdid = tid; + t->thdcap = thdcap; + t->state = SL_THD_RUNNABLE; + sl_thd_index_add_backend(sl_mod_thd_policy_get(t)); + +done: + return t; +} + +/* boot_thd = 1 if you want to create a boot-up thread in a separate component */ +static struct sl_thd * +sl_thd_alloc_intern(cos_thd_fn_t fn, void *data, struct cos_defcompinfo *comp, int boot_thd) +{ + struct cos_defcompinfo *dci = cos_defcompinfo_curr_get(); + struct cos_compinfo *ci = &dci->ci; + struct sl_thd *t = NULL; + thdcap_t thdcap; + thdid_t tid; + + if (!boot_thd) thdcap = cos_thd_alloc(ci, ci->comp_cap, fn, data); + else thdcap = cos_initthd_alloc(ci, comp->ci.comp_cap); + if (!thdcap) goto done; + + tid = cos_introspect(ci, thdcap, THD_GET_TID); + assert(tid); + t = sl_thd_alloc_init(tid, thdcap); + sl_mod_thd_create(sl_mod_thd_policy_get(t)); +done: + return t; +} + +struct sl_thd * +sl_thd_alloc(cos_thd_fn_t fn, void *data) +{ return sl_thd_alloc_intern(fn, data, NULL, 0); } + +/* Allocate a thread that executes in the specified component */ +struct sl_thd * +sl_thd_comp_alloc(struct cos_defcompinfo *comp) +{ return sl_thd_alloc_intern(NULL, NULL, comp, 1); } + +void +sl_thd_free(struct sl_thd *t) +{ + sl_thd_index_rem_backend(sl_mod_thd_policy_get(t)); + t->state = SL_THD_FREE; + /* TODO: add logic for the graveyard to delay this deallocation if t == current */ + sl_thd_free_backend(sl_mod_thd_policy_get(t)); +} + +void +sl_thd_param_set(struct sl_thd *t, sched_param_t sp) +{ + sched_param_type_t type; + unsigned int value; + + sched_param_get(sp, &type, &value); + sl_mod_thd_param_set(sl_mod_thd_policy_get(t), type, value); +} + +void +sl_timeout_period(microsec_t period) +{ + cycles_t p = sl_usec2cyc(period); + + sl__globals()->period = p; + sl_timeout_relative(p); +} + +/* engage space heater mode */ +void +sl_idle(void *d) +{ while (1) ; } + +void +sl_init(void) +{ + struct sl_global *g = sl__globals(); + struct cos_defcompinfo *ci = cos_defcompinfo_curr_get(); + + /* must fit in a word */ + assert(sizeof(struct sl_cs) <= sizeof(unsigned long)); + + g->cyc_per_usec = cos_hw_cycles_per_usec(BOOT_CAPTBL_SELF_INITHW_BASE); + g->lock.u.v = 0; + + sl_thd_init_backend(); + sl_mod_init(); + sl_timeout_mod_init(); + + /* Create the scheduler thread for us */ + g->sched_thd = sl_thd_alloc_init(cos_thdid(), BOOT_CAPTBL_SELF_INITTHD_BASE); + assert(g->sched_thd); + g->sched_thdcap = BOOT_CAPTBL_SELF_INITTHD_BASE; + + g->idle_thd = sl_thd_alloc(sl_idle, NULL); + assert(g->idle_thd); + + return; +} + +void +sl_sched_loop(void) +{ + thdid_t tid; + int blocked; + cycles_t cycles; + + while (1) { + struct sl_thd *t; + sched_tok_t tok; + + sl_cs_enter(); + + while (cos_sched_rcv(BOOT_CAPTBL_SELF_INITRCV_BASE, &tid, &blocked, &cycles)) { + struct sl_thd *t = sl_thd_lkup(tid); + + assert(t); + /* don't report the idle thread */ + if (unlikely(t == sl__globals()->idle_thd)) continue; + sl_mod_execution(sl_mod_thd_policy_get(t), cycles); + if (blocked) sl_mod_block(sl_mod_thd_policy_get(t)); + else sl_mod_wakeup(sl_mod_thd_policy_get(t)); + } + + /* If switch returns an inconsistency, we retry anyway */ + sl_cs_exit_schedule_nospin(); + } +} diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl.h b/src/components/implementation/no_interface/cFE_booter/scheddev/sl.h new file mode 100644 index 0000000000..243883915e --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/scheddev/sl.h @@ -0,0 +1,274 @@ +/** + * Redistribution of this file is permitted under the BSD two clause license. + * + * Copyright 2017, The George Washington University + * Author: Gabriel Parmer, gparmer@gwu.edu + */ + +/* + * Scheduler library (sl) abstractions and functions. + * + * This library does a few things: + * 1. hide the esoteric nature of the cos_kernel_api's dispatch + * methods, and the scheduler event notifications + scheduler + * thread, + * 2. provide synchronization around scheduler data-strutures, and + * 3. abstract shared details about thread blocking/wakeup, lookup, + * and inter-thread dependency management. + * + * This library interacts with a number of other libraries/modules. + * + * - uses: dispatching functions in the cos_kernel_api (which uses, + * the kernel system call layer) + * - uses: parsec (ps) for atomic instructions and synchronization + * - uses: memory allocation functions provided by a run-time (either + * management of static memory, or something like parsec) + * - uses: scheduler modules that implement the scheduling policy + * + */ + +#ifndef SL_H +#define SL_H + +#include +#include +#include +#include +#include + +/* Critical section (cs) API to protect scheduler data-structures */ +struct sl_cs { + union sl_cs_intern { + struct { + thdcap_t owner :31; + u32_t contention :1; + } PS_PACKED s; + unsigned long v; + } u; +}; + +struct sl_global { + struct sl_cs lock; + + thdcap_t sched_thdcap; + struct sl_thd *sched_thd; + struct sl_thd *idle_thd; + + int cyc_per_usec; + cycles_t period; + cycles_t timer_next; +}; + +extern struct sl_global sl_global_data; + +static inline struct sl_global * +sl__globals(void) +{ return &sl_global_data; } + +/* FIXME: integrate with param_set */ +static inline void +sl_thd_setprio(struct sl_thd *t, tcap_prio_t p) +{ t->prio = p; } + +static inline struct sl_thd * +sl_thd_lkup(thdid_t tid) +{ return sl_mod_thd_get(sl_thd_lookup_backend(tid)); } + +static inline struct sl_thd * +sl_thd_curr(void) +{ return sl_thd_lkup(cos_thdid()); } + +/* are we the owner of the critical section? */ +static inline int +sl_cs_owner(void) +{ return sl__globals()->lock.u.s.owner == sl_thd_curr()->thdcap; } + +/* ...not part of the public API */ +void sl_cs_enter_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, thdcap_t curr, sched_tok_t tok); +int sl_cs_exit_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, sched_tok_t tok); + +/* Enter into the scheduler critical section */ +static inline void +sl_cs_enter(void) +{ + union sl_cs_intern csi, cached; + struct sl_thd *t = sl_thd_curr(); + sched_tok_t tok; + + assert(t); +retry: + tok = cos_sched_sync(); + csi.v = sl__globals()->lock.u.v; + cached.v = csi.v; + + if (unlikely(csi.s.owner)) { + sl_cs_enter_contention(&csi, &cached, t->thdcap, tok); + goto retry; + } + + csi.s.owner = t->thdcap; + if (!ps_cas(&sl__globals()->lock.u.v, cached.v, csi.v)) goto retry; + + return; +} + +/* + * Release the scheduler critical section, switch to the scheduler + * thread if there is pending contention + */ +static inline void +sl_cs_exit(void) +{ + union sl_cs_intern csi, cached; + sched_tok_t tok; + +retry: + tok = cos_sched_sync(); + csi.v = sl__globals()->lock.u.v; + cached.v = csi.v; + + if (unlikely(csi.s.contention)) { + if (sl_cs_exit_contention(&csi, &cached, tok)) goto retry; + return; + } + + if (!ps_cas(&sl__globals()->lock.u.v, cached.v, 0)) goto retry; +} + +static inline cycles_t +sl_now(void) +{ return ps_tsc(); } + +/* + * Do a few things: 1. take the critical section if it isn't already + * taken, 2. call schedule to find the next thread to run, 3. release + * the critical section (note this will cause visual asymmetries in + * your code if you call sl_cs_enter before this function), and + * 4. switch to the given thread. It hides some races, and details + * that would make this difficult to write repetitively. + * + * Preconditions: if synchronization is required with code before + * calling this, you must call sl_cs_enter before-hand (this is likely + * a typical case). + * + * Return: the return value from cos_switch. The caller must handle + * this value correctly. + * + * A common use-case is: + * + * sl_cs_enter(); + * scheduling_stuff() + * sl_cs_exit_schedule(); + * + * ...which correctly handles any race-conditions on thread selection and + * dispatch. + */ +static inline int +sl_cs_exit_schedule_nospin(void) +{ + struct sl_thd_policy *pt; + struct sl_thd *t; + struct sl_global *globals = sl__globals(); + thdcap_t thdcap; + tcap_prio_t prio; + sched_tok_t tok; + cycles_t now; + s64_t offset; + + if (unlikely(!sl_cs_owner())) sl_cs_enter(); + + tok = cos_sched_sync(); + now = sl_now(); + offset = (s64_t)(globals->timer_next - now); + if (globals->timer_next && offset <= 0) sl_timeout_mod_expended(now, globals->timer_next); + + /* + * Once we exit, we can't trust t's memory as it could be + * deallocated/modified, so cache it locally. If these values + * are out of date, the scheduler synchronization tok will + * catch it. This is a little twitchy and subtle, so lets put + * it in a function, here. + */ + pt = sl_mod_schedule(); + if (unlikely(!pt)) t = sl__globals()->idle_thd; + else t = sl_mod_thd_get(pt); + thdcap = t->thdcap; + prio = t->prio; + + sl_cs_exit(); + + /* TODO: enable per-thread tcaps for interrupt threads */ + return cos_defswitch(thdcap, prio, sl__globals()->timer_next, tok); +} + +static inline void +sl_cs_exit_schedule(void) +{ while (sl_cs_exit_schedule_nospin()) ; } + +/* + * if tid == 0, just block the current thread; otherwise, create a + * dependency from this thread on the target tid (i.e. when the + * scheduler chooses to run this thread, we will run the dependency + * instead (note that "dependency" is transitive). + */ +void sl_thd_block(thdid_t tid); +/* wakeup a thread that has (or soon will) block */ +void sl_thd_wakeup(thdid_t tid); +void sl_thd_yield(thdid_t tid); + +/* The entire thread allocation and free API */ +struct sl_thd *sl_thd_alloc(cos_thd_fn_t fn, void *data); +struct sl_thd *sl_thd_comp_alloc(struct cos_defcompinfo *comp); +void sl_thd_free(struct sl_thd *t); + +/* + * Time and timeout API. + * + * This can be used by the scheduler policy module *and* by the + * surrounding component code. To avoid race conditions between + * reading the time, and setting a timeout, we avoid relative time + * measurements. sl_now gives the current cycle count that is on an + * absolute timeline. The periodic function sets a period that can be + * used when a timeout has happened, the relative function sets a + * timeout relative to now, and the oneshot timeout sets a timeout on + * the same absolute timeline as returned by sl_now. + */ +void sl_timeout_period(cycles_t period); + +static inline cycles_t +sl_timeout_period_get(void) +{ return sl__globals()->period; } + +static inline void +sl_timeout_oneshot(cycles_t absolute_us) +{ sl__globals()->timer_next = absolute_us; } + +static inline void +sl_timeout_relative(cycles_t offset) +{ sl_timeout_oneshot(sl_now() + offset); } + +static inline microsec_t +sl_cyc2usec(cycles_t cyc) +{ return cyc / sl__globals()->cyc_per_usec; } + +static inline microsec_t +sl_usec2cyc(microsec_t usec) +{ return usec * sl__globals()->cyc_per_usec; } + +void sl_thd_param_set(struct sl_thd *t, sched_param_t sp); + +/* + * Initialization protocol in cos_init: initialization of + * library-internal data-structures, and then the ability for the + * scheduler thread to start its scheduling loop. + * + * sl_init(); + * sl_*; <- use the sl_api here + * ... + * sl_sched_loop(); <- loop here + */ +void sl_init(void); +void sl_sched_loop(void); + + +#endif /* SL_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_consts.h b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_consts.h new file mode 100644 index 0000000000..bdcda220cc --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_consts.h @@ -0,0 +1,6 @@ +#ifndef SL_CONSTS +#define SL_CONSTS + +#define SL_PERIOD_US 100 + +#endif /* SL_CONSTS */ diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_mod_fprr.c b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_mod_fprr.c new file mode 100644 index 0000000000..ad056d4121 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_mod_fprr.c @@ -0,0 +1,88 @@ +#include +#include +#include +#include + +#define SL_FPRR_NPRIOS 32 +#define SL_FPRR_HIGHEST 0 +#define SL_FPRR_LOWEST (SL_FPRR_NPRIOS-1) + +struct ps_list_head threads[SL_FPRR_NPRIOS]; + +/* No RR yet */ +void +sl_mod_execution(struct sl_thd_policy *t, cycles_t cycles) +{ } + +struct sl_thd_policy * +sl_mod_schedule(void) +{ + int i; + struct sl_thd_policy *t; + + for (i = 0 ; i < SL_FPRR_NPRIOS ; i++) { + if (ps_list_head_empty(&threads[i])) continue; + t = ps_list_head_first_d(&threads[i], struct sl_thd_policy); + + return t; + } + assert(0); + + return NULL; +} + +void +sl_mod_block(struct sl_thd_policy *t) +{ + ps_list_rem_d(t); +} + +void +sl_mod_wakeup(struct sl_thd_policy *t) +{ + assert(t->priority <= SL_FPRR_LOWEST && ps_list_singleton_d(t)); + + ps_list_head_append_d(&threads[t->priority], t); +} + +void +sl_mod_yield(struct sl_thd_policy *t, struct sl_thd_policy *yield_to) +{ + assert(t->priority <= SL_FPRR_LOWEST); + + ps_list_rem_d(t); + ps_list_head_append_d(&threads[t->priority], t); +} + +void +sl_mod_thd_create(struct sl_thd_policy *t) +{ + t->priority = SL_FPRR_LOWEST; + t->period = 0; + t->period_usec = 0; + ps_list_init_d(t); +} + +void +sl_mod_thd_delete(struct sl_thd_policy *t) +{ ps_list_rem_d(t); } + +void +sl_mod_thd_param_set(struct sl_thd_policy *t, sched_param_type_t type, unsigned int v) +{ + assert(type == SCHEDP_PRIO && v < SL_FPRR_NPRIOS); + ps_list_rem_d(t); /* if we're already on a list, and we're updating priority */ + t->priority = v; + ps_list_head_append_d(&threads[t->priority], t); +} + +void +sl_mod_init(void) +{ + int i; + struct sl_thd *t; + + for (i = 0 ; i < SL_FPRR_NPRIOS ; i++) { + ps_list_head_init(&threads[i]); + } +} diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_mod_policy.h b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_mod_policy.h new file mode 100644 index 0000000000..351eb9e4de --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_mod_policy.h @@ -0,0 +1,23 @@ +#ifndef SL_POLICY_H +#define SL_POLICY_H + +#include +#include + +struct sl_thd_policy { + struct sl_thd thd; + tcap_prio_t priority; + microsec_t period_usec; + cycles_t period; + struct ps_list list; +}; + +static inline struct sl_thd * +sl_mod_thd_get(struct sl_thd_policy *tp) +{ return &tp->thd; } + +static inline struct sl_thd_policy * +sl_mod_thd_policy_get(struct sl_thd *t) +{ return ps_container(t, struct sl_thd_policy, thd); } + +#endif /* SL_POLICY_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_plugins.h b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_plugins.h new file mode 100644 index 0000000000..ad719101b6 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_plugins.h @@ -0,0 +1,51 @@ +#ifndef SL_PLUGINS_H +#define SL_PLUGINS_H + +#include +#include + +/* + * The build system has to add in the appropriate backends for the + * system. We rely on the linker to hook up all of these function + * call instead of function pointers so that we can statically analyze + * stack consumption and execution paths (e.g. for WCET) which are + * prohibited by function pointers. Additionally, significant work + * (by Daniel Lohmann's group) has shown that a statically configured + * system is more naturally fault resilient. A minor benefit is the + * performance of not using function pointers, but that is secondary. + */ +struct sl_thd_policy *sl_thd_alloc_backend(thdid_t tid); +void sl_thd_free_backend(struct sl_thd_policy *t); + +void sl_thd_index_add_backend(struct sl_thd_policy *); +void sl_thd_index_rem_backend(struct sl_thd_policy *); +struct sl_thd_policy *sl_thd_lookup_backend(thdid_t); +void sl_thd_init_backend(void); + +/* + * Each scheduler policy must implement the following API. See above + * for why this is not a function-pointer-based API. + * + * Scheduler modules (policies) should define the following + */ +struct sl_thd_policy; +static inline struct sl_thd *sl_mod_thd_get(struct sl_thd_policy *tp); +static inline struct sl_thd_policy *sl_mod_thd_policy_get(struct sl_thd *t); + +void sl_mod_execution(struct sl_thd_policy *t, cycles_t cycles); +struct sl_thd_policy *sl_mod_schedule(void); + +void sl_mod_block(struct sl_thd_policy *t); +void sl_mod_wakeup(struct sl_thd_policy *t); +void sl_mod_yield(struct sl_thd_policy *t, struct sl_thd_policy *tp); + +void sl_mod_thd_create(struct sl_thd_policy *t); +void sl_mod_thd_delete(struct sl_thd_policy *t); +void sl_mod_thd_param_set(struct sl_thd_policy *t, sched_param_type_t type, unsigned int val); +void sl_mod_init(void); + +/* API for handling timer management */ +void sl_timeout_mod_expended(cycles_t now, cycles_t oldtimeout); +void sl_timeout_mod_init(void); + +#endif /* SL_PLUGINS_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_policy.h b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_policy.h new file mode 100644 index 0000000000..351eb9e4de --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_policy.h @@ -0,0 +1,23 @@ +#ifndef SL_POLICY_H +#define SL_POLICY_H + +#include +#include + +struct sl_thd_policy { + struct sl_thd thd; + tcap_prio_t priority; + microsec_t period_usec; + cycles_t period; + struct ps_list list; +}; + +static inline struct sl_thd * +sl_mod_thd_get(struct sl_thd_policy *tp) +{ return &tp->thd; } + +static inline struct sl_thd_policy * +sl_mod_thd_policy_get(struct sl_thd *t) +{ return ps_container(t, struct sl_thd_policy, thd); } + +#endif /* SL_POLICY_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_thd.h b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_thd.h new file mode 100644 index 0000000000..3d98fe31da --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_thd.h @@ -0,0 +1,35 @@ +/** + * Redistribution of this file is permitted under the BSD two clause license. + * + * Copyright 2017, The George Washington University + * Author: Gabriel Parmer, gparmer@gwu.edu + */ + +#ifndef SL_THD_H +#define SL_THD_H + +typedef enum { + SL_THD_FREE = 0, + SL_THD_BLOCKED, + SL_THD_WOKEN, /* if a race causes a wakeup before the inevitable block */ + SL_THD_RUNNABLE, + SL_THD_DYING, +} sl_thd_state; + +struct sl_thd { + sl_thd_state state; + thdid_t thdid; + thdcap_t thdcap; + tcap_prio_t prio; + struct sl_thd *dependency; +}; + +#ifndef assert +#define assert(node) do { if (unlikely(!(node))) { debug_print("assert error in @ "); *((int *)0) = 0; } } while (0) +#define PRINT_FN prints +#define debug_print(str) (PRINT_FN(str __FILE__ ":" STR(__LINE__) ".\n")) +#define BUG() do { debug_print("BUG @ "); *((int *)0) = 0; } while (0); +#define SPIN() do { while (1) ; } while (0) +#endif + +#endif /* SL_THD_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_thd_static_backend.c b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_thd_static_backend.c new file mode 100644 index 0000000000..953dd1441f --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_thd_static_backend.c @@ -0,0 +1,44 @@ +/** + * Redistribution of this file is permitted under the BSD two clause license. + * + * Copyright 2017, The George Washington University + * Author: Gabriel Parmer, gparmer@gwu.edu + */ + +#include +#include +#include +#include + +static struct sl_thd_policy sl_threads[MAX_NUM_THREADS]; + +/* Default implementations of backend functions */ +struct sl_thd_policy * +sl_thd_alloc_backend(thdid_t tid) +{ + assert(tid < MAX_NUM_THREADS); + return &sl_threads[tid]; +} + +void +sl_thd_free_backend(struct sl_thd_policy *t) +{ } + +void +sl_thd_index_add_backend(struct sl_thd_policy *t) +{ } + +void +sl_thd_index_rem_backend(struct sl_thd_policy *t) +{ } + +struct sl_thd_policy * +sl_thd_lookup_backend(thdid_t tid) +{ + assert(tid < MAX_NUM_THREADS); + return &sl_threads[tid]; +} + +void +sl_thd_init_backend(void) +{ } diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_timer_mod_periodic.c b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_timer_mod_periodic.c new file mode 100644 index 0000000000..21133b46f4 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_timer_mod_periodic.c @@ -0,0 +1,18 @@ +#include +#include +#include + +void +sl_timeout_mod_expended(microsec_t now, microsec_t oldtimeout) +{ + assert(now >= oldtimeout); + + /* in virtual environments, or with very small periods, we might miss more than one period */ + sl_timeout_oneshot(now + (now-oldtimeout) % sl_timeout_period_get()); +} + +void +sl_timeout_mod_init(void) +{ + sl_timeout_period(SL_PERIOD_US); +} diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/unit_schedlib.c b/src/components/implementation/no_interface/cFE_booter/scheddev/unit_schedlib.c new file mode 100644 index 0000000000..5d76698d2d --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/scheddev/unit_schedlib.c @@ -0,0 +1,86 @@ +/* + * Copyright 2016, Phani Gadepalli and Gabriel Parmer, GWU, gparmer@gwu.edu. + * + * This uses a two clause BSD License. + */ + +#include +#include +#include +#include +#include + +#include + +#undef assert +#define assert(node) do { if (unlikely(!(node))) { debug_print("assert error in @ "); *((int *)0) = 0; } } while (0) +#define PRINT_FN prints +#define debug_print(str) (PRINT_FN(str __FILE__ ":" STR(__LINE__) ".\n")) +#define BUG() do { debug_print("BUG @ "); *((int *)0) = 0; } while (0); +#define SPIN() do { while (1) ; } while (0) + +static void +cos_llprint(char *s, int len) +{ call_cap(PRINT_CAP_TEMP, (int)s, len, 0, 0); } + +int +prints(char *s) +{ + int len = strlen(s); + + cos_llprint(s, len); + + return len; +} + +int __attribute__((format(printf,1,2))) +printc(char *fmt, ...) +{ + char s[128]; + va_list arg_ptr; + int ret, len = 128; + + va_start(arg_ptr, fmt); + ret = vsnprintf(s, len, fmt, arg_ptr); + va_end(arg_ptr); + cos_llprint(s, ret); + + return ret; +} + +#define N_TESTTHDS 8 + +void +test_thd_fn(void *data) +{ + while (1) { + sl_thd_yield(0); + } +} + +void +cos_init(void) +{ + int i; + struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); + struct cos_compinfo *ci = cos_compinfo_get(defci); + struct sl_thd *threads[N_TESTTHDS]; + union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = 10}}; + + printc("Unit-test for the scheduling library (sl)\n"); + cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); + cos_defcompinfo_init(); + sl_init(); + + for (i = 0 ; i < N_TESTTHDS ; i++) { + threads[i] = sl_thd_alloc(test_thd_fn, NULL); + assert(threads[i]); + sl_thd_param_set(threads[i], sp.v); + } + + sl_sched_loop(); + + assert(0); + + return; +} diff --git a/src/components/implementation/no_interface/cFE_booter/sl.c b/src/components/implementation/no_interface/cFE_booter/sl.c new file mode 100644 index 0000000000..5c0b6c16cb --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl.c @@ -0,0 +1,255 @@ +/** + * Redistribution of this file is permitted under the BSD two clause license. + * + * Copyright 2017, The George Washington University + * Author: Gabriel Parmer, gparmer@gwu.edu + */ + +#include +#include +#include +#include +#include + +struct sl_global sl_global_data; + +/* + * These functions are removed from the inlined fast-paths of the + * critical section (cs) code to save on code size/locality + */ +void +sl_cs_enter_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, thdcap_t curr, sched_tok_t tok) +{ + struct sl_thd *t = sl_thd_curr(); + struct sl_global *g = sl__globals(); + + /* recursive locks are not allowed */ + assert(csi->s.owner != t->thdcap); + if (!csi->s.contention) { + csi->s.contention = 1; + if (!ps_cas(&g->lock.u.v, cached->v, csi->v)) return; + } + /* Switch to the owner of the critical section, with inheritance using our tcap/priority */ + cos_defswitch(csi->s.owner, t->prio, g->timer_next, tok); + /* if we have an outdated token, then we want to use the same repeat loop, so return to that */ +} + +/* Return 1 if we need a retry, 0 otherwise */ +int +sl_cs_exit_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, sched_tok_t tok) +{ + struct sl_thd *t = sl_thd_curr(); + struct sl_global *g = sl__globals(); + + if (!ps_cas(&g->lock.u.v, cached->v, 0)) return 1; + /* let the scheduler thread decide which thread to run next, inheriting our budget/priority */ + cos_defswitch(g->sched_thdcap, t->prio, g->timer_next, tok); + + return 0; +} + +void +sl_thd_block(thdid_t tid) +{ + struct sl_thd *t; + + /* TODO: dependencies not yet supported */ + assert(!tid); + + sl_cs_enter(); + t = sl_thd_curr(); + if (unlikely(t->state == SL_THD_WOKEN)) { + t->state = SL_THD_RUNNABLE; + sl_cs_exit(); + return; + } + + assert(t->state == SL_THD_RUNNABLE); + t->state = SL_THD_BLOCKED; + sl_mod_block(sl_mod_thd_policy_get(t)); + sl_cs_exit_schedule(); + + return; +} + +void +sl_thd_wakeup(thdid_t tid) +{ + struct sl_thd *t; + thdcap_t thdcap; + tcap_t tcap; + tcap_prio_t prio; + + sl_cs_enter(); + t = sl_thd_lkup(tid); + if (unlikely(!t)) goto done; + + if (unlikely(t->state == SL_THD_RUNNABLE)) { + t->state = SL_THD_WOKEN; + goto done; + } + + assert(t->state = SL_THD_BLOCKED); + t->state = SL_THD_RUNNABLE; + sl_mod_wakeup(sl_mod_thd_policy_get(t)); + sl_cs_exit_schedule(); + + return; +done: + sl_cs_exit(); + return; +} + +void +sl_thd_yield(thdid_t tid) +{ + struct sl_thd *t = sl_thd_curr(); + + /* directed yields not yet supported! */ + assert(!tid); + + sl_cs_enter(); + sl_mod_yield(sl_mod_thd_policy_get(t), NULL); + sl_cs_exit_schedule(); + + return; +} + +static struct sl_thd * +sl_thd_alloc_init(thdid_t tid, thdcap_t thdcap) +{ + struct sl_thd_policy *tp = NULL; + struct sl_thd *t = NULL; + + tp = sl_thd_alloc_backend(tid); + if (!tp) goto done; + t = sl_mod_thd_get(tp); + + t->thdid = tid; + t->thdcap = thdcap; + t->state = SL_THD_RUNNABLE; + sl_thd_index_add_backend(sl_mod_thd_policy_get(t)); + +done: + return t; +} + +/* boot_thd = 1 if you want to create a boot-up thread in a separate component */ +static struct sl_thd * +sl_thd_alloc_intern(cos_thd_fn_t fn, void *data, struct cos_defcompinfo *comp, int boot_thd) +{ + struct cos_defcompinfo *dci = cos_defcompinfo_curr_get(); + struct cos_compinfo *ci = &dci->ci; + struct sl_thd *t = NULL; + thdcap_t thdcap; + thdid_t tid; + + if (!boot_thd) thdcap = cos_thd_alloc(ci, ci->comp_cap, fn, data); + else thdcap = cos_initthd_alloc(ci, comp->ci.comp_cap); + if (!thdcap) goto done; + + tid = cos_introspect(ci, thdcap, THD_GET_TID); + assert(tid); + t = sl_thd_alloc_init(tid, thdcap); + sl_mod_thd_create(sl_mod_thd_policy_get(t)); +done: + return t; +} + +struct sl_thd * +sl_thd_alloc(cos_thd_fn_t fn, void *data) +{ return sl_thd_alloc_intern(fn, data, NULL, 0); } + +/* Allocate a thread that executes in the specified component */ +struct sl_thd * +sl_thd_comp_alloc(struct cos_defcompinfo *comp) +{ return sl_thd_alloc_intern(NULL, NULL, comp, 1); } + +void +sl_thd_free(struct sl_thd *t) +{ + sl_thd_index_rem_backend(sl_mod_thd_policy_get(t)); + t->state = SL_THD_FREE; + /* TODO: add logic for the graveyard to delay this deallocation if t == current */ + sl_thd_free_backend(sl_mod_thd_policy_get(t)); +} + +void +sl_thd_param_set(struct sl_thd *t, sched_param_t sp) +{ + sched_param_type_t type; + unsigned int value; + + sched_param_get(sp, &type, &value); + sl_mod_thd_param_set(sl_mod_thd_policy_get(t), type, value); +} + +void +sl_timeout_period(microsec_t period) +{ + cycles_t p = sl_usec2cyc(period); + + sl__globals()->period = p; + sl_timeout_relative(p); +} + +/* engage space heater mode */ +void +sl_idle(void *d) +{ while (1) ; } + +void +sl_init(void) +{ + struct sl_global *g = sl__globals(); + struct cos_defcompinfo *ci = cos_defcompinfo_curr_get(); + + /* must fit in a word */ + assert(sizeof(struct sl_cs) <= sizeof(unsigned long)); + + g->cyc_per_usec = cos_hw_cycles_per_usec(BOOT_CAPTBL_SELF_INITHW_BASE); + g->lock.u.v = 0; + + sl_thd_init_backend(); + sl_mod_init(); + sl_timeout_mod_init(); + + /* Create the scheduler thread for us */ + g->sched_thd = sl_thd_alloc_init(cos_thdid(), BOOT_CAPTBL_SELF_INITTHD_BASE); + assert(g->sched_thd); + g->sched_thdcap = BOOT_CAPTBL_SELF_INITTHD_BASE; + + g->idle_thd = sl_thd_alloc(sl_idle, NULL); + assert(g->idle_thd); + + return; +} + +void +sl_sched_loop(void) +{ + thdid_t tid; + int blocked; + cycles_t cycles; + + while (1) { + struct sl_thd *t; + sched_tok_t tok; + + sl_cs_enter(); + + while (cos_sched_rcv(BOOT_CAPTBL_SELF_INITRCV_BASE, &tid, &blocked, &cycles)) { + struct sl_thd *t = sl_thd_lkup(tid); + + assert(t); + /* don't report the idle thread */ + if (unlikely(t == sl__globals()->idle_thd)) continue; + sl_mod_execution(sl_mod_thd_policy_get(t), cycles); + if (blocked) sl_mod_block(sl_mod_thd_policy_get(t)); + else sl_mod_wakeup(sl_mod_thd_policy_get(t)); + } + + /* If switch returns an inconsistency, we retry anyway */ + sl_cs_exit_schedule_nospin(); + } +} diff --git a/src/components/implementation/no_interface/cFE_booter/sl.h b/src/components/implementation/no_interface/cFE_booter/sl.h new file mode 100644 index 0000000000..243883915e --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl.h @@ -0,0 +1,274 @@ +/** + * Redistribution of this file is permitted under the BSD two clause license. + * + * Copyright 2017, The George Washington University + * Author: Gabriel Parmer, gparmer@gwu.edu + */ + +/* + * Scheduler library (sl) abstractions and functions. + * + * This library does a few things: + * 1. hide the esoteric nature of the cos_kernel_api's dispatch + * methods, and the scheduler event notifications + scheduler + * thread, + * 2. provide synchronization around scheduler data-strutures, and + * 3. abstract shared details about thread blocking/wakeup, lookup, + * and inter-thread dependency management. + * + * This library interacts with a number of other libraries/modules. + * + * - uses: dispatching functions in the cos_kernel_api (which uses, + * the kernel system call layer) + * - uses: parsec (ps) for atomic instructions and synchronization + * - uses: memory allocation functions provided by a run-time (either + * management of static memory, or something like parsec) + * - uses: scheduler modules that implement the scheduling policy + * + */ + +#ifndef SL_H +#define SL_H + +#include +#include +#include +#include +#include + +/* Critical section (cs) API to protect scheduler data-structures */ +struct sl_cs { + union sl_cs_intern { + struct { + thdcap_t owner :31; + u32_t contention :1; + } PS_PACKED s; + unsigned long v; + } u; +}; + +struct sl_global { + struct sl_cs lock; + + thdcap_t sched_thdcap; + struct sl_thd *sched_thd; + struct sl_thd *idle_thd; + + int cyc_per_usec; + cycles_t period; + cycles_t timer_next; +}; + +extern struct sl_global sl_global_data; + +static inline struct sl_global * +sl__globals(void) +{ return &sl_global_data; } + +/* FIXME: integrate with param_set */ +static inline void +sl_thd_setprio(struct sl_thd *t, tcap_prio_t p) +{ t->prio = p; } + +static inline struct sl_thd * +sl_thd_lkup(thdid_t tid) +{ return sl_mod_thd_get(sl_thd_lookup_backend(tid)); } + +static inline struct sl_thd * +sl_thd_curr(void) +{ return sl_thd_lkup(cos_thdid()); } + +/* are we the owner of the critical section? */ +static inline int +sl_cs_owner(void) +{ return sl__globals()->lock.u.s.owner == sl_thd_curr()->thdcap; } + +/* ...not part of the public API */ +void sl_cs_enter_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, thdcap_t curr, sched_tok_t tok); +int sl_cs_exit_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, sched_tok_t tok); + +/* Enter into the scheduler critical section */ +static inline void +sl_cs_enter(void) +{ + union sl_cs_intern csi, cached; + struct sl_thd *t = sl_thd_curr(); + sched_tok_t tok; + + assert(t); +retry: + tok = cos_sched_sync(); + csi.v = sl__globals()->lock.u.v; + cached.v = csi.v; + + if (unlikely(csi.s.owner)) { + sl_cs_enter_contention(&csi, &cached, t->thdcap, tok); + goto retry; + } + + csi.s.owner = t->thdcap; + if (!ps_cas(&sl__globals()->lock.u.v, cached.v, csi.v)) goto retry; + + return; +} + +/* + * Release the scheduler critical section, switch to the scheduler + * thread if there is pending contention + */ +static inline void +sl_cs_exit(void) +{ + union sl_cs_intern csi, cached; + sched_tok_t tok; + +retry: + tok = cos_sched_sync(); + csi.v = sl__globals()->lock.u.v; + cached.v = csi.v; + + if (unlikely(csi.s.contention)) { + if (sl_cs_exit_contention(&csi, &cached, tok)) goto retry; + return; + } + + if (!ps_cas(&sl__globals()->lock.u.v, cached.v, 0)) goto retry; +} + +static inline cycles_t +sl_now(void) +{ return ps_tsc(); } + +/* + * Do a few things: 1. take the critical section if it isn't already + * taken, 2. call schedule to find the next thread to run, 3. release + * the critical section (note this will cause visual asymmetries in + * your code if you call sl_cs_enter before this function), and + * 4. switch to the given thread. It hides some races, and details + * that would make this difficult to write repetitively. + * + * Preconditions: if synchronization is required with code before + * calling this, you must call sl_cs_enter before-hand (this is likely + * a typical case). + * + * Return: the return value from cos_switch. The caller must handle + * this value correctly. + * + * A common use-case is: + * + * sl_cs_enter(); + * scheduling_stuff() + * sl_cs_exit_schedule(); + * + * ...which correctly handles any race-conditions on thread selection and + * dispatch. + */ +static inline int +sl_cs_exit_schedule_nospin(void) +{ + struct sl_thd_policy *pt; + struct sl_thd *t; + struct sl_global *globals = sl__globals(); + thdcap_t thdcap; + tcap_prio_t prio; + sched_tok_t tok; + cycles_t now; + s64_t offset; + + if (unlikely(!sl_cs_owner())) sl_cs_enter(); + + tok = cos_sched_sync(); + now = sl_now(); + offset = (s64_t)(globals->timer_next - now); + if (globals->timer_next && offset <= 0) sl_timeout_mod_expended(now, globals->timer_next); + + /* + * Once we exit, we can't trust t's memory as it could be + * deallocated/modified, so cache it locally. If these values + * are out of date, the scheduler synchronization tok will + * catch it. This is a little twitchy and subtle, so lets put + * it in a function, here. + */ + pt = sl_mod_schedule(); + if (unlikely(!pt)) t = sl__globals()->idle_thd; + else t = sl_mod_thd_get(pt); + thdcap = t->thdcap; + prio = t->prio; + + sl_cs_exit(); + + /* TODO: enable per-thread tcaps for interrupt threads */ + return cos_defswitch(thdcap, prio, sl__globals()->timer_next, tok); +} + +static inline void +sl_cs_exit_schedule(void) +{ while (sl_cs_exit_schedule_nospin()) ; } + +/* + * if tid == 0, just block the current thread; otherwise, create a + * dependency from this thread on the target tid (i.e. when the + * scheduler chooses to run this thread, we will run the dependency + * instead (note that "dependency" is transitive). + */ +void sl_thd_block(thdid_t tid); +/* wakeup a thread that has (or soon will) block */ +void sl_thd_wakeup(thdid_t tid); +void sl_thd_yield(thdid_t tid); + +/* The entire thread allocation and free API */ +struct sl_thd *sl_thd_alloc(cos_thd_fn_t fn, void *data); +struct sl_thd *sl_thd_comp_alloc(struct cos_defcompinfo *comp); +void sl_thd_free(struct sl_thd *t); + +/* + * Time and timeout API. + * + * This can be used by the scheduler policy module *and* by the + * surrounding component code. To avoid race conditions between + * reading the time, and setting a timeout, we avoid relative time + * measurements. sl_now gives the current cycle count that is on an + * absolute timeline. The periodic function sets a period that can be + * used when a timeout has happened, the relative function sets a + * timeout relative to now, and the oneshot timeout sets a timeout on + * the same absolute timeline as returned by sl_now. + */ +void sl_timeout_period(cycles_t period); + +static inline cycles_t +sl_timeout_period_get(void) +{ return sl__globals()->period; } + +static inline void +sl_timeout_oneshot(cycles_t absolute_us) +{ sl__globals()->timer_next = absolute_us; } + +static inline void +sl_timeout_relative(cycles_t offset) +{ sl_timeout_oneshot(sl_now() + offset); } + +static inline microsec_t +sl_cyc2usec(cycles_t cyc) +{ return cyc / sl__globals()->cyc_per_usec; } + +static inline microsec_t +sl_usec2cyc(microsec_t usec) +{ return usec * sl__globals()->cyc_per_usec; } + +void sl_thd_param_set(struct sl_thd *t, sched_param_t sp); + +/* + * Initialization protocol in cos_init: initialization of + * library-internal data-structures, and then the ability for the + * scheduler thread to start its scheduling loop. + * + * sl_init(); + * sl_*; <- use the sl_api here + * ... + * sl_sched_loop(); <- loop here + */ +void sl_init(void); +void sl_sched_loop(void); + + +#endif /* SL_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_consts.h b/src/components/implementation/no_interface/cFE_booter/sl_consts.h new file mode 100644 index 0000000000..bdcda220cc --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl_consts.h @@ -0,0 +1,6 @@ +#ifndef SL_CONSTS +#define SL_CONSTS + +#define SL_PERIOD_US 100 + +#endif /* SL_CONSTS */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c new file mode 100644 index 0000000000..ad056d4121 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c @@ -0,0 +1,88 @@ +#include +#include +#include +#include + +#define SL_FPRR_NPRIOS 32 +#define SL_FPRR_HIGHEST 0 +#define SL_FPRR_LOWEST (SL_FPRR_NPRIOS-1) + +struct ps_list_head threads[SL_FPRR_NPRIOS]; + +/* No RR yet */ +void +sl_mod_execution(struct sl_thd_policy *t, cycles_t cycles) +{ } + +struct sl_thd_policy * +sl_mod_schedule(void) +{ + int i; + struct sl_thd_policy *t; + + for (i = 0 ; i < SL_FPRR_NPRIOS ; i++) { + if (ps_list_head_empty(&threads[i])) continue; + t = ps_list_head_first_d(&threads[i], struct sl_thd_policy); + + return t; + } + assert(0); + + return NULL; +} + +void +sl_mod_block(struct sl_thd_policy *t) +{ + ps_list_rem_d(t); +} + +void +sl_mod_wakeup(struct sl_thd_policy *t) +{ + assert(t->priority <= SL_FPRR_LOWEST && ps_list_singleton_d(t)); + + ps_list_head_append_d(&threads[t->priority], t); +} + +void +sl_mod_yield(struct sl_thd_policy *t, struct sl_thd_policy *yield_to) +{ + assert(t->priority <= SL_FPRR_LOWEST); + + ps_list_rem_d(t); + ps_list_head_append_d(&threads[t->priority], t); +} + +void +sl_mod_thd_create(struct sl_thd_policy *t) +{ + t->priority = SL_FPRR_LOWEST; + t->period = 0; + t->period_usec = 0; + ps_list_init_d(t); +} + +void +sl_mod_thd_delete(struct sl_thd_policy *t) +{ ps_list_rem_d(t); } + +void +sl_mod_thd_param_set(struct sl_thd_policy *t, sched_param_type_t type, unsigned int v) +{ + assert(type == SCHEDP_PRIO && v < SL_FPRR_NPRIOS); + ps_list_rem_d(t); /* if we're already on a list, and we're updating priority */ + t->priority = v; + ps_list_head_append_d(&threads[t->priority], t); +} + +void +sl_mod_init(void) +{ + int i; + struct sl_thd *t; + + for (i = 0 ; i < SL_FPRR_NPRIOS ; i++) { + ps_list_head_init(&threads[i]); + } +} diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h b/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h new file mode 100644 index 0000000000..351eb9e4de --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h @@ -0,0 +1,23 @@ +#ifndef SL_POLICY_H +#define SL_POLICY_H + +#include +#include + +struct sl_thd_policy { + struct sl_thd thd; + tcap_prio_t priority; + microsec_t period_usec; + cycles_t period; + struct ps_list list; +}; + +static inline struct sl_thd * +sl_mod_thd_get(struct sl_thd_policy *tp) +{ return &tp->thd; } + +static inline struct sl_thd_policy * +sl_mod_thd_policy_get(struct sl_thd *t) +{ return ps_container(t, struct sl_thd_policy, thd); } + +#endif /* SL_POLICY_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_plugins.h b/src/components/implementation/no_interface/cFE_booter/sl_plugins.h new file mode 100644 index 0000000000..ad719101b6 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl_plugins.h @@ -0,0 +1,51 @@ +#ifndef SL_PLUGINS_H +#define SL_PLUGINS_H + +#include +#include + +/* + * The build system has to add in the appropriate backends for the + * system. We rely on the linker to hook up all of these function + * call instead of function pointers so that we can statically analyze + * stack consumption and execution paths (e.g. for WCET) which are + * prohibited by function pointers. Additionally, significant work + * (by Daniel Lohmann's group) has shown that a statically configured + * system is more naturally fault resilient. A minor benefit is the + * performance of not using function pointers, but that is secondary. + */ +struct sl_thd_policy *sl_thd_alloc_backend(thdid_t tid); +void sl_thd_free_backend(struct sl_thd_policy *t); + +void sl_thd_index_add_backend(struct sl_thd_policy *); +void sl_thd_index_rem_backend(struct sl_thd_policy *); +struct sl_thd_policy *sl_thd_lookup_backend(thdid_t); +void sl_thd_init_backend(void); + +/* + * Each scheduler policy must implement the following API. See above + * for why this is not a function-pointer-based API. + * + * Scheduler modules (policies) should define the following + */ +struct sl_thd_policy; +static inline struct sl_thd *sl_mod_thd_get(struct sl_thd_policy *tp); +static inline struct sl_thd_policy *sl_mod_thd_policy_get(struct sl_thd *t); + +void sl_mod_execution(struct sl_thd_policy *t, cycles_t cycles); +struct sl_thd_policy *sl_mod_schedule(void); + +void sl_mod_block(struct sl_thd_policy *t); +void sl_mod_wakeup(struct sl_thd_policy *t); +void sl_mod_yield(struct sl_thd_policy *t, struct sl_thd_policy *tp); + +void sl_mod_thd_create(struct sl_thd_policy *t); +void sl_mod_thd_delete(struct sl_thd_policy *t); +void sl_mod_thd_param_set(struct sl_thd_policy *t, sched_param_type_t type, unsigned int val); +void sl_mod_init(void); + +/* API for handling timer management */ +void sl_timeout_mod_expended(cycles_t now, cycles_t oldtimeout); +void sl_timeout_mod_init(void); + +#endif /* SL_PLUGINS_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_policy.h b/src/components/implementation/no_interface/cFE_booter/sl_policy.h new file mode 100644 index 0000000000..351eb9e4de --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl_policy.h @@ -0,0 +1,23 @@ +#ifndef SL_POLICY_H +#define SL_POLICY_H + +#include +#include + +struct sl_thd_policy { + struct sl_thd thd; + tcap_prio_t priority; + microsec_t period_usec; + cycles_t period; + struct ps_list list; +}; + +static inline struct sl_thd * +sl_mod_thd_get(struct sl_thd_policy *tp) +{ return &tp->thd; } + +static inline struct sl_thd_policy * +sl_mod_thd_policy_get(struct sl_thd *t) +{ return ps_container(t, struct sl_thd_policy, thd); } + +#endif /* SL_POLICY_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_thd.h b/src/components/implementation/no_interface/cFE_booter/sl_thd.h new file mode 100644 index 0000000000..3d98fe31da --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl_thd.h @@ -0,0 +1,35 @@ +/** + * Redistribution of this file is permitted under the BSD two clause license. + * + * Copyright 2017, The George Washington University + * Author: Gabriel Parmer, gparmer@gwu.edu + */ + +#ifndef SL_THD_H +#define SL_THD_H + +typedef enum { + SL_THD_FREE = 0, + SL_THD_BLOCKED, + SL_THD_WOKEN, /* if a race causes a wakeup before the inevitable block */ + SL_THD_RUNNABLE, + SL_THD_DYING, +} sl_thd_state; + +struct sl_thd { + sl_thd_state state; + thdid_t thdid; + thdcap_t thdcap; + tcap_prio_t prio; + struct sl_thd *dependency; +}; + +#ifndef assert +#define assert(node) do { if (unlikely(!(node))) { debug_print("assert error in @ "); *((int *)0) = 0; } } while (0) +#define PRINT_FN prints +#define debug_print(str) (PRINT_FN(str __FILE__ ":" STR(__LINE__) ".\n")) +#define BUG() do { debug_print("BUG @ "); *((int *)0) = 0; } while (0); +#define SPIN() do { while (1) ; } while (0) +#endif + +#endif /* SL_THD_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c b/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c new file mode 100644 index 0000000000..953dd1441f --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c @@ -0,0 +1,44 @@ +/** + * Redistribution of this file is permitted under the BSD two clause license. + * + * Copyright 2017, The George Washington University + * Author: Gabriel Parmer, gparmer@gwu.edu + */ + +#include +#include +#include +#include + +static struct sl_thd_policy sl_threads[MAX_NUM_THREADS]; + +/* Default implementations of backend functions */ +struct sl_thd_policy * +sl_thd_alloc_backend(thdid_t tid) +{ + assert(tid < MAX_NUM_THREADS); + return &sl_threads[tid]; +} + +void +sl_thd_free_backend(struct sl_thd_policy *t) +{ } + +void +sl_thd_index_add_backend(struct sl_thd_policy *t) +{ } + +void +sl_thd_index_rem_backend(struct sl_thd_policy *t) +{ } + +struct sl_thd_policy * +sl_thd_lookup_backend(thdid_t tid) +{ + assert(tid < MAX_NUM_THREADS); + return &sl_threads[tid]; +} + +void +sl_thd_init_backend(void) +{ } diff --git a/src/components/implementation/no_interface/cFE_booter/sl_timer_mod_periodic.c b/src/components/implementation/no_interface/cFE_booter/sl_timer_mod_periodic.c new file mode 100644 index 0000000000..21133b46f4 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl_timer_mod_periodic.c @@ -0,0 +1,18 @@ +#include +#include +#include + +void +sl_timeout_mod_expended(microsec_t now, microsec_t oldtimeout) +{ + assert(now >= oldtimeout); + + /* in virtual environments, or with very small periods, we might miss more than one period */ + sl_timeout_oneshot(now + (now-oldtimeout) % sl_timeout_period_get()); +} + +void +sl_timeout_mod_init(void) +{ + sl_timeout_period(SL_PERIOD_US); +} From b43d2ef1ea01a2364a41b79f75862ec1062ce5af Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 30 May 2017 13:58:15 -0400 Subject: [PATCH 020/122] Implement CFE_PSP_GetTime --- .../implementation/no_interface/cFE_booter/osapi.c | 11 +++++++---- .../implementation/no_interface/cFE_booter/psp.c | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 35f28b875e..2dafb6e8a0 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -1,3 +1,5 @@ +#include + #include "cFE_util.h" #include "gen/osapi.h" @@ -47,17 +49,18 @@ int32 OS_Tick2Micros(void) return 0; } -int32 OS_GetLocalTime(OS_time_t *time_struct) +int32 OS_GetLocalTime(OS_time_t *time_struct) { PANIC("Unimplemented method!"); // TODO: Implement me! return 0; -} -int32 OS_SetLocalTime(OS_time_t *time_struct) +}/* end OS_GetLocalTime */ + +int32 OS_SetLocalTime(OS_time_t *time_struct) { PANIC("Unimplemented method!"); // TODO: Implement me! return 0; -} +} /*end OS_SetLocalTime */ /* ** Exception API diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c index a75270b08a..24486a6892 100644 --- a/src/components/implementation/no_interface/cFE_booter/psp.c +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -2,6 +2,7 @@ #include "cFE_util.h" +#include "gen/osapi.h" #include "gen/cfe_psp.h" /* @@ -25,7 +26,7 @@ void CFE_PSP_Main(uint32 ModeId, char *StartupFilePath) void CFE_PSP_GetTime(OS_time_t *LocalTime) { - PANIC("Unimplemented method!"); // TODO: Implement me! + OS_GetLocalTime(LocalTime); } /* This call gets the local time from the hardware on the Vxworks system * on the mcp750s @@ -96,6 +97,7 @@ uint32 CFE_PSP_GetTimerTicksPerSecond(void) PANIC("Unimplemented method!"); // TODO: Implement me! return 0; } + /* ** CFE_PSP_GetTimerTicksPerSecond provides the resolution of the least significant ** 32 bits of the 64 bit time stamp returned by CFE_PSP_Get_Timebase in timer From 9258b1a16d5b7ebf6b8e591f719e7ad0625048d9 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 30 May 2017 14:36:38 -0400 Subject: [PATCH 021/122] Add hacky implementations of many of the psp methods --- .../no_interface/cFE_booter/osapi.c | 23 ++++++++----- .../no_interface/cFE_booter/psp.c | 33 ++++++++++++++----- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 2dafb6e8a0..9b671e777c 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -3,8 +3,10 @@ #include "cFE_util.h" #include "gen/osapi.h" +#include "gen/cfe_psp.h" #include "gen/common_types.h" + #include #include @@ -39,27 +41,32 @@ void OS_DeleteAllObjects(void) int32 OS_Milli2Ticks(uint32 milli_seconds) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return (int32) (CFE_PSP_GetTimerTicksPerSecond() / 1000) * milli_seconds; } int32 OS_Tick2Micros(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + // TODO: Redo this using integer arithmetic + // seconds/tick = 1 / (tick / seconds) + double seconds_per_tick = 1.0 / CFE_PSP_GetTimerTicksPerSecond(); + // seconds / tick * microseconds / second = microseconds / tick + return (int32) seconds_per_tick * 1000000; } +// TODO: Fix this awful hack +OS_time_t local_time; + int32 OS_GetLocalTime(OS_time_t *time_struct) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + *time_struct = local_time; + return OS_SUCCESS; }/* end OS_GetLocalTime */ int32 OS_SetLocalTime(OS_time_t *time_struct) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + local_time = *time_struct; + return OS_SUCCESS; } /*end OS_SetLocalTime */ /* diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c index 24486a6892..3ed8b86594 100644 --- a/src/components/implementation/no_interface/cFE_booter/psp.c +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -2,6 +2,8 @@ #include "cFE_util.h" +#include "sl.h" + #include "gen/osapi.h" #include "gen/cfe_psp.h" @@ -94,8 +96,8 @@ uint32 CFE_PSP_Get_Timer_Tick(void) uint32 CFE_PSP_GetTimerTicksPerSecond(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + // TODO: Check that cycles and ticks are the same here + return (uint32) sl__globals()->cyc_per_usec * 1000000; } /* @@ -107,8 +109,9 @@ uint32 CFE_PSP_GetTimerTicksPerSecond(void) uint32 CFE_PSP_GetTimerLow32Rollover(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + // This is a pessimistic assumption + // TODO: Figure out if we can be more optimistic + return 1000000; } /* ** CFE_PSP_GetTimerLow32Rollover provides the number that the least significant @@ -202,10 +205,24 @@ int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea ** User reserved area. */ + int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk ) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + int32 return_code; + + if ( SizeOfVolDisk == NULL ) + { + return_code = CFE_PSP_ERROR; + } + else + { + *PtrToVolDisk = 0; + *SizeOfVolDisk = 0; + return_code = CFE_PSP_SUCCESS; + } + + return(return_code); + } /* ** CFE_PSP_GetVolatileDiskMem returns the location and size of the memory used for the cFE @@ -413,8 +430,8 @@ int32 CFE_PSP_MemWrite32(cpuaddr MemoryAddress, uint32 uint32Value) int32 CFE_PSP_MemCpy(void *dest, void *src, uint32 n) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + memcpy(dest, src, n); + return OS_SUCCESS; } int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n) From 6077404e123e3ed052f4262629bb2c3e4c25e978 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Wed, 31 May 2017 15:12:56 -0400 Subject: [PATCH 022/122] Ensure scheduler methods enter the critical section --- .../no_interface/cFE_booter/ostask.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index f9075b59b2..89f6d12a24 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -55,6 +55,8 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, uint32 stack_size, uint32 priority, uint32 flags) { + sl_cs_enter(); + if(task_name == NULL || stack_pointer == NULL){ return OS_INVALID_POINTER; } @@ -97,11 +99,15 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, *task_id = selected_task_id; + sl_cs_exit(); + return OS_SUCCESS; } int32 OS_TaskDelete(uint32 task_id) { + sl_cs_enter(); + if(task_id > OS_MAX_TASKS || !tasks[task_id].non_empty) { return OS_ERR_INVALID_ID; } @@ -115,20 +121,28 @@ int32 OS_TaskDelete(uint32 task_id) } sl_thd_free(thd); + sl_cs_exit(); + return OS_SUCCESS; } uint32 OS_TaskGetId(void) { + sl_cs_enter(); + struct sl_thd* thd = sl_thd_curr(); thdid_t t = thd->thdid; int i; for(i = 0; i < OS_MAX_TASKS; i++) { if(tasks[i].thdid == t) { + sl_cs_exit(); return i; } } + sl_cs_exit(); + + PANIC("Broken invariant, should be unreacheable!"); return 0; } @@ -155,6 +169,8 @@ int32 OS_TaskDelay(uint32 millisecond) int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) { + sl_cs_enter(); + if(task_id > OS_MAX_TASKS || !tasks[task_id].non_empty) { return OS_ERR_INVALID_ID; } @@ -166,6 +182,8 @@ int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = new_priority}}; sl_thd_param_set(sl_thd_lkup(tasks[task_id].thdid), sp.v); + sl_cs_exit(); + return OS_SUCCESS; } @@ -178,6 +196,8 @@ int32 OS_TaskRegister(void) int32 OS_TaskGetIdByName(uint32 *task_id, const char *task_name) { + sl_cs_enter(); + if(!task_name) { return OS_INVALID_POINTER; } @@ -194,6 +214,8 @@ int32 OS_TaskGetIdByName(uint32 *task_id, const char *task_name) } } + sl_cs_exit(); + return OS_ERR_NAME_NOT_FOUND; } From 77bab05e00dcec4bd750fcf6c6f7292522d31681 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Wed, 31 May 2017 16:03:18 -0400 Subject: [PATCH 023/122] Remove unnesessary queue stubs that were ressurected --- .../cFE_booter/Queue/OS_QueueCreate.c | 17 ----------------- .../no_interface/cFE_booter/Queue/QueueDelete.c | 15 --------------- .../no_interface/cFE_booter/Queue/QueueGet.c | 15 --------------- .../cFE_booter/Queue/QueueGetIdByName.c | 15 --------------- .../cFE_booter/Queue/QueueGetInfo.c | 15 --------------- .../no_interface/cFE_booter/Queue/QueuePut.c | 15 --------------- .../no_interface/cFE_booter/Queue/queue_test.c | 15 --------------- 7 files changed, 107 deletions(-) delete mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/OS_QueueCreate.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueueDelete.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueueGet.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueueGetIdByName.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueueGetInfo.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/QueuePut.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/Queue/queue_test.c diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/OS_QueueCreate.c b/src/components/implementation/no_interface/cFE_booter/Queue/OS_QueueCreate.c deleted file mode 100644 index f5e42bef06..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/Queue/OS_QueueCreate.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include -#include -#include - -/** -* Description: (From NASA's OSAL Library API documentation) -* -* This is the function used to create a queue in the operating system. Depending on the -* underlying operating system, the memory for the queue will be allocated automatically or -* allocated by the code that sets up the queue. Queue names must be unique; if the name -* already exists this function fails. Names cannot be NULL. -**/ - -int32 OS_QueueCreate( uint32 *queue_id, const char *queue_name, uint32 queue_depth, uint32 data_size, uint32 flags ){ - -} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueueDelete.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueueDelete.c deleted file mode 100644 index 643ed462d4..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/Queue/QueueDelete.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include -#include - -/** -* Description: (From NASA's OSAL Library API documentation) -* -* This is the function used to delete a queue in the operating system. This also frees the -* respective queue_id to be used again when another queue is created. -**/ - -int32 OS_QueueDelete ( uint32 queue_id ){ - -} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGet.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGet.c deleted file mode 100644 index dc9ee91f1a..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGet.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include -#include - -/** -* Description: (From NASA's OSAL Library API documentation) - -* This function is used to retrieve a data item from an existing queue. The queue can be -* checked, pended on, or pended on with a timeout. -**/ - -int32 OS_QueueGet ( uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout){ - -} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetIdByName.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetIdByName.c deleted file mode 100644 index 0463510507..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetIdByName.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include -#include - -/** -* Description: (From NASA's OSAL Library API documentation) - -* This function takes a queue name and looks for a valid queue with this name and returns -* the id of that queue. -**/ - -int32 OS_QueueGetIdByName (uint32 *queue_id, const char *queue_name){ - -} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetInfo.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetInfo.c deleted file mode 100644 index f2c0d4b1de..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/Queue/QueueGetInfo.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include -#include - -/** -* Description: (From NASA's OSAL Library API documentation) - -* This function takes queue_id, and looks it up in the OS table. It puts all of the -* information known about that queue into a structure pointer to by queue_prop. -**/ - -int32 OS_QueueGetInfo (uint32 queue_id, OS_queue_prop_t *queue_prop){ - -} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/QueuePut.c b/src/components/implementation/no_interface/cFE_booter/Queue/QueuePut.c deleted file mode 100644 index 3993c77e28..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/Queue/QueuePut.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include -#include - -/** -* Description: (From NASA's OSAL Library API documentation) - -* This function is used to send data on an existing queue. The flags can be used to specify -* the behavior of the queue if it is full. -**/ - -int32 OS_QueuePut ( uint32 queue_id, void *data, uint32 size, uint32 flags){ - -} \ No newline at end of file diff --git a/src/components/implementation/no_interface/cFE_booter/Queue/queue_test.c b/src/components/implementation/no_interface/cFE_booter/Queue/queue_test.c deleted file mode 100644 index 0ed1687f16..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/Queue/queue_test.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include -#include - -/** -* Description: -* -* A temporary method used to test the function of queue related methods -**/ - -void queue_test(){ - - prints("queue test works"); -} From a532cec678d72963b757929985dbfd1513965f8e Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Fri, 2 Jun 2017 16:16:47 -0400 Subject: [PATCH 024/122] Fix the broken build --- .gitignore | 1 - .../no_interface/cFE_booter/osapi.c | 12 ++--- .../no_interface/cFE_booter/psp.c | 5 +- .../no_interface/cFE_booter/sl.c | 47 ++++++++++++------- .../no_interface/cFE_booter/sl.h | 41 +++++++++++++--- .../cFE_booter/sl_timer_mod_periodic.c | 5 +- src/platform/i386/runscripts/cFE_booter.sh | 3 +- 7 files changed, 79 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index 4e7bd2b27f..90570b15a1 100755 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,6 @@ composite_new tags src/kernel/include/shared/cpu_ghz.h src/Makefile.cosconfig -src/PLATFORM src/PLATFORM_ID modules.order .depend diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 9b671e777c..7b74ab1a05 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -2,6 +2,8 @@ #include "cFE_util.h" +#include "sl_consts.h" + #include "gen/osapi.h" #include "gen/cfe_psp.h" #include "gen/common_types.h" @@ -21,6 +23,8 @@ int32 OS_API_Init(void) cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); cos_defcompinfo_init(); + + return OS_SUCCESS; } /* @@ -41,16 +45,12 @@ void OS_DeleteAllObjects(void) int32 OS_Milli2Ticks(uint32 milli_seconds) { - return (int32) (CFE_PSP_GetTimerTicksPerSecond() / 1000) * milli_seconds; + return (int32) (CFE_PSP_GetTimerTicksPerSecond() * milli_seconds) / 1000; } int32 OS_Tick2Micros(void) { - // TODO: Redo this using integer arithmetic - // seconds/tick = 1 / (tick / seconds) - double seconds_per_tick = 1.0 / CFE_PSP_GetTimerTicksPerSecond(); - // seconds / tick * microseconds / second = microseconds / tick - return (int32) seconds_per_tick * 1000000; + return SL_PERIOD_US; } // TODO: Fix this awful hack diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c index 3ed8b86594..8662b519d3 100644 --- a/src/components/implementation/no_interface/cFE_booter/psp.c +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -3,6 +3,7 @@ #include "cFE_util.h" #include "sl.h" +#include "sl_consts.h" #include "gen/osapi.h" #include "gen/cfe_psp.h" @@ -96,8 +97,8 @@ uint32 CFE_PSP_Get_Timer_Tick(void) uint32 CFE_PSP_GetTimerTicksPerSecond(void) { - // TODO: Check that cycles and ticks are the same here - return (uint32) sl__globals()->cyc_per_usec * 1000000; + // (usec / sec) / (usec / tick) + return 1000000 / SL_PERIOD_US; } /* diff --git a/src/components/implementation/no_interface/cFE_booter/sl.c b/src/components/implementation/no_interface/cFE_booter/sl.c index 5c0b6c16cb..5ac86e51db 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.c +++ b/src/components/implementation/no_interface/cFE_booter/sl.c @@ -30,7 +30,7 @@ sl_cs_enter_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, thdc if (!ps_cas(&g->lock.u.v, cached->v, csi->v)) return; } /* Switch to the owner of the critical section, with inheritance using our tcap/priority */ - cos_defswitch(csi->s.owner, t->prio, g->timer_next, tok); + cos_defswitch(csi->s.owner, t->prio, g->timeout_next, tok); /* if we have an outdated token, then we want to use the same repeat loop, so return to that */ } @@ -43,7 +43,7 @@ sl_cs_exit_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, sched if (!ps_cas(&g->lock.u.v, cached->v, 0)) return 1; /* let the scheduler thread decide which thread to run next, inheriting our budget/priority */ - cos_defswitch(g->sched_thdcap, t->prio, g->timer_next, tok); + cos_defswitch(g->sched_thdcap, t->prio, g->timeout_next, tok); return 0; } @@ -89,7 +89,7 @@ sl_thd_wakeup(thdid_t tid) goto done; } - assert(t->state = SL_THD_BLOCKED); + assert(t->state == SL_THD_BLOCKED); t->state = SL_THD_RUNNABLE; sl_mod_wakeup(sl_mod_thd_policy_get(t)); sl_cs_exit_schedule(); @@ -105,12 +105,16 @@ sl_thd_yield(thdid_t tid) { struct sl_thd *t = sl_thd_curr(); - /* directed yields not yet supported! */ - assert(!tid); - sl_cs_enter(); - sl_mod_yield(sl_mod_thd_policy_get(t), NULL); - sl_cs_exit_schedule(); + if (tid) { + struct sl_thd *to = sl_thd_lkup(tid); + + assert(to); + sl_cs_exit_switchto(to); + } else { + sl_mod_yield(sl_mod_thd_policy_get(t), NULL); + sl_cs_exit_schedule(); + } return; } @@ -228,26 +232,33 @@ sl_init(void) void sl_sched_loop(void) { - thdid_t tid; - int blocked; - cycles_t cycles; - while (1) { - struct sl_thd *t; - sched_tok_t tok; + int pending; sl_cs_enter(); - while (cos_sched_rcv(BOOT_CAPTBL_SELF_INITRCV_BASE, &tid, &blocked, &cycles)) { - struct sl_thd *t = sl_thd_lkup(tid); - + do { + thdid_t tid; + int blocked; + cycles_t cycles; + struct sl_thd *t; + + /* + * a child scheduler may receive both scheduling notifications (block/unblock + * states of it's child threads) and normal notifications (mainly activations from + * it's parent scheduler). + */ + pending = cos_sched_rcv(BOOT_CAPTBL_SELF_INITRCV_BASE, &tid, &blocked, &cycles); + if (!tid) continue; + + t = sl_thd_lkup(tid); assert(t); /* don't report the idle thread */ if (unlikely(t == sl__globals()->idle_thd)) continue; sl_mod_execution(sl_mod_thd_policy_get(t), cycles); if (blocked) sl_mod_block(sl_mod_thd_policy_get(t)); else sl_mod_wakeup(sl_mod_thd_policy_get(t)); - } + } while (pending); /* If switch returns an inconsistency, we retry anyway */ sl_cs_exit_schedule_nospin(); diff --git a/src/components/implementation/no_interface/cFE_booter/sl.h b/src/components/implementation/no_interface/cFE_booter/sl.h index 243883915e..9beebc6505 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.h +++ b/src/components/implementation/no_interface/cFE_booter/sl.h @@ -57,6 +57,7 @@ struct sl_global { int cyc_per_usec; cycles_t period; cycles_t timer_next; + tcap_time_t timeout_next; }; extern struct sl_global sl_global_data; @@ -164,7 +165,7 @@ sl_now(void) * dispatch. */ static inline int -sl_cs_exit_schedule_nospin(void) +sl_cs_exit_schedule_nospin_arg(struct sl_thd *to) { struct sl_thd_policy *pt; struct sl_thd *t; @@ -175,6 +176,7 @@ sl_cs_exit_schedule_nospin(void) cycles_t now; s64_t offset; + /* Don't abuse this, it is only to enable the tight loop around this function for races... */ if (unlikely(!sl_cs_owner())) sl_cs_enter(); tok = cos_sched_sync(); @@ -189,22 +191,46 @@ sl_cs_exit_schedule_nospin(void) * catch it. This is a little twitchy and subtle, so lets put * it in a function, here. */ - pt = sl_mod_schedule(); - if (unlikely(!pt)) t = sl__globals()->idle_thd; - else t = sl_mod_thd_get(pt); + if (unlikely(to)) { + t = to; + if (t->state != SL_THD_RUNNABLE) to = NULL; + } + if (likely(!to)) { + pt = sl_mod_schedule(); + if (unlikely(!pt)) t = sl__globals()->idle_thd; + else t = sl_mod_thd_get(pt); + } thdcap = t->thdcap; prio = t->prio; sl_cs_exit(); /* TODO: enable per-thread tcaps for interrupt threads */ - return cos_defswitch(thdcap, prio, sl__globals()->timer_next, tok); + return cos_defswitch(thdcap, prio, sl__globals()->timeout_next, tok); } +static inline int +sl_cs_exit_schedule_nospin(void) +{ return sl_cs_exit_schedule_nospin_arg(NULL); } + static inline void sl_cs_exit_schedule(void) { while (sl_cs_exit_schedule_nospin()) ; } +static inline void +sl_cs_exit_switchto(struct sl_thd *to) +{ + /* + * We only try once, so it is possible that we don't end up + * switching to the desired thread. However, this is always a + * case that the caller has to consider if the current thread + * has a higher priority than the "to" thread. + */ + if (sl_cs_exit_schedule_nospin_arg(to)) { + sl_cs_exit_schedule(); + } +} + /* * if tid == 0, just block the current thread; otherwise, create a * dependency from this thread on the target tid (i.e. when the @@ -241,7 +267,10 @@ sl_timeout_period_get(void) static inline void sl_timeout_oneshot(cycles_t absolute_us) -{ sl__globals()->timer_next = absolute_us; } +{ + sl__globals()->timer_next = absolute_us; + sl__globals()->timeout_next = tcap_cyc2time(absolute_us); +} static inline void sl_timeout_relative(cycles_t offset) diff --git a/src/components/implementation/no_interface/cFE_booter/sl_timer_mod_periodic.c b/src/components/implementation/no_interface/cFE_booter/sl_timer_mod_periodic.c index 21133b46f4..b7b815bc91 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_timer_mod_periodic.c +++ b/src/components/implementation/no_interface/cFE_booter/sl_timer_mod_periodic.c @@ -5,10 +5,13 @@ void sl_timeout_mod_expended(microsec_t now, microsec_t oldtimeout) { + cycles_t offset; + assert(now >= oldtimeout); /* in virtual environments, or with very small periods, we might miss more than one period */ - sl_timeout_oneshot(now + (now-oldtimeout) % sl_timeout_period_get()); + offset = (now - oldtimeout) % sl_timeout_period_get(); + sl_timeout_oneshot(now + sl_timeout_period_get() - offset); } void diff --git a/src/platform/i386/runscripts/cFE_booter.sh b/src/platform/i386/runscripts/cFE_booter.sh index 1369b07050..6d6ea8dd9d 100644 --- a/src/platform/i386/runscripts/cFE_booter.sh +++ b/src/platform/i386/runscripts/cFE_booter.sh @@ -1,4 +1,5 @@ #!/bin/sh cp cFE_booter.o llboot.o -./cos_linker "llboot.o, ;llpong.o, :" ./gen_client_stub +./cos_linker "llboot.o, ;test_boot.o, :" ./gen_client_stub + From e9b018304dc80c3e0eae475bd11c0d0ea854a127 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 5 Jun 2017 13:39:08 -0400 Subject: [PATCH 025/122] Fix the osal GetLocalTime/SetLocalTime routines This commit also removes the redundant scheddev directory --- .../no_interface/cFE_booter/osapi.c | 40 ++- .../no_interface/cFE_booter/psp.c | 2 +- .../no_interface/cFE_booter/scheddev/Makefile | 9 - .../cFE_booter/scheddev/README.md | 66 ----- .../no_interface/cFE_booter/scheddev/sl.c | 255 ---------------- .../no_interface/cFE_booter/scheddev/sl.h | 274 ------------------ .../cFE_booter/scheddev/sl_consts.h | 6 - .../cFE_booter/scheddev/sl_mod_fprr.c | 88 ------ .../cFE_booter/scheddev/sl_mod_policy.h | 23 -- .../cFE_booter/scheddev/sl_plugins.h | 51 ---- .../cFE_booter/scheddev/sl_policy.h | 23 -- .../no_interface/cFE_booter/scheddev/sl_thd.h | 35 --- .../scheddev/sl_thd_static_backend.c | 44 --- .../scheddev/sl_timer_mod_periodic.c | 18 -- .../cFE_booter/scheddev/unit_schedlib.c | 86 ------ 15 files changed, 39 insertions(+), 981 deletions(-) delete mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/Makefile delete mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/README.md delete mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl.h delete mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl_consts.h delete mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl_mod_fprr.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl_mod_policy.h delete mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl_plugins.h delete mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl_policy.h delete mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl_thd.h delete mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl_thd_static_backend.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/sl_timer_mod_periodic.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/scheddev/unit_schedlib.c diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 7b74ab1a05..7585b7fc32 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -2,6 +2,7 @@ #include "cFE_util.h" +#include "sl.h" #include "sl_consts.h" #include "gen/osapi.h" @@ -23,7 +24,7 @@ int32 OS_API_Init(void) cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); cos_defcompinfo_init(); - + return OS_SUCCESS; } @@ -53,12 +54,45 @@ int32 OS_Tick2Micros(void) return SL_PERIOD_US; } -// TODO: Fix this awful hack OS_time_t local_time; +cycles_t old_cycle_count; + +OS_time_t OS_AdvanceTime(OS_time_t initial_time, microsec_t usec) { + microsec_t old_seconds = (microsec_t) initial_time.seconds; + microsec_t old_additional_usec = (microsec_t) initial_time.microsecs; + + microsec_t old_usec = old_seconds * (1000 * 1000) + old_additional_usec; + microsec_t new_usec = old_usec + usec; + + microsec_t new_seconds = new_usec / (1000 * 1000); + microsec_t new_additional_usec = new_usec % (1000 * 1000); + + return (OS_time_t) { + .seconds = new_seconds, + .microsecs = new_additional_usec + }; +} int32 OS_GetLocalTime(OS_time_t *time_struct) { + if(old_cycle_count == 0) { + local_time = (OS_time_t) { + .seconds = 1181683060, + .microsecs = 0 + }; + old_cycle_count = sl_now(); + } else { + cycles_t new_cycle_count = sl_now(); + cycles_t elapsed_cycles = new_cycle_count - old_cycle_count; + + microsec_t elapsed_usec = sl_cyc2usec(elapsed_cycles); + + local_time = OS_AdvanceTime(local_time, elapsed_usec); + old_cycle_count = new_cycle_count; + } + *time_struct = local_time; + return OS_SUCCESS; }/* end OS_GetLocalTime */ @@ -66,6 +100,8 @@ int32 OS_GetLocalTime(OS_time_t *time_struct) int32 OS_SetLocalTime(OS_time_t *time_struct) { local_time = *time_struct; + old_cycle_count = sl_now(); + return OS_SUCCESS; } /*end OS_SetLocalTime */ diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c index 8662b519d3..65667eb6a8 100644 --- a/src/components/implementation/no_interface/cFE_booter/psp.c +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -186,7 +186,7 @@ char RESET_AREA[RESET_AREA_SIZE]; int32 CFE_PSP_GetResetArea (cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) { - *PtrToResetArea = RESET_AREA; + *PtrToResetArea = (cpuaddr) RESET_AREA; *SizeOfResetArea = RESET_AREA_SIZE; return OS_SUCCESS; } diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/Makefile b/src/components/implementation/no_interface/cFE_booter/scheddev/Makefile deleted file mode 100644 index 07e0a81b11..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/scheddev/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -#C_OBJS=unit_schedlib.o -COMPONENT=unit_sl.o -INTERFACES= -DEPENDENCIES= -IF_LIB= -ADDITIONAL_LIBS=-lcos_defkernel_api -lcos_kernel_api - -include ../../Makefile.subsubdir -MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/README.md b/src/components/implementation/no_interface/cFE_booter/scheddev/README.md deleted file mode 100644 index 22d7366c71..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/scheddev/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# What - -The is the *Speck* version of the scheduler library. -It encodes some default behaviors (i.e. fixed capability offsets for rcv, tcap, initial thread), and handles most of the esoteric synchronization required by the interaction between user and kernel. -It has a plugin infrastructure with three main parts: - -- *Scheduling policy* - encoded in `sl_mod_.c` and `sl_mod_policy.h`. - There will be a separate version of this per scheduling policy (each in a subdirectory as in the current `src/components/implementation/sched/fprr/` organization). -- *Allocation policy* - how the actual thread data-structure is allocated and referenced. - This is encoded in `sl_thd__backend.c`. -- *Timer policy* - The policy for when timer interrupts are set to fire. - This is encoded in `sl_timer_mod_.c`. - -# How - -The API for each of these plugins is encoded in `sl_plugins.h`. -Though I'll try not to change this greatly, it likely will. -Of course the intention is that this is a stable API which can support a great many implementations behind it. -At the very least, it was designed with the following in mind: - -- FPRR, EDF -- `ps`-based dynamic allocation and reclamation -- Oneshot and periodic timers -- Extensions to multicore - -## Client API - -The client API is relatively simple, and is populated with the `sl_*` functions. -The main (`cos_init`) thread should enter the event loop after initialization as such: - -``` -cos_meminfo_init(&cos_defcompinfo_curr_get()->mi, BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); -cos_defcompinfo_init(); - -sl_init() -... -sl_sched_loop(); -``` - -Other threads can be created using `sl_thd_alloc(fn, data)` within the same component, or using the `cos_defkernel_api` and `sl_thd_comp_alloc(target_comp)` to create execution in another component. -Threads will *not* be executed until their parameters are set; at least their priority, via `sl_thd_param_set`. - -Once executing, threads can `sl_block(...)`, and `sl_wakeup(target_thd)` another blocked thread. -They can also leverage `sl_cs_enter` and `sl_cs_exit_schedule` for a critical section on this core to protect data-strutures. -Do note that most of the `sl_*` API does take the critical section itself, and recursive critical sections are not allowed. - -The entire timing API is in the unit of finest granularity provided by the hardware (`cycles_t`). -There are conversion functions between that unit and microseconds (`sl_usec2cyc` and `sl_cyc2usec`). -We don't hide the internal, fine-grained unit to avoid costly translation between the units when that can be avoided. - -# FIXME - -- The current timing seems to be way off, but it is hard to tell if that is just qemu or not. -- `sl_thd_prio` needs integration with `param_set`. -- Needs more thorough testing - -# TODO - -- More policies in all dimensions -- Either add a queue of timers, or a facility for a separate thread/component to maintain that queue -- tcap modification facilities such as binding threads to specific tcaps -- tcap timeout handlers to suspend those threads (via policy) -- `aep` endpoints: asynchronous rcv + tcap + thread tuples with asynchronous activations; most of this should already work, but we need an API for this -- schedule not just threads, but also aep endpoints to enable hierarchical scheduling, and in doing so, integrate with APIs for tcap transfer (i.e. period-based?, larger?) -- a separate API to virtually "disable interrupts" might be necessary to support the likes of the rump kernel -- idle processing should be wrapped into the `sl_sched_loop` processing, so that when idle, `rcv` can be called, thus switching to a parent scheduler. `rcv`ing on the root rcv end-point should likely idle the processor, which could get complicated. In the mean time, returning immediately would help. To make this work, 1. the sched loop needs to disambiguate between different types of activations, and 2. the `cos_sched_rcv` should have a flag to allow it to be called in blocking (idle) or non-blocking (scheduler event retrieval) modes. diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl.c b/src/components/implementation/no_interface/cFE_booter/scheddev/sl.c deleted file mode 100644 index 5c0b6c16cb..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/scheddev/sl.c +++ /dev/null @@ -1,255 +0,0 @@ -/** - * Redistribution of this file is permitted under the BSD two clause license. - * - * Copyright 2017, The George Washington University - * Author: Gabriel Parmer, gparmer@gwu.edu - */ - -#include -#include -#include -#include -#include - -struct sl_global sl_global_data; - -/* - * These functions are removed from the inlined fast-paths of the - * critical section (cs) code to save on code size/locality - */ -void -sl_cs_enter_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, thdcap_t curr, sched_tok_t tok) -{ - struct sl_thd *t = sl_thd_curr(); - struct sl_global *g = sl__globals(); - - /* recursive locks are not allowed */ - assert(csi->s.owner != t->thdcap); - if (!csi->s.contention) { - csi->s.contention = 1; - if (!ps_cas(&g->lock.u.v, cached->v, csi->v)) return; - } - /* Switch to the owner of the critical section, with inheritance using our tcap/priority */ - cos_defswitch(csi->s.owner, t->prio, g->timer_next, tok); - /* if we have an outdated token, then we want to use the same repeat loop, so return to that */ -} - -/* Return 1 if we need a retry, 0 otherwise */ -int -sl_cs_exit_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, sched_tok_t tok) -{ - struct sl_thd *t = sl_thd_curr(); - struct sl_global *g = sl__globals(); - - if (!ps_cas(&g->lock.u.v, cached->v, 0)) return 1; - /* let the scheduler thread decide which thread to run next, inheriting our budget/priority */ - cos_defswitch(g->sched_thdcap, t->prio, g->timer_next, tok); - - return 0; -} - -void -sl_thd_block(thdid_t tid) -{ - struct sl_thd *t; - - /* TODO: dependencies not yet supported */ - assert(!tid); - - sl_cs_enter(); - t = sl_thd_curr(); - if (unlikely(t->state == SL_THD_WOKEN)) { - t->state = SL_THD_RUNNABLE; - sl_cs_exit(); - return; - } - - assert(t->state == SL_THD_RUNNABLE); - t->state = SL_THD_BLOCKED; - sl_mod_block(sl_mod_thd_policy_get(t)); - sl_cs_exit_schedule(); - - return; -} - -void -sl_thd_wakeup(thdid_t tid) -{ - struct sl_thd *t; - thdcap_t thdcap; - tcap_t tcap; - tcap_prio_t prio; - - sl_cs_enter(); - t = sl_thd_lkup(tid); - if (unlikely(!t)) goto done; - - if (unlikely(t->state == SL_THD_RUNNABLE)) { - t->state = SL_THD_WOKEN; - goto done; - } - - assert(t->state = SL_THD_BLOCKED); - t->state = SL_THD_RUNNABLE; - sl_mod_wakeup(sl_mod_thd_policy_get(t)); - sl_cs_exit_schedule(); - - return; -done: - sl_cs_exit(); - return; -} - -void -sl_thd_yield(thdid_t tid) -{ - struct sl_thd *t = sl_thd_curr(); - - /* directed yields not yet supported! */ - assert(!tid); - - sl_cs_enter(); - sl_mod_yield(sl_mod_thd_policy_get(t), NULL); - sl_cs_exit_schedule(); - - return; -} - -static struct sl_thd * -sl_thd_alloc_init(thdid_t tid, thdcap_t thdcap) -{ - struct sl_thd_policy *tp = NULL; - struct sl_thd *t = NULL; - - tp = sl_thd_alloc_backend(tid); - if (!tp) goto done; - t = sl_mod_thd_get(tp); - - t->thdid = tid; - t->thdcap = thdcap; - t->state = SL_THD_RUNNABLE; - sl_thd_index_add_backend(sl_mod_thd_policy_get(t)); - -done: - return t; -} - -/* boot_thd = 1 if you want to create a boot-up thread in a separate component */ -static struct sl_thd * -sl_thd_alloc_intern(cos_thd_fn_t fn, void *data, struct cos_defcompinfo *comp, int boot_thd) -{ - struct cos_defcompinfo *dci = cos_defcompinfo_curr_get(); - struct cos_compinfo *ci = &dci->ci; - struct sl_thd *t = NULL; - thdcap_t thdcap; - thdid_t tid; - - if (!boot_thd) thdcap = cos_thd_alloc(ci, ci->comp_cap, fn, data); - else thdcap = cos_initthd_alloc(ci, comp->ci.comp_cap); - if (!thdcap) goto done; - - tid = cos_introspect(ci, thdcap, THD_GET_TID); - assert(tid); - t = sl_thd_alloc_init(tid, thdcap); - sl_mod_thd_create(sl_mod_thd_policy_get(t)); -done: - return t; -} - -struct sl_thd * -sl_thd_alloc(cos_thd_fn_t fn, void *data) -{ return sl_thd_alloc_intern(fn, data, NULL, 0); } - -/* Allocate a thread that executes in the specified component */ -struct sl_thd * -sl_thd_comp_alloc(struct cos_defcompinfo *comp) -{ return sl_thd_alloc_intern(NULL, NULL, comp, 1); } - -void -sl_thd_free(struct sl_thd *t) -{ - sl_thd_index_rem_backend(sl_mod_thd_policy_get(t)); - t->state = SL_THD_FREE; - /* TODO: add logic for the graveyard to delay this deallocation if t == current */ - sl_thd_free_backend(sl_mod_thd_policy_get(t)); -} - -void -sl_thd_param_set(struct sl_thd *t, sched_param_t sp) -{ - sched_param_type_t type; - unsigned int value; - - sched_param_get(sp, &type, &value); - sl_mod_thd_param_set(sl_mod_thd_policy_get(t), type, value); -} - -void -sl_timeout_period(microsec_t period) -{ - cycles_t p = sl_usec2cyc(period); - - sl__globals()->period = p; - sl_timeout_relative(p); -} - -/* engage space heater mode */ -void -sl_idle(void *d) -{ while (1) ; } - -void -sl_init(void) -{ - struct sl_global *g = sl__globals(); - struct cos_defcompinfo *ci = cos_defcompinfo_curr_get(); - - /* must fit in a word */ - assert(sizeof(struct sl_cs) <= sizeof(unsigned long)); - - g->cyc_per_usec = cos_hw_cycles_per_usec(BOOT_CAPTBL_SELF_INITHW_BASE); - g->lock.u.v = 0; - - sl_thd_init_backend(); - sl_mod_init(); - sl_timeout_mod_init(); - - /* Create the scheduler thread for us */ - g->sched_thd = sl_thd_alloc_init(cos_thdid(), BOOT_CAPTBL_SELF_INITTHD_BASE); - assert(g->sched_thd); - g->sched_thdcap = BOOT_CAPTBL_SELF_INITTHD_BASE; - - g->idle_thd = sl_thd_alloc(sl_idle, NULL); - assert(g->idle_thd); - - return; -} - -void -sl_sched_loop(void) -{ - thdid_t tid; - int blocked; - cycles_t cycles; - - while (1) { - struct sl_thd *t; - sched_tok_t tok; - - sl_cs_enter(); - - while (cos_sched_rcv(BOOT_CAPTBL_SELF_INITRCV_BASE, &tid, &blocked, &cycles)) { - struct sl_thd *t = sl_thd_lkup(tid); - - assert(t); - /* don't report the idle thread */ - if (unlikely(t == sl__globals()->idle_thd)) continue; - sl_mod_execution(sl_mod_thd_policy_get(t), cycles); - if (blocked) sl_mod_block(sl_mod_thd_policy_get(t)); - else sl_mod_wakeup(sl_mod_thd_policy_get(t)); - } - - /* If switch returns an inconsistency, we retry anyway */ - sl_cs_exit_schedule_nospin(); - } -} diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl.h b/src/components/implementation/no_interface/cFE_booter/scheddev/sl.h deleted file mode 100644 index 243883915e..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/scheddev/sl.h +++ /dev/null @@ -1,274 +0,0 @@ -/** - * Redistribution of this file is permitted under the BSD two clause license. - * - * Copyright 2017, The George Washington University - * Author: Gabriel Parmer, gparmer@gwu.edu - */ - -/* - * Scheduler library (sl) abstractions and functions. - * - * This library does a few things: - * 1. hide the esoteric nature of the cos_kernel_api's dispatch - * methods, and the scheduler event notifications + scheduler - * thread, - * 2. provide synchronization around scheduler data-strutures, and - * 3. abstract shared details about thread blocking/wakeup, lookup, - * and inter-thread dependency management. - * - * This library interacts with a number of other libraries/modules. - * - * - uses: dispatching functions in the cos_kernel_api (which uses, - * the kernel system call layer) - * - uses: parsec (ps) for atomic instructions and synchronization - * - uses: memory allocation functions provided by a run-time (either - * management of static memory, or something like parsec) - * - uses: scheduler modules that implement the scheduling policy - * - */ - -#ifndef SL_H -#define SL_H - -#include -#include -#include -#include -#include - -/* Critical section (cs) API to protect scheduler data-structures */ -struct sl_cs { - union sl_cs_intern { - struct { - thdcap_t owner :31; - u32_t contention :1; - } PS_PACKED s; - unsigned long v; - } u; -}; - -struct sl_global { - struct sl_cs lock; - - thdcap_t sched_thdcap; - struct sl_thd *sched_thd; - struct sl_thd *idle_thd; - - int cyc_per_usec; - cycles_t period; - cycles_t timer_next; -}; - -extern struct sl_global sl_global_data; - -static inline struct sl_global * -sl__globals(void) -{ return &sl_global_data; } - -/* FIXME: integrate with param_set */ -static inline void -sl_thd_setprio(struct sl_thd *t, tcap_prio_t p) -{ t->prio = p; } - -static inline struct sl_thd * -sl_thd_lkup(thdid_t tid) -{ return sl_mod_thd_get(sl_thd_lookup_backend(tid)); } - -static inline struct sl_thd * -sl_thd_curr(void) -{ return sl_thd_lkup(cos_thdid()); } - -/* are we the owner of the critical section? */ -static inline int -sl_cs_owner(void) -{ return sl__globals()->lock.u.s.owner == sl_thd_curr()->thdcap; } - -/* ...not part of the public API */ -void sl_cs_enter_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, thdcap_t curr, sched_tok_t tok); -int sl_cs_exit_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, sched_tok_t tok); - -/* Enter into the scheduler critical section */ -static inline void -sl_cs_enter(void) -{ - union sl_cs_intern csi, cached; - struct sl_thd *t = sl_thd_curr(); - sched_tok_t tok; - - assert(t); -retry: - tok = cos_sched_sync(); - csi.v = sl__globals()->lock.u.v; - cached.v = csi.v; - - if (unlikely(csi.s.owner)) { - sl_cs_enter_contention(&csi, &cached, t->thdcap, tok); - goto retry; - } - - csi.s.owner = t->thdcap; - if (!ps_cas(&sl__globals()->lock.u.v, cached.v, csi.v)) goto retry; - - return; -} - -/* - * Release the scheduler critical section, switch to the scheduler - * thread if there is pending contention - */ -static inline void -sl_cs_exit(void) -{ - union sl_cs_intern csi, cached; - sched_tok_t tok; - -retry: - tok = cos_sched_sync(); - csi.v = sl__globals()->lock.u.v; - cached.v = csi.v; - - if (unlikely(csi.s.contention)) { - if (sl_cs_exit_contention(&csi, &cached, tok)) goto retry; - return; - } - - if (!ps_cas(&sl__globals()->lock.u.v, cached.v, 0)) goto retry; -} - -static inline cycles_t -sl_now(void) -{ return ps_tsc(); } - -/* - * Do a few things: 1. take the critical section if it isn't already - * taken, 2. call schedule to find the next thread to run, 3. release - * the critical section (note this will cause visual asymmetries in - * your code if you call sl_cs_enter before this function), and - * 4. switch to the given thread. It hides some races, and details - * that would make this difficult to write repetitively. - * - * Preconditions: if synchronization is required with code before - * calling this, you must call sl_cs_enter before-hand (this is likely - * a typical case). - * - * Return: the return value from cos_switch. The caller must handle - * this value correctly. - * - * A common use-case is: - * - * sl_cs_enter(); - * scheduling_stuff() - * sl_cs_exit_schedule(); - * - * ...which correctly handles any race-conditions on thread selection and - * dispatch. - */ -static inline int -sl_cs_exit_schedule_nospin(void) -{ - struct sl_thd_policy *pt; - struct sl_thd *t; - struct sl_global *globals = sl__globals(); - thdcap_t thdcap; - tcap_prio_t prio; - sched_tok_t tok; - cycles_t now; - s64_t offset; - - if (unlikely(!sl_cs_owner())) sl_cs_enter(); - - tok = cos_sched_sync(); - now = sl_now(); - offset = (s64_t)(globals->timer_next - now); - if (globals->timer_next && offset <= 0) sl_timeout_mod_expended(now, globals->timer_next); - - /* - * Once we exit, we can't trust t's memory as it could be - * deallocated/modified, so cache it locally. If these values - * are out of date, the scheduler synchronization tok will - * catch it. This is a little twitchy and subtle, so lets put - * it in a function, here. - */ - pt = sl_mod_schedule(); - if (unlikely(!pt)) t = sl__globals()->idle_thd; - else t = sl_mod_thd_get(pt); - thdcap = t->thdcap; - prio = t->prio; - - sl_cs_exit(); - - /* TODO: enable per-thread tcaps for interrupt threads */ - return cos_defswitch(thdcap, prio, sl__globals()->timer_next, tok); -} - -static inline void -sl_cs_exit_schedule(void) -{ while (sl_cs_exit_schedule_nospin()) ; } - -/* - * if tid == 0, just block the current thread; otherwise, create a - * dependency from this thread on the target tid (i.e. when the - * scheduler chooses to run this thread, we will run the dependency - * instead (note that "dependency" is transitive). - */ -void sl_thd_block(thdid_t tid); -/* wakeup a thread that has (or soon will) block */ -void sl_thd_wakeup(thdid_t tid); -void sl_thd_yield(thdid_t tid); - -/* The entire thread allocation and free API */ -struct sl_thd *sl_thd_alloc(cos_thd_fn_t fn, void *data); -struct sl_thd *sl_thd_comp_alloc(struct cos_defcompinfo *comp); -void sl_thd_free(struct sl_thd *t); - -/* - * Time and timeout API. - * - * This can be used by the scheduler policy module *and* by the - * surrounding component code. To avoid race conditions between - * reading the time, and setting a timeout, we avoid relative time - * measurements. sl_now gives the current cycle count that is on an - * absolute timeline. The periodic function sets a period that can be - * used when a timeout has happened, the relative function sets a - * timeout relative to now, and the oneshot timeout sets a timeout on - * the same absolute timeline as returned by sl_now. - */ -void sl_timeout_period(cycles_t period); - -static inline cycles_t -sl_timeout_period_get(void) -{ return sl__globals()->period; } - -static inline void -sl_timeout_oneshot(cycles_t absolute_us) -{ sl__globals()->timer_next = absolute_us; } - -static inline void -sl_timeout_relative(cycles_t offset) -{ sl_timeout_oneshot(sl_now() + offset); } - -static inline microsec_t -sl_cyc2usec(cycles_t cyc) -{ return cyc / sl__globals()->cyc_per_usec; } - -static inline microsec_t -sl_usec2cyc(microsec_t usec) -{ return usec * sl__globals()->cyc_per_usec; } - -void sl_thd_param_set(struct sl_thd *t, sched_param_t sp); - -/* - * Initialization protocol in cos_init: initialization of - * library-internal data-structures, and then the ability for the - * scheduler thread to start its scheduling loop. - * - * sl_init(); - * sl_*; <- use the sl_api here - * ... - * sl_sched_loop(); <- loop here - */ -void sl_init(void); -void sl_sched_loop(void); - - -#endif /* SL_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_consts.h b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_consts.h deleted file mode 100644 index bdcda220cc..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_consts.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef SL_CONSTS -#define SL_CONSTS - -#define SL_PERIOD_US 100 - -#endif /* SL_CONSTS */ diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_mod_fprr.c b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_mod_fprr.c deleted file mode 100644 index ad056d4121..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_mod_fprr.c +++ /dev/null @@ -1,88 +0,0 @@ -#include -#include -#include -#include - -#define SL_FPRR_NPRIOS 32 -#define SL_FPRR_HIGHEST 0 -#define SL_FPRR_LOWEST (SL_FPRR_NPRIOS-1) - -struct ps_list_head threads[SL_FPRR_NPRIOS]; - -/* No RR yet */ -void -sl_mod_execution(struct sl_thd_policy *t, cycles_t cycles) -{ } - -struct sl_thd_policy * -sl_mod_schedule(void) -{ - int i; - struct sl_thd_policy *t; - - for (i = 0 ; i < SL_FPRR_NPRIOS ; i++) { - if (ps_list_head_empty(&threads[i])) continue; - t = ps_list_head_first_d(&threads[i], struct sl_thd_policy); - - return t; - } - assert(0); - - return NULL; -} - -void -sl_mod_block(struct sl_thd_policy *t) -{ - ps_list_rem_d(t); -} - -void -sl_mod_wakeup(struct sl_thd_policy *t) -{ - assert(t->priority <= SL_FPRR_LOWEST && ps_list_singleton_d(t)); - - ps_list_head_append_d(&threads[t->priority], t); -} - -void -sl_mod_yield(struct sl_thd_policy *t, struct sl_thd_policy *yield_to) -{ - assert(t->priority <= SL_FPRR_LOWEST); - - ps_list_rem_d(t); - ps_list_head_append_d(&threads[t->priority], t); -} - -void -sl_mod_thd_create(struct sl_thd_policy *t) -{ - t->priority = SL_FPRR_LOWEST; - t->period = 0; - t->period_usec = 0; - ps_list_init_d(t); -} - -void -sl_mod_thd_delete(struct sl_thd_policy *t) -{ ps_list_rem_d(t); } - -void -sl_mod_thd_param_set(struct sl_thd_policy *t, sched_param_type_t type, unsigned int v) -{ - assert(type == SCHEDP_PRIO && v < SL_FPRR_NPRIOS); - ps_list_rem_d(t); /* if we're already on a list, and we're updating priority */ - t->priority = v; - ps_list_head_append_d(&threads[t->priority], t); -} - -void -sl_mod_init(void) -{ - int i; - struct sl_thd *t; - - for (i = 0 ; i < SL_FPRR_NPRIOS ; i++) { - ps_list_head_init(&threads[i]); - } -} diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_mod_policy.h b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_mod_policy.h deleted file mode 100644 index 351eb9e4de..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_mod_policy.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef SL_POLICY_H -#define SL_POLICY_H - -#include -#include - -struct sl_thd_policy { - struct sl_thd thd; - tcap_prio_t priority; - microsec_t period_usec; - cycles_t period; - struct ps_list list; -}; - -static inline struct sl_thd * -sl_mod_thd_get(struct sl_thd_policy *tp) -{ return &tp->thd; } - -static inline struct sl_thd_policy * -sl_mod_thd_policy_get(struct sl_thd *t) -{ return ps_container(t, struct sl_thd_policy, thd); } - -#endif /* SL_POLICY_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_plugins.h b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_plugins.h deleted file mode 100644 index ad719101b6..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_plugins.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef SL_PLUGINS_H -#define SL_PLUGINS_H - -#include -#include - -/* - * The build system has to add in the appropriate backends for the - * system. We rely on the linker to hook up all of these function - * call instead of function pointers so that we can statically analyze - * stack consumption and execution paths (e.g. for WCET) which are - * prohibited by function pointers. Additionally, significant work - * (by Daniel Lohmann's group) has shown that a statically configured - * system is more naturally fault resilient. A minor benefit is the - * performance of not using function pointers, but that is secondary. - */ -struct sl_thd_policy *sl_thd_alloc_backend(thdid_t tid); -void sl_thd_free_backend(struct sl_thd_policy *t); - -void sl_thd_index_add_backend(struct sl_thd_policy *); -void sl_thd_index_rem_backend(struct sl_thd_policy *); -struct sl_thd_policy *sl_thd_lookup_backend(thdid_t); -void sl_thd_init_backend(void); - -/* - * Each scheduler policy must implement the following API. See above - * for why this is not a function-pointer-based API. - * - * Scheduler modules (policies) should define the following - */ -struct sl_thd_policy; -static inline struct sl_thd *sl_mod_thd_get(struct sl_thd_policy *tp); -static inline struct sl_thd_policy *sl_mod_thd_policy_get(struct sl_thd *t); - -void sl_mod_execution(struct sl_thd_policy *t, cycles_t cycles); -struct sl_thd_policy *sl_mod_schedule(void); - -void sl_mod_block(struct sl_thd_policy *t); -void sl_mod_wakeup(struct sl_thd_policy *t); -void sl_mod_yield(struct sl_thd_policy *t, struct sl_thd_policy *tp); - -void sl_mod_thd_create(struct sl_thd_policy *t); -void sl_mod_thd_delete(struct sl_thd_policy *t); -void sl_mod_thd_param_set(struct sl_thd_policy *t, sched_param_type_t type, unsigned int val); -void sl_mod_init(void); - -/* API for handling timer management */ -void sl_timeout_mod_expended(cycles_t now, cycles_t oldtimeout); -void sl_timeout_mod_init(void); - -#endif /* SL_PLUGINS_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_policy.h b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_policy.h deleted file mode 100644 index 351eb9e4de..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_policy.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef SL_POLICY_H -#define SL_POLICY_H - -#include -#include - -struct sl_thd_policy { - struct sl_thd thd; - tcap_prio_t priority; - microsec_t period_usec; - cycles_t period; - struct ps_list list; -}; - -static inline struct sl_thd * -sl_mod_thd_get(struct sl_thd_policy *tp) -{ return &tp->thd; } - -static inline struct sl_thd_policy * -sl_mod_thd_policy_get(struct sl_thd *t) -{ return ps_container(t, struct sl_thd_policy, thd); } - -#endif /* SL_POLICY_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_thd.h b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_thd.h deleted file mode 100644 index 3d98fe31da..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_thd.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Redistribution of this file is permitted under the BSD two clause license. - * - * Copyright 2017, The George Washington University - * Author: Gabriel Parmer, gparmer@gwu.edu - */ - -#ifndef SL_THD_H -#define SL_THD_H - -typedef enum { - SL_THD_FREE = 0, - SL_THD_BLOCKED, - SL_THD_WOKEN, /* if a race causes a wakeup before the inevitable block */ - SL_THD_RUNNABLE, - SL_THD_DYING, -} sl_thd_state; - -struct sl_thd { - sl_thd_state state; - thdid_t thdid; - thdcap_t thdcap; - tcap_prio_t prio; - struct sl_thd *dependency; -}; - -#ifndef assert -#define assert(node) do { if (unlikely(!(node))) { debug_print("assert error in @ "); *((int *)0) = 0; } } while (0) -#define PRINT_FN prints -#define debug_print(str) (PRINT_FN(str __FILE__ ":" STR(__LINE__) ".\n")) -#define BUG() do { debug_print("BUG @ "); *((int *)0) = 0; } while (0); -#define SPIN() do { while (1) ; } while (0) -#endif - -#endif /* SL_THD_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_thd_static_backend.c b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_thd_static_backend.c deleted file mode 100644 index 953dd1441f..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_thd_static_backend.c +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Redistribution of this file is permitted under the BSD two clause license. - * - * Copyright 2017, The George Washington University - * Author: Gabriel Parmer, gparmer@gwu.edu - */ - -#include -#include -#include -#include - -static struct sl_thd_policy sl_threads[MAX_NUM_THREADS]; - -/* Default implementations of backend functions */ -struct sl_thd_policy * -sl_thd_alloc_backend(thdid_t tid) -{ - assert(tid < MAX_NUM_THREADS); - return &sl_threads[tid]; -} - -void -sl_thd_free_backend(struct sl_thd_policy *t) -{ } - -void -sl_thd_index_add_backend(struct sl_thd_policy *t) -{ } - -void -sl_thd_index_rem_backend(struct sl_thd_policy *t) -{ } - -struct sl_thd_policy * -sl_thd_lookup_backend(thdid_t tid) -{ - assert(tid < MAX_NUM_THREADS); - return &sl_threads[tid]; -} - -void -sl_thd_init_backend(void) -{ } diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_timer_mod_periodic.c b/src/components/implementation/no_interface/cFE_booter/scheddev/sl_timer_mod_periodic.c deleted file mode 100644 index 21133b46f4..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/scheddev/sl_timer_mod_periodic.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include -#include - -void -sl_timeout_mod_expended(microsec_t now, microsec_t oldtimeout) -{ - assert(now >= oldtimeout); - - /* in virtual environments, or with very small periods, we might miss more than one period */ - sl_timeout_oneshot(now + (now-oldtimeout) % sl_timeout_period_get()); -} - -void -sl_timeout_mod_init(void) -{ - sl_timeout_period(SL_PERIOD_US); -} diff --git a/src/components/implementation/no_interface/cFE_booter/scheddev/unit_schedlib.c b/src/components/implementation/no_interface/cFE_booter/scheddev/unit_schedlib.c deleted file mode 100644 index 5d76698d2d..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/scheddev/unit_schedlib.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2016, Phani Gadepalli and Gabriel Parmer, GWU, gparmer@gwu.edu. - * - * This uses a two clause BSD License. - */ - -#include -#include -#include -#include -#include - -#include - -#undef assert -#define assert(node) do { if (unlikely(!(node))) { debug_print("assert error in @ "); *((int *)0) = 0; } } while (0) -#define PRINT_FN prints -#define debug_print(str) (PRINT_FN(str __FILE__ ":" STR(__LINE__) ".\n")) -#define BUG() do { debug_print("BUG @ "); *((int *)0) = 0; } while (0); -#define SPIN() do { while (1) ; } while (0) - -static void -cos_llprint(char *s, int len) -{ call_cap(PRINT_CAP_TEMP, (int)s, len, 0, 0); } - -int -prints(char *s) -{ - int len = strlen(s); - - cos_llprint(s, len); - - return len; -} - -int __attribute__((format(printf,1,2))) -printc(char *fmt, ...) -{ - char s[128]; - va_list arg_ptr; - int ret, len = 128; - - va_start(arg_ptr, fmt); - ret = vsnprintf(s, len, fmt, arg_ptr); - va_end(arg_ptr); - cos_llprint(s, ret); - - return ret; -} - -#define N_TESTTHDS 8 - -void -test_thd_fn(void *data) -{ - while (1) { - sl_thd_yield(0); - } -} - -void -cos_init(void) -{ - int i; - struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); - struct cos_compinfo *ci = cos_compinfo_get(defci); - struct sl_thd *threads[N_TESTTHDS]; - union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = 10}}; - - printc("Unit-test for the scheduling library (sl)\n"); - cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); - cos_defcompinfo_init(); - sl_init(); - - for (i = 0 ; i < N_TESTTHDS ; i++) { - threads[i] = sl_thd_alloc(test_thd_fn, NULL); - assert(threads[i]); - sl_thd_param_set(threads[i], sp.v); - } - - sl_sched_loop(); - - assert(0); - - return; -} From 313afb15f46568fbf8bfc731d3ef4841784b0515 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 5 Jun 2017 17:32:41 -0400 Subject: [PATCH 026/122] Update thread methods to use new sl improvements --- .../no_interface/cFE_booter/ostask.c | 148 +++++++----------- .../no_interface/cFE_booter/sl.c | 28 +++- .../no_interface/cFE_booter/sl.h | 54 ++++++- .../no_interface/cFE_booter/sl_mod_fprr.c | 2 +- .../no_interface/cFE_booter/sl_mod_policy.h | 13 +- .../no_interface/cFE_booter/sl_policy.h | 23 --- 6 files changed, 131 insertions(+), 137 deletions(-) delete mode 100644 src/components/implementation/no_interface/cFE_booter/sl_policy.h diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 89f6d12a24..653b6338ae 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -8,13 +8,6 @@ #include -// TODO: sl_policy thread -struct os_task { - int non_empty; - thdid_t thdid; - char name[OS_MAX_API_NAME]; -}; -struct os_task tasks[OS_MAX_TASKS]; /* ** Internal Task helper functions @@ -26,7 +19,6 @@ void OS_SchedulerStart(cos_thd_fn_t main_delegate) { union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = 1}}; sl_thd_param_set(main_delegate_thread, sp.v); - sl_sched_loop(); } @@ -44,11 +36,24 @@ int is_valid_name(const char* name) { return FALSE; } +// TODO: Figure out how to check if names are taken +int is_name_taken(const char* name) { + // for(int i = 0; i < num_tasks; i++) { + // thdid_t task_id = task_ids[i]; + // struct sl_thd_policy* task = sl_mod_thd_policy_get(sl_thd_lkup(task_id)); + // + // if(strcmp(task->name, name) == 0) { + // return TRUE; + // } + // } + return FALSE; +} + /* ** Task API */ -// FIXME: Put all these within a critical section... +// TODO: Implement flags int32 OS_TaskCreate(uint32 *task_id, const char *task_name, osal_task_entry function_pointer, uint32 *stack_pointer, @@ -66,38 +71,26 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, return OS_ERR_NAME_TOO_LONG; } - if(priority > 255 || priority < 1) { - return OS_ERR_INVALID_PRIORITY; + if(is_name_taken(task_name)) { + return OS_ERR_NAME_TAKEN; } - int i; - int selected_task_id = -1; - for(i = 0; i < OS_MAX_TASKS; i++) { - if(tasks[i].non_empty) { - if(strcmp(tasks[i].name, task_name) == 0) { - return OS_ERR_NAME_TAKEN; - } - }else if(selected_task_id == -1){ - selected_task_id = i; - } - } - if(selected_task_id == -1) { - return OS_ERR_NO_FREE_IDS; + if(priority > 255 || priority < 1) { + return OS_ERR_INVALID_PRIORITY; } - struct sl_thd* thd = sl_thd_alloc(osal_task_entry_wrapper, function_pointer); union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = priority}}; sl_thd_param_set(thd, sp.v); + struct sl_thd_policy* policy = sl_mod_thd_policy_get(thd); + strcpy(policy->osal_task_prop.name, task_name); + policy->osal_task_prop.creator = OS_TaskGetId(); + policy->osal_task_prop.stack_size = stack_size; + policy->osal_task_prop.priority = priority; + policy->osal_task_prop.OStask_id = (uint32) thd->thdid; - tasks[selected_task_id] = (struct os_task) { - .non_empty = TRUE, - .thdid = thd->thdid - }; - strcpy(tasks[selected_task_id].name, task_name); - - *task_id = selected_task_id; + *task_id = (uint32) thd->thdid; sl_cs_exit(); @@ -108,17 +101,18 @@ int32 OS_TaskDelete(uint32 task_id) { sl_cs_enter(); - if(task_id > OS_MAX_TASKS || !tasks[task_id].non_empty) { + struct sl_thd* thd = sl_thd_lkup(task_id); + if(!thd) { return OS_ERR_INVALID_ID; } - int delete_id = tasks[task_id].thdid; - tasks[task_id].non_empty = FALSE; + struct sl_thd_policy* thd_policy = sl_mod_thd_policy_get(thd); - struct sl_thd* thd = sl_thd_lkup(delete_id); - if(!thd) { - return OS_ERROR; + osal_task_entry delete_handler = thd_policy->delete_handler; + if(delete_handler) { + delete_handler(); } + sl_thd_free(thd); sl_cs_exit(); @@ -128,23 +122,11 @@ int32 OS_TaskDelete(uint32 task_id) uint32 OS_TaskGetId(void) { - sl_cs_enter(); - struct sl_thd* thd = sl_thd_curr(); - thdid_t t = thd->thdid; - int i; - for(i = 0; i < OS_MAX_TASKS; i++) { - if(tasks[i].thdid == t) { - sl_cs_exit(); - return i; - } + if(!thd) { + PANIC("Could not get the current thread!"); } - - sl_cs_exit(); - - - PANIC("Broken invariant, should be unreacheable!"); - return 0; + return thd->thdid; } void OS_TaskExit(void) @@ -154,35 +136,27 @@ void OS_TaskExit(void) PANIC("Broken invariant, should be unreacheable!"); } -int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer){ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; +int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer) +{ + sl_mod_thd_policy_get(sl_thd_lkup(OS_TaskGetId()))->delete_handler = function_pointer; + return OS_SUCCESS; } int32 OS_TaskDelay(uint32 millisecond) { // TODO: Use Phanis extension - // Meanwhile: Busy loop yielding - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + cycles_t start_time = sl_now(); + + while(sl_cyc2usec(sl_now() - start_time) / 1000 < millisecond) { + sl_thd_yield(0); + } + return OS_SUCCESS; } int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) { - sl_cs_enter(); - - if(task_id > OS_MAX_TASKS || !tasks[task_id].non_empty) { - return OS_ERR_INVALID_ID; - } - - if(new_priority < 1 || new_priority > 255) { - return OS_ERR_INVALID_PRIORITY; - } - union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = new_priority}}; - sl_thd_param_set(sl_thd_lkup(tasks[task_id].thdid), sp.v); - - sl_cs_exit(); + sl_thd_param_set(sl_thd_lkup(task_id), sp.v); return OS_SUCCESS; } @@ -196,33 +170,15 @@ int32 OS_TaskRegister(void) int32 OS_TaskGetIdByName(uint32 *task_id, const char *task_name) { - sl_cs_enter(); - - if(!task_name) { - return OS_INVALID_POINTER; - } - - if(!is_valid_name(task_name)) { - return OS_ERR_NAME_TOO_LONG; - } - - int i; - for(i = 0; i < OS_MAX_TASKS; i++) { - if(tasks[i].non_empty && strcmp(tasks[i].name, task_name) == 0) { - *task_id = i; - return OS_SUCCESS; - } - } - - sl_cs_exit(); - - return OS_ERR_NAME_NOT_FOUND; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + // TODO: Consider moving this sequence of calls to a helper function + *task_prop = sl_mod_thd_policy_get(sl_thd_lkup(OS_TaskGetId()))->osal_task_prop; + return OS_SUCCESS; } /* @@ -344,6 +300,8 @@ int32 OS_BinSemGetInfo(uint32 sem_id, OS_bin_sem_prop_t *bin_prop) return 0; } + + int32 OS_CountSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { diff --git a/src/components/implementation/no_interface/cFE_booter/sl.c b/src/components/implementation/no_interface/cFE_booter/sl.c index 5ac86e51db..55b108165b 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.c +++ b/src/components/implementation/no_interface/cFE_booter/sl.c @@ -17,21 +17,24 @@ struct sl_global sl_global_data; * These functions are removed from the inlined fast-paths of the * critical section (cs) code to save on code size/locality */ -void +int sl_cs_enter_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, thdcap_t curr, sched_tok_t tok) { struct sl_thd *t = sl_thd_curr(); struct sl_global *g = sl__globals(); + int ret; /* recursive locks are not allowed */ assert(csi->s.owner != t->thdcap); if (!csi->s.contention) { csi->s.contention = 1; - if (!ps_cas(&g->lock.u.v, cached->v, csi->v)) return; + if (!ps_cas(&g->lock.u.v, cached->v, csi->v)) return 1; } /* Switch to the owner of the critical section, with inheritance using our tcap/priority */ - cos_defswitch(csi->s.owner, t->prio, g->timeout_next, tok); + if ((ret = cos_defswitch(csi->s.owner, t->prio, g->timeout_next, tok))) return ret; /* if we have an outdated token, then we want to use the same repeat loop, so return to that */ + + return 1; } /* Return 1 if we need a retry, 0 otherwise */ @@ -235,11 +238,9 @@ sl_sched_loop(void) while (1) { int pending; - sl_cs_enter(); - do { thdid_t tid; - int blocked; + int blocked, rcvd; cycles_t cycles; struct sl_thd *t; @@ -248,18 +249,31 @@ sl_sched_loop(void) * states of it's child threads) and normal notifications (mainly activations from * it's parent scheduler). */ - pending = cos_sched_rcv(BOOT_CAPTBL_SELF_INITRCV_BASE, &tid, &blocked, &cycles); + pending = cos_sched_rcv(BOOT_CAPTBL_SELF_INITRCV_BASE, RCV_ALL_PENDING, + &rcvd, &tid, &blocked, &cycles); if (!tid) continue; t = sl_thd_lkup(tid); assert(t); /* don't report the idle thread */ if (unlikely(t == sl__globals()->idle_thd)) continue; + + /* + * receiving scheduler notifications is not in critical section mainly for + * 1. scheduler thread can often be blocked in rcv, which can add to + * interrupt execution or even AEP thread execution overheads. + * 2. scheduler events are not acting on the sl_thd or the policy structures, so + * having finer grained locks around the code that modifies sl_thd states is better. + */ + if (sl_cs_enter_sched()) continue; sl_mod_execution(sl_mod_thd_policy_get(t), cycles); if (blocked) sl_mod_block(sl_mod_thd_policy_get(t)); else sl_mod_wakeup(sl_mod_thd_policy_get(t)); + + sl_cs_exit(); } while (pending); + if (sl_cs_enter_sched()) continue; /* If switch returns an inconsistency, we retry anyway */ sl_cs_exit_schedule_nospin(); } diff --git a/src/components/implementation/no_interface/cFE_booter/sl.h b/src/components/implementation/no_interface/cFE_booter/sl.h index 9beebc6505..f3d8636fc4 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.h +++ b/src/components/implementation/no_interface/cFE_booter/sl.h @@ -85,32 +85,70 @@ sl_cs_owner(void) { return sl__globals()->lock.u.s.owner == sl_thd_curr()->thdcap; } /* ...not part of the public API */ -void sl_cs_enter_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, thdcap_t curr, sched_tok_t tok); +/* + * @csi: current critical section value + * @cached: a cached copy of @csi + * @curr: currently executing thread + * @tok: scheduler synchronization token for cos_defswitch + * + * @ret: + * (Caller of this function should retry for a non-zero return value.) + * 1 for cas failure or after successful thread switch to thread that owns the lock. + * -ve from cos_defswitch failure, allowing caller for ex: the scheduler thread to + * check if it was -EBUSY to first recieve pending notifications before retrying lock. + */ +int sl_cs_enter_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, thdcap_t curr, sched_tok_t tok); +/* + * @csi: current critical section value + * @cached: a cached copy of @csi + * @tok: scheduler synchronization token for cos_defswitch + * + * @ret: returns 1 if we need a retry, 0 otherwise + */ int sl_cs_exit_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, sched_tok_t tok); /* Enter into the scheduler critical section */ -static inline void -sl_cs_enter(void) +static inline int +sl_cs_enter_nospin(void) { union sl_cs_intern csi, cached; struct sl_thd *t = sl_thd_curr(); sched_tok_t tok; assert(t); -retry: tok = cos_sched_sync(); csi.v = sl__globals()->lock.u.v; cached.v = csi.v; if (unlikely(csi.s.owner)) { - sl_cs_enter_contention(&csi, &cached, t->thdcap, tok); - goto retry; + return sl_cs_enter_contention(&csi, &cached, t->thdcap, tok); } csi.s.owner = t->thdcap; - if (!ps_cas(&sl__globals()->lock.u.v, cached.v, csi.v)) goto retry; + if (!ps_cas(&sl__globals()->lock.u.v, cached.v, csi.v)) return 1; + + return 0; +} + +/* Enter into scheduler cs from a non-sched thread context */ +static inline void +sl_cs_enter(void) +{ while (sl_cs_enter_nospin()) ; } + +/* + * Enter into scheduler cs from scheduler thread context + * @ret: returns -EBUSY if sched thread has events to process and cannot switch threads, 0 otherwise. + */ +static inline int +sl_cs_enter_sched(void) +{ + int ret; + + while ((ret = sl_cs_enter_nospin())) { + if (ret == -EBUSY) break; + } - return; + return ret; } /* diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c index ad056d4121..fce2c56c93 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c +++ b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include #define SL_FPRR_NPRIOS 32 diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h b/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h index 351eb9e4de..ed862c60a9 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h +++ b/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h @@ -1,15 +1,22 @@ -#ifndef SL_POLICY_H -#define SL_POLICY_H +#ifndef SL_MOD_POLICY_H +#define SL_MOD_POLICY_H #include #include +#include "gen/osapi.h" +#include "gen/common_types.h" + struct sl_thd_policy { struct sl_thd thd; tcap_prio_t priority; microsec_t period_usec; cycles_t period; struct ps_list list; + + // cFE specific fields + OS_task_prop_t osal_task_prop; + osal_task_entry delete_handler; }; static inline struct sl_thd * @@ -20,4 +27,4 @@ static inline struct sl_thd_policy * sl_mod_thd_policy_get(struct sl_thd *t) { return ps_container(t, struct sl_thd_policy, thd); } -#endif /* SL_POLICY_H */ +#endif /* SL_MOD_POLICY_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_policy.h b/src/components/implementation/no_interface/cFE_booter/sl_policy.h deleted file mode 100644 index 351eb9e4de..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/sl_policy.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef SL_POLICY_H -#define SL_POLICY_H - -#include -#include - -struct sl_thd_policy { - struct sl_thd thd; - tcap_prio_t priority; - microsec_t period_usec; - cycles_t period; - struct ps_list list; -}; - -static inline struct sl_thd * -sl_mod_thd_get(struct sl_thd_policy *tp) -{ return &tp->thd; } - -static inline struct sl_thd_policy * -sl_mod_thd_policy_get(struct sl_thd *t) -{ return ps_container(t, struct sl_thd_policy, thd); } - -#endif /* SL_POLICY_H */ From 0884f59fbbaa9b95983eb762ea10742f9d9e27b3 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 5 Jun 2017 19:07:56 -0400 Subject: [PATCH 027/122] Implement several of the mutex methods --- .../no_interface/cFE_booter/ostask.c | 150 ++++++++++++++++-- 1 file changed, 140 insertions(+), 10 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 653b6338ae..3be1b51e21 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -211,34 +211,164 @@ void OS_ApplicationShutdown(uint8 flag) ** Mutex API */ +struct mutex { + uint32 used; + + uint32 held; + thdid_t holder; + char name[OS_MAX_API_NAME]; +}; + +struct mutex mutexes[OS_MAX_BIN_SEMAPHORES]; + + int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + int32 result = OS_SUCCESS; + + sl_cs_enter(); + + if(sem_id == NULL || sem_name == NULL) { + result = OS_INVALID_POINTER; + goto exit; + } + + if(!is_valid_name(sem_name)) { + result = OS_ERR_NAME_TOO_LONG; + goto exit; + } + + int id; + for(id = 0; id < OS_MAX_MUTEXES; id++) { + if(!mutexes[id].used) { + break; + } + } + if(mutexes[id].used) { + result = OS_ERR_NO_FREE_IDS; + goto exit; + } + + mutexes[id].used = TRUE; + mutexes[id].held = FALSE; + strcpy(mutexes[id].name, sem_name); + +exit: + sl_cs_exit(); + return result; } int32 OS_MutSemGive(uint32 sem_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + int32 result = OS_SUCCESS; + + sl_cs_enter(); + + if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } + + if (!mutexes[sem_id].held || mutexes[sem_id].holder != sl_thd_curr()->thdid) { + result = OS_SEM_FAILURE; + goto exit; + } + + mutexes[sem_id].held = FALSE; + +exit: + sl_cs_exit(); + + return result; } int32 OS_MutSemTake(uint32 sem_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + int32 result = OS_SUCCESS; + + sl_cs_enter(); + + if (sem_id >= OS_MAX_MUTEXES) { + result = OS_ERR_INVALID_ID; + goto exit; + } + + while (mutexes[sem_id].held && mutexes[sem_id].used) { + int holder = mutexes[sem_id].holder; + + /* + * If we are preempted after the exit, and the holder is no longer holding + * the critical section, then we will yield to them and possibly waste a + * time-slice. This will be fixed the next iteration, as we will see an + * updated value of the holder, but we essentially lose a timeslice in the + * worst case. From a real-time perspective, this is bad, but we're erring + * on simplicity here. + */ + sl_cs_exit(); + sl_thd_yield(holder); + sl_cs_enter(); + } + + if(!mutexes[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } + + mutexes[sem_id].held = TRUE; + mutexes[sem_id].holder = sl_thd_curr()->thdid; + +exit: + sl_cs_exit(); + + return result; } int32 OS_MutSemDelete(uint32 sem_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + int32 result = OS_SUCCESS; + sl_cs_enter(); + + if(sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } + + if(mutexes[sem_id].held) { + result = OS_SEM_FAILURE; + goto exit; + } + + mutexes[sem_id].used = FALSE; + + exit: + sl_cs_exit(); + + return result; } int32 OS_MutSemGetIdByName(uint32 *sem_id, const char *sem_name) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + + if(sem_id == NULL || sem_name == NULL) { + return OS_INVALID_POINTER; + } + + if(strlen(sem_name) >= OS_MAX_API_NAME) { + return OS_ERR_NAME_TOO_LONG; + } + + int i; + for(i = 0; i < OS_MAX_MUTEXES; i++) { + if (mutexes[i].used && (strcmp (mutexes[i].name, (char*) sem_name) == 0)) { + *sem_id = i; + return OS_SUCCESS; + } + } + + /* The name was not found in the table, + * or it was, and the sem_id isn't valid anymore */ + + return OS_ERR_NAME_NOT_FOUND; } int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) From 12251d663008c82e3b9a9f445eee35b8d61e3b08 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 6 Jun 2017 15:07:08 -0400 Subject: [PATCH 028/122] Add preliminary semaphore implementation --- .../no_interface/cFE_booter/osapi.c | 2 - .../no_interface/cFE_booter/ostask.c | 282 +++++++++++++++--- .../no_interface/cFE_booter/psp.c | 3 +- 3 files changed, 243 insertions(+), 44 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 7585b7fc32..10cb4428a5 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -1,5 +1,3 @@ -#include - #include "cFE_util.h" #include "sl.h" diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 3be1b51e21..19d498e63d 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -212,7 +212,7 @@ void OS_ApplicationShutdown(uint8 flag) */ struct mutex { - uint32 used; + int used; uint32 held; thdid_t holder; @@ -228,23 +228,23 @@ int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) sl_cs_enter(); - if(sem_id == NULL || sem_name == NULL) { + if (sem_id == NULL || sem_name == NULL) { result = OS_INVALID_POINTER; goto exit; } - if(!is_valid_name(sem_name)) { + if (!is_valid_name(sem_name)) { result = OS_ERR_NAME_TOO_LONG; goto exit; } int id; - for(id = 0; id < OS_MAX_MUTEXES; id++) { + for (id = 0; id < OS_MAX_MUTEXES; id++) { if(!mutexes[id].used) { break; } } - if(mutexes[id].used) { + if (mutexes[id].used) { result = OS_ERR_NO_FREE_IDS; goto exit; } @@ -309,7 +309,7 @@ int32 OS_MutSemTake(uint32 sem_id) sl_cs_enter(); } - if(!mutexes[sem_id].used) { + if (!mutexes[sem_id].used) { result = OS_ERR_INVALID_ID; goto exit; } @@ -328,12 +328,12 @@ int32 OS_MutSemDelete(uint32 sem_id) int32 result = OS_SUCCESS; sl_cs_enter(); - if(sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { + if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { result = OS_ERR_INVALID_ID; goto exit; } - if(mutexes[sem_id].held) { + if (mutexes[sem_id].held) { result = OS_SEM_FAILURE; goto exit; } @@ -348,27 +348,33 @@ int32 OS_MutSemDelete(uint32 sem_id) int32 OS_MutSemGetIdByName(uint32 *sem_id, const char *sem_name) { + int32 result = OS_SUCCESS; - if(sem_id == NULL || sem_name == NULL) { - return OS_INVALID_POINTER; + sl_cs_enter(); + + if (sem_id == NULL || sem_name == NULL) { + result = OS_INVALID_POINTER; + goto exit; } - if(strlen(sem_name) >= OS_MAX_API_NAME) { - return OS_ERR_NAME_TOO_LONG; + if (strlen(sem_name) >= OS_MAX_API_NAME) { + result = OS_ERR_NAME_TOO_LONG; + goto exit; } int i; - for(i = 0; i < OS_MAX_MUTEXES; i++) { + for (i = 0; i < OS_MAX_MUTEXES; i++) { if (mutexes[i].used && (strcmp (mutexes[i].name, (char*) sem_name) == 0)) { *sem_id = i; - return OS_SUCCESS; + goto exit; } } /* The name was not found in the table, * or it was, and the sem_id isn't valid anymore */ - - return OS_ERR_NAME_NOT_FOUND; +exit: + sl_cs_exit(); + return result; } int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) @@ -381,11 +387,213 @@ int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) ** Semaphore API */ +struct semaphore { + int used; + + uint32 count; + char name[OS_MAX_API_NAME]; +}; + + +struct semaphore binary_semaphores[OS_MAX_BIN_SEMAPHORES]; + +struct semaphore counting_semaphores[OS_MAX_COUNT_SEMAPHORES]; + +// Generic semaphore methods +int32 OS_SemaphoreCreate(struct semaphore* semaphores, uint32 max_semaphores, + uint32 *sem_id, const char *sem_name, + uint32 sem_initial_value, uint32 options) +{ + int32 result = OS_SUCCESS; + sl_cs_enter(); + + if (sem_id == NULL || sem_name == NULL) { + result = OS_INVALID_POINTER; + goto exit; + } + + if (!is_valid_name(sem_name)) { + result = OS_ERR_NAME_TOO_LONG; + goto exit; + } + + uint32 id; + for (id = 0; id < max_semaphores; id++) { + if(!semaphores[id].used) { + break; + } + } + if (semaphores[id].used) { + result = OS_ERR_NO_FREE_IDS; + goto exit; + } + + semaphores[id].used = TRUE; + semaphores[id].count = sem_initial_value; + strcpy(semaphores[id].name, sem_name); + +exit: + sl_cs_exit(); + return result; +} + +int32 OS_SemaphoreGive(struct semaphore* semaphores, uint32 max_semaphores, uint32 sem_id) +{ + int32 result = OS_SUCCESS; + + sl_cs_enter(); + + if (sem_id >= max_semaphores || !semaphores[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } + + // FIXME: Add some checks that the semaphore was actually taken by this thread + semaphores[sem_id].count += 1; + +exit: + sl_cs_exit(); + return result; + +} + +int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint32 sem_id) +{ + int32 result = OS_SUCCESS; + + sl_cs_enter(); + + if (sem_id >= max_semaphores) { + result = OS_ERR_INVALID_ID; + goto exit; + } + + while (semaphores[sem_id].used && semaphores[sem_id].count == 0) { + sl_cs_exit(); + // FIXME: Do an actually sensible yield here! + sl_thd_yield(0); + sl_cs_enter(); + } + + if (!semaphores[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } + + semaphores[sem_id].count -= 1; + +exit: + sl_cs_exit(); + + return result; +} + +int32 OS_SemaphoreTimedWait(struct semaphore* semaphores, uint32 max_semaphores, + uint32 sem_id, uint32 msecs) +{ + int32 result = OS_SUCCESS; + cycles_t start_cycles = sl_now(); + microsec_t max_wait = msecs * 1000; + + sl_cs_enter(); + + if (sem_id >= max_semaphores) { + result = OS_ERR_INVALID_ID; + goto exit; + } + + while (semaphores[sem_id].used + && semaphores[sem_id].count == 0 + && sl_cyc2usec(sl_now() - start_cycles) < max_wait) { + sl_cs_exit(); + // FIXME: Do an actually sensible yield here! + sl_thd_yield(0); + sl_cs_enter(); + } + + if (!semaphores[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } + + if (semaphores[sem_id].count == 0) { + result = OS_SEM_TIMEOUT; + goto exit; + } + + semaphores[sem_id].count -= 1; + +exit: + sl_cs_exit(); + + return result; +} + +int32 OS_SemaphoreDelete(struct semaphore* semaphores, uint32 max_semaphores, + uint32 sem_id) +{ + int32 result = OS_SUCCESS; + sl_cs_enter(); + + if (sem_id >= max_semaphores || !semaphores[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } + + // FIXME: Add smarter checking than this + if (semaphores[sem_id].count == 0) { + result = OS_SEM_FAILURE; + goto exit; + } + + semaphores[sem_id].used = FALSE; + + exit: + sl_cs_exit(); + + return result; +} + +int32 OS_SemaphoreGetIdByName(struct semaphore* semaphores, uint32 max_semaphores, + uint32 *sem_id, const char *sem_name) +{ + int32 result = OS_SUCCESS; + + sl_cs_enter(); + + if (sem_id == NULL || sem_name == NULL) { + result = OS_INVALID_POINTER; + goto exit; + } + + if (!is_valid_name(sem_name)) { + result = OS_ERR_NAME_TOO_LONG; + goto exit; + } + + uint32 i; + for (i = 0; i < max_semaphores; i++) { + if (semaphores[i].used && (strcmp(semaphores[i].name, (char*) sem_name) == 0)) { + *sem_id = i; + goto exit; + } + } + + /* The name was not found in the table, + * or it was, and the sem_id isn't valid anymore */ +exit: + sl_cs_exit(); + return result; +} + + + +// Binary semaphore methods int32 OS_BinSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SemaphoreCreate(binary_semaphores, OS_MAX_BIN_SEMAPHORES, + sem_id, sem_name, sem_initial_value, options); } int32 OS_BinSemFlush(uint32 sem_id) @@ -396,32 +604,28 @@ int32 OS_BinSemFlush(uint32 sem_id) int32 OS_BinSemGive(uint32 sem_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SemaphoreGive(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id); } int32 OS_BinSemTake(uint32 sem_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SemaphoreTake(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id); } int32 OS_BinSemTimedWait(uint32 sem_id, uint32 msecs) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SemaphoreTimedWait(binary_semaphores, OS_MAX_BIN_SEMAPHORES, + sem_id, msecs); } int32 OS_BinSemDelete(uint32 sem_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SemaphoreDelete(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id); } int32 OS_BinSemGetIdByName(uint32 *sem_id, const char *sem_name) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SemaphoreGetIdByName(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id, sem_name); } int32 OS_BinSemGetInfo(uint32 sem_id, OS_bin_sem_prop_t *bin_prop) @@ -431,42 +635,38 @@ int32 OS_BinSemGetInfo(uint32 sem_id, OS_bin_sem_prop_t *bin_prop) } - int32 OS_CountSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SemaphoreCreate(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, + sem_id, sem_name, sem_initial_value, options); } int32 OS_CountSemGive(uint32 sem_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SemaphoreGive(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, sem_id); } int32 OS_CountSemTake(uint32 sem_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SemaphoreTake(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, sem_id); } int32 OS_CountSemTimedWait(uint32 sem_id, uint32 msecs) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SemaphoreTimedWait(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, + sem_id, msecs); } int32 OS_CountSemDelete(uint32 sem_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SemaphoreDelete(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, sem_id); } int32 OS_CountSemGetIdByName(uint32 *sem_id, const char *sem_name) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SemaphoreGetIdByName(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, + sem_id, sem_name); } int32 OS_CountSemGetInfo(uint32 sem_id, OS_count_sem_prop_t *count_prop) diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c index 65667eb6a8..90ec13db38 100644 --- a/src/components/implementation/no_interface/cFE_booter/psp.c +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -329,7 +329,8 @@ int32 CFE_PSP_Decompress( char * srcFileName, char * dstFileName) void CFE_PSP_AttachExceptions(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + // For now it is safe for this to do nothing + // TODO: Actually implement exception handling } /* ** CFE_PSP_AttachExceptions will setup the exception environment for the chosen platform From 9690464deae6bb63ec5f5b7f77e310cb49fd2436 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 6 Jun 2017 16:20:02 -0400 Subject: [PATCH 029/122] Implement a few more ostask methods --- .../no_interface/cFE_booter/ostask.c | 81 +++++++++++++++++-- 1 file changed, 75 insertions(+), 6 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 19d498e63d..529c45e13e 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -214,6 +214,7 @@ void OS_ApplicationShutdown(uint8 flag) struct mutex { int used; + uint32 creator; uint32 held; thdid_t holder; char name[OS_MAX_API_NAME]; @@ -251,6 +252,7 @@ int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) mutexes[id].used = TRUE; mutexes[id].held = FALSE; + mutexes[id].creator = sl_thd_curr()->thdid; strcpy(mutexes[id].name, sem_name); exit: @@ -379,8 +381,29 @@ int32 OS_MutSemGetIdByName(uint32 *sem_id, const char *sem_name) int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + int32 result = OS_SUCCESS; + sl_cs_enter(); + + if(!mut_prop) + { + result = OS_INVALID_POINTER; + goto exit; + } + + if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } + + *mut_prop = (OS_mut_sem_prop_t) { + .creator = mutexes[sem_id].creator, + }; + + strcpy(mut_prop->name, mutexes[sem_id].name); + +exit: + sl_cs_exit(); + return result; } /* @@ -391,6 +414,7 @@ struct semaphore { int used; uint32 count; + uint32 creator; char name[OS_MAX_API_NAME]; }; @@ -429,6 +453,7 @@ int32 OS_SemaphoreCreate(struct semaphore* semaphores, uint32 max_semaphores, } semaphores[id].used = TRUE; + semaphores[id].creator = sl_thd_curr()->thdid; semaphores[id].count = sem_initial_value; strcpy(semaphores[id].name, sem_name); @@ -630,8 +655,30 @@ int32 OS_BinSemGetIdByName(uint32 *sem_id, const char *sem_name) int32 OS_BinSemGetInfo(uint32 sem_id, OS_bin_sem_prop_t *bin_prop) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + int32 result = OS_SUCCESS; + sl_cs_enter(); + + if(!bin_prop) + { + result = OS_INVALID_POINTER; + goto exit; + } + + if (sem_id >= OS_MAX_BIN_SEMAPHORES || !binary_semaphores[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } + + *bin_prop = (OS_bin_sem_prop_t) { + .creator = binary_semaphores[sem_id].creator, + .value = binary_semaphores[sem_id].count + }; + + strcpy(bin_prop->name, binary_semaphores[sem_id].name); + +exit: + sl_cs_exit(); + return result; } @@ -671,6 +718,28 @@ int32 OS_CountSemGetIdByName(uint32 *sem_id, const char *sem_name) int32 OS_CountSemGetInfo(uint32 sem_id, OS_count_sem_prop_t *count_prop) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + int32 result = OS_SUCCESS; + sl_cs_enter(); + + if(!count_prop) + { + result = OS_INVALID_POINTER; + goto exit; + } + + if (sem_id >= OS_MAX_COUNT_SEMAPHORES || !counting_semaphores[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } + + *count_prop = (OS_count_sem_prop_t) { + .creator = counting_semaphores[sem_id].creator, + .value = counting_semaphores[sem_id].count + }; + + strcpy(count_prop->name, counting_semaphores[sem_id].name); + +exit: + sl_cs_exit(); + return result; } From b75a93a58a0a54894731b2abccd5add27a7fd78b Mon Sep 17 00:00:00 2001 From: Zach Day Date: Tue, 6 Jun 2017 18:03:53 -0400 Subject: [PATCH 030/122] Implemented unit testing --- .../no_interface/cFE_booter/.gitignore | 2 ++ .../implementation/no_interface/cFE_booter/Makefile | 4 ++-- .../no_interface/cFE_booter/cFE_entrypoint.c | 7 +++++++ .../implementation/no_interface/cFE_booter/osapi.c | 13 ++++++++++++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/.gitignore b/src/components/implementation/no_interface/cFE_booter/.gitignore index 4f62b849d5..74de6c3797 100644 --- a/src/components/implementation/no_interface/cFE_booter/.gitignore +++ b/src/components/implementation/no_interface/cFE_booter/.gitignore @@ -1 +1,3 @@ gen +test +*.d.[0-9]* diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index 9a642fa2d6..2462f1e94c 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -3,10 +3,10 @@ ASM_OBJS= COMPONENT=cFE_booter.o INTERFACES= DEPENDENCIES= -IF_LIB=./composite_cFE.o +IF_LIB:=./composite_cFE.o $(wildcard test/*.o) ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api -lcos_defkernel_api include ../../Makefile.subsubdir -CFLAGS += -I./gen +CFLAGS += -I./gen -I ./test/shared MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c index 97598aa082..f79f310025 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c @@ -7,6 +7,8 @@ #include "gen/common_types.h" #include "gen/osapi.h" +#include "test/oscore-test/ut_oscore_test.h" + // This is based on an old build technique, so we can ignore this warning. // But I'm leaving it in, just in case we ever switch to cmake /* @@ -128,6 +130,11 @@ void cos_init(void) { OS_API_Init(); OS_printf("CFE_PSP: The the OS API was successfully initialized!\n"); + OS_printf("Beginning unit tests\n"); + /* Their method name is misleading -- this begins the unit tests */ + OS_Application_Startup(); + OS_printf("End unit tests\n"); + OS_printf("CFE_PSP: Delegating to scheduler setup... \n"); OS_SchedulerStart(&cos_init_delegate); } diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 7b74ab1a05..7d399e2177 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -23,7 +23,7 @@ int32 OS_API_Init(void) cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); cos_defcompinfo_init(); - + return OS_SUCCESS; } @@ -324,6 +324,17 @@ void OS_printf(const char *string, ...) } } +void OS_sprintf(char *str, const char *format, ...) +{ + if(is_printf_enabled) { + va_list arg_ptr; + int ret, len = OS_BUFFER_SIZE; + + va_start(arg_ptr, format); + ret = vsprintf(str, format, arg_ptr); + va_end(arg_ptr); + } +} void OS_printf_disable(void) { From 14552bd221477303213100c77eefb95374107c3f Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 6 Jun 2017 18:21:51 -0400 Subject: [PATCH 031/122] Implement OS_BinSemFlush --- .../no_interface/cFE_booter/ostask.c | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 529c45e13e..5f45eb3ffc 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -414,6 +414,7 @@ struct semaphore { int used; uint32 count; + int epoch; uint32 creator; char name[OS_MAX_API_NAME]; }; @@ -462,6 +463,26 @@ int32 OS_SemaphoreCreate(struct semaphore* semaphores, uint32 max_semaphores, return result; } +int32 OS_SemaphoreFlush(struct semaphore* semaphores, uint32 max_semaphores, uint32 sem_id) +{ + + int32 result = OS_SUCCESS; + + sl_cs_enter(); + + if (sem_id >= max_semaphores || !semaphores[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } + + semaphores[sem_id].epoch += 1; + +exit: + sl_cs_exit(); + return result; +} + + int32 OS_SemaphoreGive(struct semaphore* semaphores, uint32 max_semaphores, uint32 sem_id) { int32 result = OS_SUCCESS; @@ -493,7 +514,12 @@ int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint goto exit; } + int starting_epoch = semaphores[sem_id].epoch; + while (semaphores[sem_id].used && semaphores[sem_id].count == 0) { + if(semaphores[sem_id].epoch != starting_epoch) { + goto exit; + } sl_cs_exit(); // FIXME: Do an actually sensible yield here! sl_thd_yield(0); @@ -623,8 +649,7 @@ int32 OS_BinSemCreate(uint32 *sem_id, const char *sem_name, int32 OS_BinSemFlush(uint32 sem_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SemaphoreFlush(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id); } int32 OS_BinSemGive(uint32 sem_id) From ad69a1ac379a38935ddd9070c74f6e738635137a Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 6 Jun 2017 18:37:50 -0400 Subject: [PATCH 032/122] Fix some task_id handling bugs --- .../no_interface/cFE_booter/ostask.c | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 5f45eb3ffc..9346906036 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -99,13 +99,22 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, int32 OS_TaskDelete(uint32 task_id) { + int32 result = OS_SUCCESS; + sl_cs_enter(); + if (task_id >= OS_MAX_TASKS) { + result = OS_ERR_INVALID_ID; + goto exit; + } + struct sl_thd* thd = sl_thd_lkup(task_id); if(!thd) { - return OS_ERR_INVALID_ID; + result = OS_ERR_INVALID_ID; + goto exit; } + struct sl_thd_policy* thd_policy = sl_mod_thd_policy_get(thd); osal_task_entry delete_handler = thd_policy->delete_handler; @@ -115,9 +124,10 @@ int32 OS_TaskDelete(uint32 task_id) sl_thd_free(thd); +exit: sl_cs_exit(); - return OS_SUCCESS; + return result; } uint32 OS_TaskGetId(void) @@ -155,8 +165,17 @@ int32 OS_TaskDelay(uint32 millisecond) int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) { + if (task_id >= OS_MAX_TASKS) { + return OS_ERR_INVALID_ID; + } + + struct sl_thd* thd = sl_thd_lkup(task_id); + if(!thd) { + return OS_ERR_INVALID_ID; + } + union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = new_priority}}; - sl_thd_param_set(sl_thd_lkup(task_id), sp.v); + sl_thd_param_set(thd, sp.v); return OS_SUCCESS; } @@ -177,7 +196,7 @@ int32 OS_TaskGetIdByName(uint32 *task_id, const char *task_name) int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) { // TODO: Consider moving this sequence of calls to a helper function - *task_prop = sl_mod_thd_policy_get(sl_thd_lkup(OS_TaskGetId()))->osal_task_prop; + *task_prop = sl_mod_thd_policy_get(sl_thd_lkup(task_id))->osal_task_prop; return OS_SUCCESS; } From 62655e356e4e9f53f183952a032f8869c5f29a1a Mon Sep 17 00:00:00 2001 From: Zach Day Date: Tue, 6 Jun 2017 18:45:49 -0400 Subject: [PATCH 033/122] Fixed an unused variable warning in --- src/components/implementation/no_interface/cFE_booter/osapi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 9c73b92248..fa26a2bd21 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -362,7 +362,6 @@ void OS_sprintf(char *str, const char *format, ...) { if(is_printf_enabled) { va_list arg_ptr; - int ret, len = OS_BUFFER_SIZE; va_start(arg_ptr, format); ret = vsprintf(str, format, arg_ptr); From 2ea12edadc0a9164548d2e7bc2728912bfd909c2 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Wed, 7 Jun 2017 12:31:28 -0400 Subject: [PATCH 034/122] Fix obvious build error --- src/components/implementation/no_interface/cFE_booter/osapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 10cb4428a5..0819bf3e3a 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -352,7 +352,7 @@ void OS_printf(const char *string, ...) int ret, len = OS_BUFFER_SIZE; va_start(arg_ptr, string); - ret = vsnprintf(s, len, string, arg_ptr); + vsnprintf(s, len, string, arg_ptr); va_end(arg_ptr); llprint(s, ret); } From 3642436cb68d63317a219c4e0f35a049a7eda618 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Wed, 7 Jun 2017 12:32:24 -0400 Subject: [PATCH 035/122] Revert "Fix obvious build error" This reverts commit 2ea12edadc0a9164548d2e7bc2728912bfd909c2. --- src/components/implementation/no_interface/cFE_booter/osapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 32042a8eb3..fa26a2bd21 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -352,7 +352,7 @@ void OS_printf(const char *string, ...) int ret, len = OS_BUFFER_SIZE; va_start(arg_ptr, string); - vsnprintf(s, len, string, arg_ptr); + ret = vsnprintf(s, len, string, arg_ptr); va_end(arg_ptr); llprint(s, ret); } From 1cc24c6810ed4cb4fe1335e636aa4f07c6129641 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Wed, 7 Jun 2017 12:33:09 -0400 Subject: [PATCH 036/122] Fix obvious build error --- src/components/implementation/no_interface/cFE_booter/osapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index fa26a2bd21..e038757e13 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -364,7 +364,7 @@ void OS_sprintf(char *str, const char *format, ...) va_list arg_ptr; va_start(arg_ptr, format); - ret = vsprintf(str, format, arg_ptr); + vsprintf(str, format, arg_ptr); va_end(arg_ptr); } } From 027e72731b8276ed592aa276ddb711f67976386b Mon Sep 17 00:00:00 2001 From: Zach Day Date: Wed, 7 Jun 2017 16:15:32 -0400 Subject: [PATCH 037/122] Implemented conditional conditional compilation of unit test calls. --- .../implementation/no_interface/cFE_booter/Makefile | 2 +- .../no_interface/cFE_booter/cFE_entrypoint.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index 2462f1e94c..866068b92e 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -7,6 +7,6 @@ IF_LIB:=./composite_cFE.o $(wildcard test/*.o) ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api -lcos_defkernel_api include ../../Makefile.subsubdir -CFLAGS += -I./gen -I ./test/shared +CFLAGS += -I./gen -I ./test/shared $(CPPFLAGS) MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c index f79f310025..5ada055779 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c @@ -71,6 +71,14 @@ struct CFE_PSP_CommandData_t args; // This is the delegate function called by the scheduler void cos_init_delegate(void* data) { OS_printf("CFE_PSP: Doing PSP setup...\n"); + +#ifdef UNIT_TESTS + OS_printf("Beginning unit tests\n"); + /* Their method name is misleading -- this begins the unit tests, not application */ + OS_Application_Startup(); + OS_printf("End unit tests\n"); +#endif + /* ** Initialize the statically linked modules (if any) ** This is only applicable to CMake build - classic build @@ -130,11 +138,6 @@ void cos_init(void) { OS_API_Init(); OS_printf("CFE_PSP: The the OS API was successfully initialized!\n"); - OS_printf("Beginning unit tests\n"); - /* Their method name is misleading -- this begins the unit tests */ - OS_Application_Startup(); - OS_printf("End unit tests\n"); - OS_printf("CFE_PSP: Delegating to scheduler setup... \n"); OS_SchedulerStart(&cos_init_delegate); } From d8cdca34e150baf8f56bd0f299695065fa41e141 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Thu, 8 Jun 2017 13:10:02 -0400 Subject: [PATCH 038/122] Increase stack size to fix overflow errors --- .../implementation/no_interface/cFE_booter/osapi.c | 11 ++++------- .../implementation/no_interface/cFE_booter/ostask.c | 9 --------- .../implementation/no_interface/cFE_booter/sl.h | 13 ++++++++++--- src/kernel/include/shared/consts.h | 2 +- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index e038757e13..a62cb0520b 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -360,13 +360,10 @@ void OS_printf(const char *string, ...) void OS_sprintf(char *str, const char *format, ...) { - if(is_printf_enabled) { - va_list arg_ptr; - - va_start(arg_ptr, format); - vsprintf(str, format, arg_ptr); - va_end(arg_ptr); - } + va_list arg_ptr; + va_start(arg_ptr, format); + vsprintf(str, format, arg_ptr); + va_end(arg_ptr); } void OS_printf_disable(void) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 9346906036..1e45e1ba68 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -103,11 +103,6 @@ int32 OS_TaskDelete(uint32 task_id) sl_cs_enter(); - if (task_id >= OS_MAX_TASKS) { - result = OS_ERR_INVALID_ID; - goto exit; - } - struct sl_thd* thd = sl_thd_lkup(task_id); if(!thd) { result = OS_ERR_INVALID_ID; @@ -165,10 +160,6 @@ int32 OS_TaskDelay(uint32 millisecond) int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) { - if (task_id >= OS_MAX_TASKS) { - return OS_ERR_INVALID_ID; - } - struct sl_thd* thd = sl_thd_lkup(task_id); if(!thd) { return OS_ERR_INVALID_ID; diff --git a/src/components/implementation/no_interface/cFE_booter/sl.h b/src/components/implementation/no_interface/cFE_booter/sl.h index f3d8636fc4..13cb073291 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.h +++ b/src/components/implementation/no_interface/cFE_booter/sl.h @@ -73,11 +73,18 @@ sl_thd_setprio(struct sl_thd *t, tcap_prio_t p) static inline struct sl_thd * sl_thd_lkup(thdid_t tid) -{ return sl_mod_thd_get(sl_thd_lookup_backend(tid)); } +{ + assert(tid < MAX_NUM_THREADS); + return sl_mod_thd_get(sl_thd_lookup_backend(tid)); +} static inline struct sl_thd * sl_thd_curr(void) -{ return sl_thd_lkup(cos_thdid()); } +{ + thdid_t tid = cos_thdid(); + assert(tid < MAX_NUM_THREADS); + return sl_thd_lkup(tid); +} /* are we the owner of the critical section? */ static inline int @@ -94,7 +101,7 @@ sl_cs_owner(void) * @ret: * (Caller of this function should retry for a non-zero return value.) * 1 for cas failure or after successful thread switch to thread that owns the lock. - * -ve from cos_defswitch failure, allowing caller for ex: the scheduler thread to + * -ve from cos_defswitch failure, allowing caller for ex: the scheduler thread to * check if it was -EBUSY to first recieve pending notifications before retrying lock. */ int sl_cs_enter_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, thdcap_t curr, sched_tok_t tok); diff --git a/src/kernel/include/shared/consts.h b/src/kernel/include/shared/consts.h index dd67d70249..0df92f4754 100644 --- a/src/kernel/include/shared/consts.h +++ b/src/kernel/include/shared/consts.h @@ -50,7 +50,7 @@ struct pt_regs { #define MAX_SERVICE_DEPTH 31 #define MAX_NUM_THREADS 64 /* Stacks are 2 * page_size (expressed in words) */ -#define MAX_STACK_SZ (PAGE_SIZE/4) /* a page */ +#define MAX_STACK_SZ (PAGE_SIZE * 2) /* a page */ #define COS_STACK_SZ (MAX_STACK_SZ*4) #define ALL_STACK_SZ (MAX_NUM_THREADS*MAX_STACK_SZ) #define MAX_SPD_VAS_LOCATIONS 8 From 2552fc031828624c48b70036c649125fd0efc836 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Thu, 8 Jun 2017 14:01:08 -0400 Subject: [PATCH 039/122] Increase the number of priorities to match cFE's expectations --- .../implementation/no_interface/cFE_booter/sl_mod_fprr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c index fce2c56c93..0f5ebe80e0 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c +++ b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c @@ -3,7 +3,7 @@ #include #include -#define SL_FPRR_NPRIOS 32 +#define SL_FPRR_NPRIOS 256 #define SL_FPRR_HIGHEST 0 #define SL_FPRR_LOWEST (SL_FPRR_NPRIOS-1) From a34e6d5dd53427a866c0dfbd1cc154b56d8c89ed Mon Sep 17 00:00:00 2001 From: Zach Day Date: Tue, 13 Jun 2017 17:11:32 -0400 Subject: [PATCH 040/122] Fixed #17: build breaking when building without compiling unit tests first --- .../implementation/no_interface/cFE_booter/cFE_entrypoint.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c index 5ada055779..4150543069 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c @@ -7,7 +7,9 @@ #include "gen/common_types.h" #include "gen/osapi.h" +#ifdef UNIT_TESTS #include "test/oscore-test/ut_oscore_test.h" +#endif // This is based on an old build technique, so we can ignore this warning. // But I'm leaving it in, just in case we ever switch to cmake From 3d8a74bf33d8ab34ecce5e93925913bf617084fc Mon Sep 17 00:00:00 2001 From: Joseph Espy Date: Fri, 9 Jun 2017 15:03:58 -0400 Subject: [PATCH 041/122] Implement read only filesystem and tar parsing Parses tar into statically allocated fsobjs which build into tree Implemented a number of OSAPI wrappers. --- .../no_interface/cFE_booter/osfiles.c | 84 ++--- .../no_interface/cFE_booter/osfilesys.c | 308 ++++++++++++++++++ .../no_interface/cFE_booter/osfilesys.h | 113 +++++++ 3 files changed, 467 insertions(+), 38 deletions(-) create mode 100644 src/components/implementation/no_interface/cFE_booter/osfilesys.c create mode 100644 src/components/implementation/no_interface/cFE_booter/osfilesys.h diff --git a/src/components/implementation/no_interface/cFE_booter/osfiles.c b/src/components/implementation/no_interface/cFE_booter/osfiles.c index 642179d58f..6b04c83855 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfiles.c +++ b/src/components/implementation/no_interface/cFE_booter/osfiles.c @@ -1,8 +1,4 @@ -#include "cFE_util.h" - -#include "gen/osapi.h" -#include "gen/common_types.h" - +#include "osfilesys.h" /****************************************************************************** ** Standard File system API @@ -13,8 +9,7 @@ int32 OS_FS_Init(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_FS_SUCCESS; } /* @@ -22,7 +17,7 @@ int32 OS_FS_Init(void) */ int32 OS_creat(const char *path, int32 access) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Read Only Filesystem"); return 0; } @@ -31,26 +26,26 @@ int32 OS_creat(const char *path, int32 access) */ int32 OS_open(const char *path, int32 access, uint32 mode) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if (access != OS_READ_ONLY) PANIC("Read Only Filesystem!"); + if (!path) return OS_FS_ERR_INVALID_POINTER; + if (strlen(path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + return open(path); } /* * Closes an open file. */ -int32 OS_close(int32 filedes) +int32 OS_close(int32 filedes) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return close(filedes); } /* * Reads nbytes bytes from file into buffer */ -int32 OS_read(int32 filedes, void *buffer, uint32 nbytes) +int32 OS_read(int32 filedes, void *buffer, uint32 nbytes) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return read(filedes, buffer, nbytes); } /* @@ -58,7 +53,7 @@ int32 OS_read(int32 filedes, void *buffer, uint32 nbytes) */ int32 OS_write(int32 filedes, void *buffer, uint32 nbytes) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Read Only Filesystem!"); return 0; } @@ -67,7 +62,7 @@ int32 OS_write(int32 filedes, void *buffer, uint32 nbytes) */ int32 OS_chmod(const char *path, uint32 access) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Read Only Filesystem!"); return 0; } @@ -94,7 +89,7 @@ int32 OS_lseek(int32 filedes, int32 offset, uint32 whence) */ int32 OS_remove(const char *path) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Read Only Filesystem!"); return 0; } @@ -103,7 +98,7 @@ int32 OS_remove(const char *path) */ int32 OS_rename(const char *old_filename, const char *new_filename) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Read Only Filesystem!"); return 0; } @@ -112,7 +107,7 @@ int32 OS_rename(const char *old_filename, const char *new_filename) */ int32 OS_cp(const char *src, const char *dest) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Read Only Filesystem!"); return 0; } @@ -121,7 +116,7 @@ int32 OS_cp(const char *src, const char *dest) */ int32 OS_mv(const char *src, const char *dest) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Read Only Filesystem!"); return 0; } @@ -171,7 +166,7 @@ int32 OS_CloseFileByName(char *Filename) */ int32 OS_mkdir(const char *path, uint32 access) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Read Only Filesystem!"); return 0; } @@ -228,25 +223,36 @@ int32 OS_rmdir(const char *path) int32 OS_mkfs(char *address,char *devname, char *volname, uint32 blocksize, uint32 numblocks) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + uint32 ret = 0; + if (address) return OS_FS_ERR_INVALID_POINTER; + if (!devname || !volname) return OS_FS_ERR_INVALID_POINTER; + if (strlen(devname) >= OS_FS_DEV_NAME_LEN || strlen(volname) >= OS_FS_VOL_NAME_LEN) + return OS_FS_ERROR; + ret = newfs_init(devname, volname, blocksize, numblocks); + if (ret != OS_FS_SUCCESS) return ret; + ret = tar_parse(); + if (ret != OS_FS_SUCCESS) return ret; + return OS_FS_SUCCESS; } /* * Mounts a file system */ int32 OS_mount(const char *devname, char *mountpoint) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if (!devname || !mountpoint) return OS_FS_ERR_INVALID_POINTER; + return mount(devname, mountpoint); } /* - * Initializes an existing file system + * Initializes an existing filesystem + * address will be null if wants to initialize an empty fs, non-null to load an fs from memory + * we could easily load a tar from memory but if an application wants to load a filesystem it + * is safer to panic as we do not know what format the application is attempting to load */ -int32 OS_initfs(char *address,char *devname, char *volname, uint32 blocksize, uint32 numblocks) +int32 OS_initfs(char *address, char *devname, char *volname, uint32 blocksize, uint32 numblocks) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if (address) PANIC("No support for loading a filesystem from arbitrary memory"); + return OS_FS_SUCCESS; } /* @@ -254,7 +260,7 @@ int32 OS_initfs(char *address,char *devname, char *volname, uint32 blocksize, ui */ int32 OS_rmfs(char *devname) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Read Only Filesystem!"); // TODO: Implement me! return 0; } @@ -263,8 +269,8 @@ int32 OS_rmfs(char *devname) */ int32 OS_unmount(const char *mountpoint) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if (!mountpoint) return OS_FS_ERR_INVALID_POINTER; + return unmount(mountpoint); } /* @@ -288,6 +294,7 @@ int32 OS_fsBytesFree(const char *name, uint64 *bytes_free) } /* + * * Checks the health of a file system and repairs it if neccesary */ os_fshealth_t OS_chkfs(const char *name, boolean repair) @@ -306,12 +313,13 @@ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, char * MountPoint) } /* -** Translates a OSAL Virtual file system path to a host Local path + * This is currently not used by osal + * Translates a OSAL Virtual file system path to a host Local path */ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + strcpy(LocalPath, VirtualPath); + return OS_FS_SUCCESS; } /* @@ -331,6 +339,6 @@ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) * command to the file specified by the given OSAPI file descriptor */ int32 OS_ShellOutputToFile(char* Cmd, int32 OS_fd) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Read Only Filesystem!"); // TODO: Implement me! return 0; } diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.c b/src/components/implementation/no_interface/cFE_booter/osfilesys.c new file mode 100644 index 0000000000..0c5ac1c2b8 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.c @@ -0,0 +1,308 @@ +#include "cFE_util.h" +#include "osfilesys.h" + +struct FS fs[MAX_NUM_FS]; +struct fsobj files[MAX_NUM_FILES]; + +/* + * Notes on this version: + * This is not the final implementation of a file system for the cFE on COS + * For now the file system is read only and staticly allocates for fsobj and FS + * The next step is to write a dumb allocator/deallocator and use it for + * new fs, fsobj, and file data + * I have been intentional to restrict memory specific details to this file + * osfilesys.h and osfiles.c 'should' not care about how FS, fsobj, and data + * are stored in memory. + */ + +/****************************************************************************** +** Tar Level Methods +******************************************************************************/ + +/* + * Loads the position in memory of linked tar file system + * Checks for badly linked or no linked tar file. The names given by + * the linker are non-intuative so a description of error checking is given: + * First checks to make sure that symbols have been overwritten by linking + * process. Next checks that the size is greater than 0. Finally checks that + * the end of the tar is after the start + */ +uint32 tar_load() +{ + if (!_binary_cFEfs_tar_start) + return OS_FS_ERR_DRIVE_NOT_CREATED; + if (! &_binary_cFEfs_tar_size) + return OS_FS_ERR_DRIVE_NOT_CREATED; + if (&_binary_cFEfs_tar_end < &_binary_cFEfs_tar_start) + return OS_FS_ERR_DRIVE_NOT_CREATED; + size = (size_t) &_binary_cFEfs_tar_size; + start = &_binary_cFEfs_tar_start; + end = &_binary_cFEfs_tar_end; + return OS_FS_SUCCESS; +} + +/* + * parses a loaded tar into fs[0] + */ +uint32 tar_parse() +{ + assert(start && end); + assert(size < INT32_MAX); + assert(end - start > 0); + assert(size == (size_t) (end - start)); + assert(fs[0].root->filedes == 1); //first fs should be rooted by first file + + if (!fs[0].devname) return OS_FS_ERR_DRIVE_NOT_CREATED; + + struct fsobj *o = fs[0].root; + uint32 offset = 0; + + while (offset + start < end) { + //tar ends after two empty records + if ( !(offset + start)[0] && !(offset + start)[TAR_BLOCKSIZE]) return OS_FS_SUCCESS; + + if (tar_cphdr(offset, o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + if (file_insert(o, &fs[0])) return OS_FS_ERR_DRIVE_NOT_CREATED; + //data is alligned to 512 byte blocks. a header is 500 bytes, and + // the file's data begins exactly after the header + // therefor the next header is 500 + o->size rounded up to a mult of 512 + offset += round_to_blocksize(o->size + 500); + if (newfile_get(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + } + + //tar ends before two empty records are found + return OS_FS_ERROR; +} + +/* + * Copies information from a tar file header to a fsobj + */ +uint32 tar_cphdr(uint32 tar_offset, struct fsobj *file) +{ + //TODO: store filenames without paths + assert(tar_offset < size); + assert(file->filedes > 0); + + char *location = start; + location += tar_offset; + file->name = location; + if (*(location + strlen(location) - 1) == '/') { + file->type = FSOBJ_DIR; + file->size = 0; + } + else{ + file->type = FSOBJ_FILE; + file->size = oct_to_dec(location + 124); + file->data = location + 500; + } + return OS_FS_SUCCESS; +} + +//this could be more performant bithack +uint32 round_to_blocksize(uint32 offset) +{ + if (offset % TAR_BLOCKSIZE) return offset + (TAR_BLOCKSIZE - (offset % TAR_BLOCKSIZE)); + return offset; +} + +/****************************************************************************** +** fsobj Level Methods +******************************************************************************/ + +uint32 fsobj_init(struct fsobj *o) +{ + assert(o); + assert(o->filedes > 0); + + o->name = "EXAMPLE_NAME"; + o->type = FSOBJ_DIR; + o->size = 0; + o->refcnt = 0; + o->data = NULL; + o->child = o->parent = NULL; + o->next = o->prev = NULL; + return OS_FS_SUCCESS; +} + +//finds the next open file +uint32 newfile_get(struct fsobj **o) +{ + uint32 count = 0; + while (count < MAX_NUM_FILES && files[count].filedes) { + count++; + } + if (count == MAX_NUM_FILES) return OS_FS_ERROR; + *o = &files[count]; + (*o)->filedes = count + 1; + //filedes needs to be unique and nonzero, so filedes is defined as index+1 + return OS_FS_SUCCESS; +} + +uint32 file_insert(struct fsobj *o, struct FS *filesys) +{ + assert(filesys && filesys->root && filesys->root->filedes); + if (filesys->root == o) return OS_FS_SUCCESS; + + insert(o, filesys->root); + + return OS_FS_SUCCESS; +} + +//could be written iteratively to use less stackframe if that becomes an issue +// Root is +uint32 insert(struct fsobj *o, struct fsobj *root) +{ + assert(root && o); + assert(strlen(root->name) < strlen(o->name)); + + //loop terminates when it finds a place to put o, either at the end of a + //list of children or as the first in an empty children list + while (1) { + assert(strcmp(root->name, o->name) !=0 ); + assert(strspn(o->name, root->name) >= strlen(root->name)); + //if there is no child, then insert as child + if (!root->child) { + o->parent = root; + root->child = o; + return OS_FS_SUCCESS; + } + root = root->child; + + //precondition: root is the first in a non-empty list of children + //postcondition: root is an ancestor of o + while (strspn(o->name, root->name) < strlen(root->name)) { + if (!root->next) { + root->next = o; + o->prev = root; + o->parent = root->parent; + return OS_FS_SUCCESS; + } + root = root->next; + } + + } + PANIC("Unreachable Statement"); + return 0; +} + +int32 open(const char *path) { + assert(fs[0].root && !fs[1].root); + struct fsobj *root = fs[0].root; + root = find(path, root); + if (!root) return OS_FS_ERROR; + root->refcnt++; + return root->filedes; +} + +int32 close(int32 filedes) { + uint32 index = filedes + 1; + if (files[index].filedes != filedes) return OS_FS_ERROR; + if (files[index].refcnt < 1) return OS_FS_ERROR; + files[index].refcnt--; + return OS_FS_SUCCESS; +} + +int32 read(int32 filedes, void *buffer, uint32 nbytes) { + if (!buffer) return OS_FS_ERR_INVALID_POINTER; + if (files[filedes + 1].filedes != filedes) return OS_FS_ERROR; + if (files[filedes + 1].refcnt < 1) return OS_FS_ERROR; + if (nbytes == 0) return 0; + memcpy(buffer, files[filedes + 1].data, nbytes); + return nbytes; +} + +struct fsobj *find(const char *path, struct fsobj *root) +{ + assert(root); + assert(strlen(root->name) < strlen(path)); + while (1) { + assert(strcmp(root->name, path) !=0 ); + assert(strspn(path, root->name) >= strlen(root->name)); + if (!root->child) return NULL; + + root = root->child; + + while (strspn(path, root->name) < strlen(root->name)) { + if (!strcmp(root->name, path)) return root; + if (!root->next) return NULL; + root = root->next; + } + + } + PANIC("Unreachable Statement"); + return NULL; +} + +/****************************************************************************** +** fs Level Methods +******************************************************************************/ + +uint32 mount(const char *devname, char *mountpoint) +{ + uint32 i; + for (i=0 ; i < MAX_NUM_FS && fs[i].devname != NULL ; i++) { + if (!strcmp(fs[i].devname, devname)) { + fs[i].mountpoint = mountpoint; + return OS_FS_SUCCESS; + } + } + return OS_FS_ERROR; +} + +uint32 unmount(const char *mountpoint) { + uint32 i; + for (i=0 ; i < MAX_NUM_FS ; i++) { + if (mountpoint != NULL && !strcmp(fs[i].mountpoint, mountpoint)) { + fs[i].mountpoint = NULL; + return OS_FS_SUCCESS; + } + } + return OS_FS_ERROR; +} + +/* + * Given a pointer to an FS, inits values and fsobj for root + */ +uint32 fs_init(struct FS *filesys, char *devname, char *volname, uint32 blocksize, uint32 numblocks) +{ + struct fsobj *o = NULL; + if (newfile_get(&o)) return OS_FS_ERROR; + if (fsobj_init(o)) return OS_FS_ERROR; + filesys->devname = devname; + filesys->mountpoint = ""; + filesys->blocksize = blocksize; + filesys->numblocks = numblocks; + filesys->root = o; + filesys->next = NULL; + filesys->prev = NULL; + return OS_FS_SUCCESS; +} + +uint32 newfs_init(char *devname, char *volname, uint32 blocksize, uint32 numblocks) +{ + uint32 count = 1, ret = 0; + if (!devname) return OS_FS_ERR_INVALID_POINTER; + if (blocksize == 0 || numblocks == 0) return OS_FS_ERROR; + if (strlen(devname) >= OS_FS_DEV_NAME_LEN || strlen(volname) >= OS_FS_VOL_NAME_LEN) + return OS_FS_ERROR; + + //the first filesystem is always the tar + if (!fs[0].devname) { + ret = tar_load(); + if (ret != OS_FS_SUCCESS) return ret; + ret = fs_init(&fs[0], devname, volname, blocksize, numblocks); + if (ret != OS_FS_SUCCESS) return ret; + return OS_FS_SUCCESS; + } + + while (count < MAX_NUM_FS && fs[count].devname) { + count++; + } + if (count == MAX_NUM_FS) + return OS_FS_ERR_DRIVE_NOT_CREATED; + + ret = fs_init(&fs[count], devname, volname, blocksize, numblocks); + if (ret !=OS_FS_SUCCESS) return ret; + + return OS_FS_SUCCESS; +} diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.h b/src/components/implementation/no_interface/cFE_booter/osfilesys.h new file mode 100644 index 0000000000..3770f2b03f --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.h @@ -0,0 +1,113 @@ +#include "cFE_util.h" +#include +#include "gen/common_types.h" +#include "gen/osapi.h" +#include "gen/osapi-os-filesys.h" + +// Not to be confused with similar OSAL constants. +// These are only to define size of statically allocated data +#define MAX_NUM_FS 3 +#define MAX_NUM_FILES 100 + +#define TAR_BLOCKSIZE 512 +#define INT32_MAX 0x7FFFFFF //2^31 - 1 + +//should be overwritten by linking step in build process +__attribute__((weak)) char _binary_cFEfs_tar_size=0; +__attribute__((weak)) char _binary_cFEfs_tar_start=0; +__attribute__((weak)) char _binary_cFEfs_tar_end=0; + +//locations and size of tar +char *start; +char *end; +size_t size; + +typedef enum { + FSOBJ_FILE, + FSOBJ_DIR, +} fsobj_type_t; + +struct fsobj { + char *name; + int32 filedes; // 0 for free file, posative for tracked file + fsobj_type_t type; + size_t size; + uint32 refcnt; //number of programs which have opened it + char *data; + struct fsobj *next, *prev; + struct fsobj *child, *parent; /* child != NULL iff type = dir */ +}; + +struct FS { + char *devname; + char *volname; + char *mountpoint; + uint32 blocksize; + uint32 numblocks; + struct fsobj *root; + struct FS *next, *prev; +}; + +/****************************************************************************** +** Tar Level Methods +******************************************************************************/ + +uint32 tar_load(); + +uint32 tar_parse(); + +int32 tar_read(uint32 offset, char *buf, uint32 req_sz); + +uint32 tar_cphdr(uint32 tar_offset, struct fsobj *file); + +uint32 round_to_blocksize(uint32 offset); + +static inline uint32 oct_to_dec(char *oct) +{ + int32 i, base; + int32 tot; + + i = strlen(oct) - 1; + + for (base = 1, tot = 0 ; i >= 0 ; i--, base *= 8) { + char val = oct[i]; + + assert(val <= '7' && val >= '0'); + val = val - '0'; + tot = tot + (val * base); + } + + return tot; +} + +/****************************************************************************** +** fsobj Level Methods +******************************************************************************/ + +uint32 fsobj_init(struct fsobj *o); + +uint32 newfile_get(struct fsobj **o); + +uint32 file_insert(struct fsobj *o, struct FS *fs); + +uint32 insert(struct fsobj *o, struct fsobj *root); + +int32 open(const char *path); + +int32 close(int32 filedes); + +int32 read(int32 filedes, void *buffer, uint32 nbytes); + +struct fsobj *find(const char *path, struct fsobj *root); + +/****************************************************************************** +** fs Level Methods +******************************************************************************/ + +uint32 mount(const char *devname, char *mountpoint); + +uint32 unmount(const char *mountpoint); + +uint32 fs_init(struct FS *filesys, char *devname, char *volname, uint32 blocksize, uint32 numblocks); + +uint32 newfs_init(char *defilvname, char *volname, uint32 blocksize, uint32 numblocks); From 8e15b2c2238ff9c478e20edccf02aeb8d24e4a7c Mon Sep 17 00:00:00 2001 From: Zach Day Date: Thu, 15 Jun 2017 23:46:27 -0400 Subject: [PATCH 042/122] Clean up unit test process and run tests in a Composite-friendly way --- .../no_interface/cFE_booter/cFE_entrypoint.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c index 4150543069..c4a8dc3b4a 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c @@ -8,7 +8,7 @@ #include "gen/osapi.h" #ifdef UNIT_TESTS -#include "test/oscore-test/ut_oscore_test.h" +#include "test/shared/ut_main_composite.h" #endif // This is based on an old build technique, so we can ignore this warning. @@ -76,8 +76,12 @@ void cos_init_delegate(void* data) { #ifdef UNIT_TESTS OS_printf("Beginning unit tests\n"); - /* Their method name is misleading -- this begins the unit tests, not application */ - OS_Application_Startup(); + Composite_UT_oscore(); + Composite_UT_osfile(); + Composite_UT_osfilesys(); + Composite_UT_osloader(); + Composite_UT_osnetwork(); + Composite_UT_ostimer(); OS_printf("End unit tests\n"); #endif From 69938ee4d344046f4486343c0e31e4a4f0dfdbe6 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Fri, 16 Jun 2017 15:01:09 -0400 Subject: [PATCH 043/122] Remove duplicated call to OS_API_Init, preventing a fault When running unit tests OS_API_Init was called twice, leading mem_info to be propogated twice. This lead to a fault when allocating after the second call, since the memory being allocated was already in use. This fix deduplicates calls to OS_API_Init (a preferable solution to changing the unit tests.) --- .../implementation/no_interface/cFE_booter/osapi.c | 13 +++++++++---- .../implementation/no_interface/cFE_booter/ostask.c | 6 ++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index a62cb0520b..c2549259aa 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -15,13 +15,18 @@ /* ** Initialization of API */ +int have_initialized = 0; + int32 OS_API_Init(void) { - struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); - struct cos_compinfo *ci = cos_compinfo_get(defci); + if(!have_initialized) { + struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); + struct cos_compinfo *ci = cos_compinfo_get(defci); - cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); - cos_defcompinfo_init(); + cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); + cos_defcompinfo_init(); + have_initialized = 1; + } return OS_SUCCESS; } diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 1e45e1ba68..8cfe0cbc77 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -62,7 +62,7 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, { sl_cs_enter(); - if(task_name == NULL || stack_pointer == NULL){ + if(task_id == NULL || task_name == NULL || stack_pointer == NULL){ return OS_INVALID_POINTER; } @@ -80,6 +80,7 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, } struct sl_thd* thd = sl_thd_alloc(osal_task_entry_wrapper, function_pointer); + assert(thd); union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = priority}}; sl_thd_param_set(thd, sp.v); @@ -153,7 +154,8 @@ int32 OS_TaskDelay(uint32 millisecond) cycles_t start_time = sl_now(); while(sl_cyc2usec(sl_now() - start_time) / 1000 < millisecond) { - sl_thd_yield(0); + // FIXME: This is broken, busy loop for now + // sl_thd_yield(0); } return OS_SUCCESS; } From 30ea6b6efa1481c630ec4220c239c47f5ee4d0af Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 19 Jun 2017 13:55:33 -0400 Subject: [PATCH 044/122] Fix crashing task unit tests --- .../no_interface/cFE_booter/ostask.c | 40 ++++++++++++++----- .../no_interface/cFE_booter/sl.h | 4 +- src/kernel/include/shared/consts.h | 4 +- src/kernel/include/thd.h | 7 ++-- 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 8cfe0cbc77..942615e88d 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -52,6 +52,7 @@ int is_name_taken(const char* name) { /* ** Task API */ +// Necessary to control the number of created tasks // TODO: Implement flags int32 OS_TaskCreate(uint32 *task_id, const char *task_name, @@ -60,23 +61,29 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, uint32 stack_size, uint32 priority, uint32 flags) { + int32 result = OS_SUCCESS; + sl_cs_enter(); if(task_id == NULL || task_name == NULL || stack_pointer == NULL){ - return OS_INVALID_POINTER; + result = OS_INVALID_POINTER; + goto exit; } // Validate the name if(!is_valid_name(task_name)) { - return OS_ERR_NAME_TOO_LONG; + result = OS_ERR_NAME_TOO_LONG; + goto exit; } if(is_name_taken(task_name)) { - return OS_ERR_NAME_TAKEN; + result = OS_ERR_NAME_TAKEN; + goto exit; } if(priority > 255 || priority < 1) { - return OS_ERR_INVALID_PRIORITY; + result = OS_ERR_INVALID_PRIORITY; + goto exit; } struct sl_thd* thd = sl_thd_alloc(osal_task_entry_wrapper, function_pointer); @@ -93,9 +100,9 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, *task_id = (uint32) thd->thdid; +exit: sl_cs_exit(); - - return OS_SUCCESS; + return result; } int32 OS_TaskDelete(uint32 task_id) @@ -162,6 +169,10 @@ int32 OS_TaskDelay(uint32 millisecond) int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) { + if(new_priority > 255 || new_priority < 1) { + return OS_ERR_INVALID_PRIORITY; + } + struct sl_thd* thd = sl_thd_lkup(task_id); if(!thd) { return OS_ERR_INVALID_ID; @@ -182,14 +193,25 @@ int32 OS_TaskRegister(void) int32 OS_TaskGetIdByName(uint32 *task_id, const char *task_name) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + // FIXME: Implement this. Left as is so unit tests pass + return OS_ERR_NOT_IMPLEMENTED; } int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) { + if(!task_prop) { + return OS_INVALID_POINTER; + } + + struct sl_thd* thd = sl_thd_lkup(task_id); + if (!thd) { + return OS_ERR_INVALID_ID; + } + struct sl_thd_policy* thd_policy = sl_mod_thd_policy_get(thd); + assert(thd_policy); + // TODO: Consider moving this sequence of calls to a helper function - *task_prop = sl_mod_thd_policy_get(sl_thd_lkup(task_id))->osal_task_prop; + *task_prop = thd_policy->osal_task_prop; return OS_SUCCESS; } diff --git a/src/components/implementation/no_interface/cFE_booter/sl.h b/src/components/implementation/no_interface/cFE_booter/sl.h index 13cb073291..e7f9dc33c1 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.h +++ b/src/components/implementation/no_interface/cFE_booter/sl.h @@ -74,7 +74,9 @@ sl_thd_setprio(struct sl_thd *t, tcap_prio_t p) static inline struct sl_thd * sl_thd_lkup(thdid_t tid) { - assert(tid < MAX_NUM_THREADS); + if (!(tid < MAX_NUM_THREADS)) { + return NULL; + } return sl_mod_thd_get(sl_thd_lookup_backend(tid)); } diff --git a/src/kernel/include/shared/consts.h b/src/kernel/include/shared/consts.h index 0df92f4754..05d490de5c 100644 --- a/src/kernel/include/shared/consts.h +++ b/src/kernel/include/shared/consts.h @@ -48,9 +48,9 @@ struct pt_regs { #endif #define MAX_SERVICE_DEPTH 31 -#define MAX_NUM_THREADS 64 +#define MAX_NUM_THREADS 128 /* Stacks are 2 * page_size (expressed in words) */ -#define MAX_STACK_SZ (PAGE_SIZE * 2) /* a page */ +#define MAX_STACK_SZ (PAGE_SIZE * 4) /* a page */ #define COS_STACK_SZ (MAX_STACK_SZ*4) #define ALL_STACK_SZ (MAX_NUM_THREADS*MAX_STACK_SZ) #define MAX_SPD_VAS_LOCATIONS 8 diff --git a/src/kernel/include/thd.h b/src/kernel/include/thd.h index 3dc8805b79..28a37d1539 100644 --- a/src/kernel/include/thd.h +++ b/src/kernel/include/thd.h @@ -121,7 +121,7 @@ static u32_t thdid_alloc(void) { /* FIXME: thd id address space management. */ - if (unlikely(free_thd_id >= MAX_NUM_THREADS)) assert(0); +// if (unlikely(free_thd_id >= MAX_NUM_THREADS)) assert(0); return cos_faa((int*)&free_thd_id, 1); } static void @@ -277,9 +277,8 @@ thd_activate(struct captbl *t, capid_t cap, capid_t capin, struct thread *thd, c thd->invstk[0].ip = thd->invstk[0].sp = 0; thd->tid = thdid_alloc(); thd->refcnt = 1; - thd->invstk_top = 0; + thd->invstk_top = 0; thd->cpuid = get_cpuid(); - assert(thd->tid <= MAX_NUM_THREADS); thd_rcvcap_init(thd); list_head_init(&thd->event_head); @@ -465,7 +464,7 @@ thd_preemption_state_update(struct thread *curr, struct thread *next, struct pt_ memcpy(&curr->regs, regs, sizeof(struct pt_regs)); } -static inline void +static inline void thd_rcvcap_pending_deliver(struct thread *thd, struct pt_regs *regs) { unsigned long a = 0, b = 0; int all_pending = thd_rcvcap_all_pending_get(thd); From fa71ced5f032415e30c1b50c5f2d4e78b9c98c15 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 19 Jun 2017 14:16:09 -0400 Subject: [PATCH 045/122] Add missing null guards to the LocalTime functions --- .../implementation/no_interface/cFE_booter/osapi.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index c2549259aa..3af5eb70d2 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -78,6 +78,10 @@ OS_time_t OS_AdvanceTime(OS_time_t initial_time, microsec_t usec) { int32 OS_GetLocalTime(OS_time_t *time_struct) { + if(!time_struct) { + return OS_INVALID_POINTER; + } + if(old_cycle_count == 0) { local_time = (OS_time_t) { .seconds = 1181683060, @@ -102,6 +106,10 @@ int32 OS_GetLocalTime(OS_time_t *time_struct) int32 OS_SetLocalTime(OS_time_t *time_struct) { + if(!time_struct) { + return OS_INVALID_POINTER; + } + local_time = *time_struct; old_cycle_count = sl_now(); @@ -263,8 +271,8 @@ int32 OS_ShMemGetIdByName(uint32 *ShMemId, const char *SegName ) */ int32 OS_HeapGetInfo(OS_heap_prop_t *heap_prop) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + // FIXME: Implement me! + return OS_ERR_NOT_IMPLEMENTED; } /* From 0d5c45edb426857ead9c6642ca0b8708f06dedb4 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 19 Jun 2017 17:20:55 -0400 Subject: [PATCH 046/122] Fix broken unit tests --- .../no_interface/cFE_booter/osapi.c | 36 ++++++++++++++++++- .../no_interface/cFE_booter/osqueue.c | 17 ++++++++- .../no_interface/cFE_booter/ostask.c | 34 ++++++++++++------ 3 files changed, 74 insertions(+), 13 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 3af5eb70d2..9054fd5318 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -38,7 +38,41 @@ int32 OS_API_Init(void) */ void OS_DeleteAllObjects(void) { - // It's safe for this method to do nothing for now + uint32 i; + + // FIXME: Add deleting tasks when we have a way of iterating through them + // for (i = 0; i < OS_MAX_TASKS; ++i) + // { + // OS_TaskDelete(i); + // } + for (i = 0; i < OS_MAX_QUEUES; ++i) + { + OS_QueueDelete(i); + } + for (i = 0; i < OS_MAX_MUTEXES; ++i) + { + OS_MutSemDelete(i); + } + for (i = 0; i < OS_MAX_COUNT_SEMAPHORES; ++i) + { + OS_CountSemDelete(i); + } + for (i = 0; i < OS_MAX_BIN_SEMAPHORES; ++i) + { + OS_BinSemDelete(i); + } + // for (i = 0; i < OS_MAX_TIMERS; ++i) + // { + // OS_TimerDelete(i); + // } + // for (i = 0; i < OS_MAX_MODULES; ++i) + // { + // OS_ModuleUnload(i); + // } + for (i = 0; i < OS_MAX_NUM_OPEN_FILES; ++i) + { + OS_close(i); + } } diff --git a/src/components/implementation/no_interface/cFE_booter/osqueue.c b/src/components/implementation/no_interface/cFE_booter/osqueue.c index 635754f541..681f26aa30 100644 --- a/src/components/implementation/no_interface/cFE_booter/osqueue.c +++ b/src/components/implementation/no_interface/cFE_booter/osqueue.c @@ -79,6 +79,9 @@ OS_QueueCreate(uint32* queue_id, const char* queue_name, uint32 queue_depth, uin int32 OS_QueueDelete(uint32 queue_id) { + if (queue_id > OS_MAX_QUEUES) { + return OS_ERR_INVALID_ID; + } /* Check if there is a queue to be deleted at the ID. */ if (queues[queue_id].free == TRUE) { return OS_ERR_INVALID_ID; @@ -100,6 +103,10 @@ OS_QueueDelete(uint32 queue_id) { int32 OS_QueueGet(uint32 queue_id, void* data, uint32 size, uint32* size_copied, int32 timeout) { + if (queue_id > OS_MAX_QUEUES) { + return OS_ERR_INVALID_ID; + } + uint32 i; /* Check if the requested queue exists. */ @@ -108,7 +115,7 @@ OS_QueueGet(uint32 queue_id, void* data, uint32 size, uint32* size_copied, int32 } /* Check for a NULL pointer. */ - if (data == NULL) { + if (data == NULL || size_copied == NULL) { return OS_INVALID_POINTER; } @@ -138,6 +145,10 @@ OS_QueueGet(uint32 queue_id, void* data, uint32 size, uint32* size_copied, int32 int32 OS_QueuePut(uint32 queue_id, const void* data, uint32 size, uint32 flags) { + if (queue_id > OS_MAX_QUEUES) { + return OS_ERR_INVALID_ID; + } + uint32 i; /* Check if the requested queue exists. */ @@ -202,6 +213,10 @@ OS_QueueGetIdByName(uint32* queue_id, const char* queue_name) int32 OS_QueueGetInfo(uint32 queue_id, OS_queue_prop_t* queue_prop) { + if (queue_id > OS_MAX_QUEUES) { + return OS_ERR_INVALID_ID; + } + if (queue_prop == NULL) { return OS_INVALID_POINTER; } diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 942615e88d..50096677c7 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -65,7 +65,7 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, sl_cs_enter(); - if(task_id == NULL || task_name == NULL || stack_pointer == NULL){ + if(task_id == NULL || task_name == NULL || stack_pointer == NULL || function_pointer == NULL){ result = OS_INVALID_POINTER; goto exit; } @@ -254,7 +254,7 @@ struct mutex { char name[OS_MAX_API_NAME]; }; -struct mutex mutexes[OS_MAX_BIN_SEMAPHORES]; +struct mutex mutexes[OS_MAX_MUTEXES]; int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) @@ -273,7 +273,14 @@ int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) goto exit; } - int id; + uint32 id; + for (id = 0; id < OS_MAX_MUTEXES; id++) { + if (mutexes[id].used && strcmp(sem_name, mutexes[id].name) == 0) { + result = OS_ERR_NAME_TAKEN; + goto exit; + } + } + for (id = 0; id < OS_MAX_MUTEXES; id++) { if(!mutexes[id].used) { break; @@ -284,6 +291,7 @@ int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) goto exit; } + *sem_id = id; mutexes[id].used = TRUE; mutexes[id].held = FALSE; mutexes[id].creator = sl_thd_curr()->thdid; @@ -408,6 +416,7 @@ int32 OS_MutSemGetIdByName(uint32 *sem_id, const char *sem_name) /* The name was not found in the table, * or it was, and the sem_id isn't valid anymore */ + result = OS_ERR_NAME_NOT_FOUND; exit: sl_cs_exit(); return result; @@ -477,6 +486,13 @@ int32 OS_SemaphoreCreate(struct semaphore* semaphores, uint32 max_semaphores, } uint32 id; + for (id = 0; id < max_semaphores; id++) { + if (semaphores[id].used && strcmp(sem_name, semaphores[id].name) == 0) { + result = OS_ERR_NAME_TAKEN; + goto exit; + } + } + for (id = 0; id < max_semaphores; id++) { if(!semaphores[id].used) { break; @@ -487,6 +503,7 @@ int32 OS_SemaphoreCreate(struct semaphore* semaphores, uint32 max_semaphores, goto exit; } + *sem_id = id; semaphores[id].used = TRUE; semaphores[id].creator = sl_thd_curr()->thdid; semaphores[id].count = sem_initial_value; @@ -556,7 +573,7 @@ int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint } sl_cs_exit(); // FIXME: Do an actually sensible yield here! - sl_thd_yield(0); + // sl_thd_yield(0); sl_cs_enter(); } @@ -592,7 +609,7 @@ int32 OS_SemaphoreTimedWait(struct semaphore* semaphores, uint32 max_semaphores, && sl_cyc2usec(sl_now() - start_cycles) < max_wait) { sl_cs_exit(); // FIXME: Do an actually sensible yield here! - sl_thd_yield(0); + // sl_thd_yield(0); sl_cs_enter(); } @@ -625,12 +642,6 @@ int32 OS_SemaphoreDelete(struct semaphore* semaphores, uint32 max_semaphores, goto exit; } - // FIXME: Add smarter checking than this - if (semaphores[sem_id].count == 0) { - result = OS_SEM_FAILURE; - goto exit; - } - semaphores[sem_id].used = FALSE; exit: @@ -666,6 +677,7 @@ int32 OS_SemaphoreGetIdByName(struct semaphore* semaphores, uint32 max_semaphore /* The name was not found in the table, * or it was, and the sem_id isn't valid anymore */ + result = OS_ERR_NAME_NOT_FOUND; exit: sl_cs_exit(); return result; From a6f3148d0575df4f914f7c6f04ff06c6b5c5c371 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 20 Jun 2017 14:43:14 -0400 Subject: [PATCH 047/122] Insert missing id bounds checks in Semaphore creation methods --- .../implementation/no_interface/cFE_booter/ostask.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 50096677c7..4b01b556b3 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -286,7 +286,7 @@ int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) break; } } - if (mutexes[id].used) { + if (id >= OS_MAX_MUTEXES || mutexes[id].used) { result = OS_ERR_NO_FREE_IDS; goto exit; } @@ -473,6 +473,7 @@ int32 OS_SemaphoreCreate(struct semaphore* semaphores, uint32 max_semaphores, uint32 sem_initial_value, uint32 options) { int32 result = OS_SUCCESS; + sl_cs_enter(); if (sem_id == NULL || sem_name == NULL) { @@ -498,7 +499,8 @@ int32 OS_SemaphoreCreate(struct semaphore* semaphores, uint32 max_semaphores, break; } } - if (semaphores[id].used) { + + if (id >= max_semaphores || semaphores[id].used) { result = OS_ERR_NO_FREE_IDS; goto exit; } From f35295261ce41032c897f5fafeb812dbe51a4ec6 Mon Sep 17 00:00:00 2001 From: Zach Day Date: Tue, 20 Jun 2017 16:08:58 -0400 Subject: [PATCH 048/122] Add `INVALID_SIZE` fail case to `OS_QueueGet`. `OS_QueueGet` now returns `OS_QUEUE_INVALID_SIZE` if the requested data size is below the element size of the queue. `OS_QueueGet` still does not pass the timeout test, as timeout checking cannot be implemented due to threading concerns until we have a more robust mutex implementation. `osqueue.c` has also been updated to use the double-slash single-line comment style instead of block style. --- .../no_interface/cFE_booter/osqueue.c | 74 ++++++++++--------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osqueue.c b/src/components/implementation/no_interface/cFE_booter/osqueue.c index 681f26aa30..73a599a0da 100644 --- a/src/components/implementation/no_interface/cFE_booter/osqueue.c +++ b/src/components/implementation/no_interface/cFE_booter/osqueue.c @@ -7,28 +7,28 @@ #define MAX_QUEUE_DATA_SIZE (1024 * 1024) -/* The main queue data structure. */ +// The main queue data structure. struct queue { - /* Whether or not the index of this queue is already taken. */ + // Whether or not the index of this queue is already taken. int32 free; - /* The number of elements allowed in the queue. */ - int32 depth; + // The number of elements allowed in the queue. + uint32 depth; - /* The size, in bytes, of each element in the queue. */ - int32 data_size; + // The size, in bytes, of each element in the queue. + uint32 data_size; - /* The name of the queue. For display purposes only. */ + // The name of the queue. For display purposes only. char name[OS_MAX_API_NAME]; uint32 head; uint32 tail; }; -/* The global queue bank. */ +// The global queue bank. struct queue queues[OS_MAX_QUEUES]; -/* The bank of data that queues have access to. */ +// The bank of data that queues have access to. char queue_data[OS_MAX_QUEUES][MAX_QUEUE_DATA_SIZE]; int32 @@ -37,36 +37,36 @@ OS_QueueCreate(uint32* queue_id, const char* queue_name, uint32 queue_depth, uin int32 i; uint32 qid; - /* Check validity of parameters. */ + // Check validity of parameters. if (queue_id == NULL || queue_name == NULL) { return OS_INVALID_POINTER; } - /* Check name length. */ + // Check name length. if (strlen(queue_name) >= OS_MAX_API_NAME) { return OS_ERR_NAME_TOO_LONG; } - /* Check to see if the name is already taken. */ + // Check to see if the name is already taken. for (i = 0 ; i < OS_MAX_QUEUES ; i++) { if ((queues[i].free == FALSE) && strcmp((char*)queue_name, queues[i].name) == 0) { return OS_ERR_NAME_TAKEN; } } - /* Calculate the queue ID. */ + // Calculate the queue ID. for (qid = 0 ; qid < OS_MAX_QUEUES ; qid++) { if (queues[qid].free == TRUE) { break; } } - /* Fail if there are too many queues. */ + // Fail if there are too many queues. if (qid >= OS_MAX_QUEUES || queues[qid].free != TRUE) { return OS_ERR_NO_FREE_IDS; } - /* OS_ERROR may also be returned in the event that an OS call fails, but none are used here. */ + // OS_ERROR may also be returned in the event that an OS call fails, but none are used here. *queue_id = qid; queues[*queue_id].free = FALSE; @@ -82,12 +82,12 @@ OS_QueueDelete(uint32 queue_id) { if (queue_id > OS_MAX_QUEUES) { return OS_ERR_INVALID_ID; } - /* Check if there is a queue to be deleted at the ID. */ + // Check if there is a queue to be deleted at the ID. if (queues[queue_id].free == TRUE) { return OS_ERR_INVALID_ID; } - /* Reset all values in the queue. */ + // Reset all values in the queue. queues[queue_id].free = TRUE; queues[queue_id].depth = 0; queues[queue_id].data_size = 0; @@ -95,7 +95,7 @@ OS_QueueDelete(uint32 queue_id) { queues[queue_id].head = 0; queues[queue_id].tail = 0; - /* OS_ERROR may also be returned in the event that an OS call fails, but none are used here. */ + // OS_ERROR may also be returned in the event that an OS call fails, but none are used here. return OS_SUCCESS; } @@ -103,36 +103,38 @@ OS_QueueDelete(uint32 queue_id) { int32 OS_QueueGet(uint32 queue_id, void* data, uint32 size, uint32* size_copied, int32 timeout) { - if (queue_id > OS_MAX_QUEUES) { - return OS_ERR_INVALID_ID; - } - uint32 i; - /* Check if the requested queue exists. */ - if (queues[queue_id].free == TRUE) { + // Check if the requested queue exists. + if (queue_id > OS_MAX_QUEUES || queues[queue_id].free == TRUE) { return OS_ERR_INVALID_ID; } - /* Check for a NULL pointer. */ + // Check for a NULL pointer. if (data == NULL || size_copied == NULL) { return OS_INVALID_POINTER; } - /* Check if there are messages to be received. */ + // Check if there are messages to be received. if (queues[queue_id].head == queues[queue_id].tail) { return OS_QUEUE_EMPTY; } - /* A helper reference to the currently selected queue. */ + // TODO: Implement logic for returning OS_QUEUE_TIMEOUT (waiting on mutex implementation). + + if (size < queues[queue_id].data_size) { + return OS_QUEUE_INVALID_SIZE; + } + + // A helper reference to the currently selected queue. struct queue* cur = &queues[queue_id]; - /* Walk through the bytes at the head of the queue and write them to buffer `data`. */ + // Walk through the bytes at the head of the queue and write them to buffer `data`. for (i = 0; i < size; i++) { *((char*)data + i) = queue_data[queue_id][cur->head * cur->data_size + i]; } - /* Advance the queue head, wrapping if it is passed `depth`. */ + // Advance the queue head, wrapping if it is passed `depth`. cur->head = (cur->head + 1) % cur->depth; return OS_SUCCESS; @@ -151,30 +153,30 @@ OS_QueuePut(uint32 queue_id, const void* data, uint32 size, uint32 flags) uint32 i; - /* Check if the requested queue exists. */ + // Check if the requested queue exists. if (queues[queue_id].free == TRUE) { return OS_ERR_INVALID_ID; } - /* Check for invalid pointers. */ + // Check for invalid pointers. if (data == NULL) { return OS_INVALID_POINTER; } - /* Check if space remains in the queue. */ + // Check if space remains in the queue. if ((queues[queue_id].tail + 1) % queues[queue_id].depth == queues[queue_id].head) { return OS_QUEUE_FULL; } - /* A helper pointer to the currently selected queue. */ + // A helper pointer to the currently selected queue. struct queue* cur = &queues[queue_id]; - /* Walk through the bytes in `data` and write them to the tail of the specified queue. */ + // Walk through the bytes in `data` and write them to the tail of the specified queue. for (i = 0 ; i < size ; i++) { queue_data[queue_id][cur->tail * cur->data_size + i] = *((char*)data + i); } - /* Advance the queue tail, wrapping if it is past `depth`. */ + // Advance the queue tail, wrapping if it is past `depth`. cur->tail = (cur->tail + 1) % cur->depth; return OS_SUCCESS; @@ -225,7 +227,7 @@ OS_QueueGetInfo(uint32 queue_id, OS_queue_prop_t* queue_prop) return OS_ERR_INVALID_ID; } - /* TODO: Identify creator; `0` is a dummy value. */ + // TODO: Identify creator; `0` is a dummy value. queue_prop->creator = 0; strcpy(queue_prop->name, queues[queue_id].name); From f9f0c75aaa7e9d5d68870672d37e16f3400164ab Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 20 Jun 2017 17:14:41 -0400 Subject: [PATCH 049/122] Add some saftey asserts to sl --- src/components/implementation/no_interface/cFE_booter/sl.h | 2 ++ .../implementation/no_interface/cFE_booter/sl_mod_fprr.c | 1 + src/kernel/include/shared/consts.h | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/implementation/no_interface/cFE_booter/sl.h b/src/components/implementation/no_interface/cFE_booter/sl.h index e7f9dc33c1..2211c14e5a 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.h +++ b/src/components/implementation/no_interface/cFE_booter/sl.h @@ -74,6 +74,7 @@ sl_thd_setprio(struct sl_thd *t, tcap_prio_t p) static inline struct sl_thd * sl_thd_lkup(thdid_t tid) { + assert(tid != 0); if (!(tid < MAX_NUM_THREADS)) { return NULL; } @@ -84,6 +85,7 @@ static inline struct sl_thd * sl_thd_curr(void) { thdid_t tid = cos_thdid(); + assert(tid != 0); assert(tid < MAX_NUM_THREADS); return sl_thd_lkup(tid); } diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c index 0f5ebe80e0..e9340c8aac 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c +++ b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c @@ -48,6 +48,7 @@ sl_mod_wakeup(struct sl_thd_policy *t) void sl_mod_yield(struct sl_thd_policy *t, struct sl_thd_policy *yield_to) { + assert(t); assert(t->priority <= SL_FPRR_LOWEST); ps_list_rem_d(t); diff --git a/src/kernel/include/shared/consts.h b/src/kernel/include/shared/consts.h index 05d490de5c..97cd591a91 100644 --- a/src/kernel/include/shared/consts.h +++ b/src/kernel/include/shared/consts.h @@ -50,7 +50,7 @@ struct pt_regs { #define MAX_SERVICE_DEPTH 31 #define MAX_NUM_THREADS 128 /* Stacks are 2 * page_size (expressed in words) */ -#define MAX_STACK_SZ (PAGE_SIZE * 4) /* a page */ +#define MAX_STACK_SZ (PAGE_SIZE / 2) /* a page */ #define COS_STACK_SZ (MAX_STACK_SZ*4) #define ALL_STACK_SZ (MAX_NUM_THREADS*MAX_STACK_SZ) #define MAX_SPD_VAS_LOCATIONS 8 From 298660c463ac71d59b2d677abbad577d1170d5cc Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 26 Jun 2017 14:03:34 -0400 Subject: [PATCH 050/122] Bring in shared implementations of many of the psp routines Doing it this way we don't have to duplicate code --- .../no_interface/cFE_booter/cfe_psp_eeprom.c | 352 ++++++++++++++++++ .../cFE_booter/cfe_psp_memrange.c | 309 +++++++++++++++ .../no_interface/cFE_booter/cfe_psp_memtab.c | 46 +++ .../cFE_booter/cfe_psp_memutils.c | 94 +++++ .../no_interface/cFE_booter/cfe_psp_port.c | 232 ++++++++++++ .../no_interface/cFE_booter/cfe_psp_ram.c | 228 ++++++++++++ .../no_interface/cFE_booter/psp.c | 246 +++--------- 7 files changed, 1322 insertions(+), 185 deletions(-) create mode 100644 src/components/implementation/no_interface/cFE_booter/cfe_psp_eeprom.c create mode 100644 src/components/implementation/no_interface/cFE_booter/cfe_psp_memrange.c create mode 100644 src/components/implementation/no_interface/cFE_booter/cfe_psp_memtab.c create mode 100644 src/components/implementation/no_interface/cFE_booter/cfe_psp_memutils.c create mode 100644 src/components/implementation/no_interface/cFE_booter/cfe_psp_port.c create mode 100644 src/components/implementation/no_interface/cFE_booter/cfe_psp_ram.c diff --git a/src/components/implementation/no_interface/cFE_booter/cfe_psp_eeprom.c b/src/components/implementation/no_interface/cFE_booter/cfe_psp_eeprom.c new file mode 100644 index 0000000000..29692c8ee0 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/cfe_psp_eeprom.c @@ -0,0 +1,352 @@ +/* +** File : cfe_psp_eeprom.c +** +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Author : Ezra Yeheskeli +** +** Purpose: +** This file contains some of the OS APIs abstraction layer. +** It contains the processor architecture specific calls. +** +** 16-Nov-2003 Ezra Yeheskeli +** - First Creation. +** +*/ + +/* +** Include section +*/ +#include + +#include "gen/cfe_psp.h" + +/* +** global memory +*/ + +/* + ** Name: CFE_PSP_EepromWrite32 + ** + ** Purpose: + ** + ** Assumptions and Notes: + ** + ** Parameters: + ** + ** Global Inputs: None + ** + ** Global Outputs: None + ** + ** + ** Return Values: + ** CFE_PSP_SUCCESS + ** CFE_PSP_ERROR_TIMEOUT write operation did not go through after a specific + ** timeout. + ** CFE_PSP_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit addressing + ** scheme. + */ +int32 CFE_PSP_EepromWrite32( cpuaddr MemoryAddress, uint32 uint32Value ) +{ + uint32 ret_value = CFE_PSP_SUCCESS; + + /* check 32 bit alignment */ + if( MemoryAddress & 0x00000003) + { + return(CFE_PSP_ERROR_ADDRESS_MISALIGNED) ; + } + + /* make the Write */ + *((uint32 *)MemoryAddress) = uint32Value; + + return(ret_value) ; +} + +/* + ** Name: CFE_PSP_EepromWrite16 + ** + ** Purpose: + ** + ** Assumptions and Notes: + ** + ** Parameters: + ** + ** Global Inputs: None + ** + ** Global Outputs: None + ** + ** + ** Return Values: + ** CFE_PSP_SUCCESS + ** CFE_PSP_ERROR_TIMEOUT write operation did not go through after a specific + ** timeout. + ** CFE_PSP_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit addressing + ** scheme. + */ +int32 CFE_PSP_EepromWrite16( cpuaddr MemoryAddress, uint16 uint16Value ) +{ + uint32 write32; + uint32 temp32; + uint32 aligned_address ; + + /* + ** check 16 bit alignment , check the 1st lsb + */ + if( MemoryAddress & 0x00000001) + { + return(CFE_PSP_ERROR_ADDRESS_MISALIGNED) ; + } + + temp32 = uint16Value ; + +#ifdef SOFTWARE_LITTLE_BIT_ORDER + /* + ** Implementation for Little Endian architectures ( x86 ) + */ + + /* + ** check the 2nd lsb to see if it's the 1st or 2nd 16 bit word + */ + if( (MemoryAddress & 0x00000002) ) + { + /* + ** writing the 16 high bit order of 32 bit field + */ + aligned_address = MemoryAddress - 2 ; + CFE_PSP_MemRead32 ( aligned_address ,&write32) ; + write32 = (write32 & 0x0000FFFF) | (temp32 << 16 ) ; + } + else + { + /* + ** writing the 16 low bit order of 32 bit field + */ + aligned_address = MemoryAddress; + CFE_PSP_MemRead32 ( aligned_address, &write32 ) ; + write32 = ( write32 & 0xFFFF0000 ) | ( temp32 ); + + } + +#else + + /* + ** Implementation for Big Endian architectures (PPC, Coldfire ) + */ + /* + ** check the 2nd lsb to see if it's the 1st or 2nd 16 bit word + */ + if( (MemoryAddress & 0x00000002) ) + { + /* + ** writing the 16 high bit order of 32 bit field + */ + aligned_address = MemoryAddress - 2 ; + CFE_PSP_MemRead32 ( aligned_address ,&write32) ; + write32 = (write32 & 0xFFFF0000) | (temp32) ; + } + else + { + /* + ** writing the 16 low bit order of 32 bit field + */ + aligned_address = MemoryAddress; + CFE_PSP_MemRead32 ( aligned_address, &write32 ) ; + write32 = ( write32 & 0x0000FFFF ) | ( temp32 << 16 ); + + } +#endif + + return(CFE_PSP_EepromWrite32(aligned_address,write32)) ; + +} + + +/* + ** Name: CFE_PSP_EepromWrite8 + ** + ** Purpose: + ** + ** Assumptions and Notes: + ** + ** Parameters: + ** + ** Global Inputs: None + ** + ** Global Outputs: None + ** + ** + ** Return Values: + ** CFE_PSP_SUCCESS + ** CFE_PSP_ERROR_TIMEOUT write operation did not go through after a specific + ** timeout. + */ + +int32 CFE_PSP_EepromWrite8( cpuaddr MemoryAddress, uint8 ByteValue ) +{ + uint32 aligned_address ; + uint16 write16 ,temp16; + + temp16 = ByteValue ; + + +#ifdef SOFTWARE_LITTLE_BIT_ORDER + /* + ** Implementation for Little Endian architectures ( x86 ) + */ + /* + ** check the 1st lsb + */ + if( MemoryAddress & 0x00000001) + { + /* + ** writing the 8 high bit order of 16 bit field + */ + aligned_address = MemoryAddress - 1; + CFE_PSP_MemRead16 ( aligned_address ,&write16) ; + write16 = (write16 & 0x00FF) | ( temp16 << 8) ; + } + else + { + /* + ** writing the 8 low bit order of 16 bit field + */ + aligned_address = MemoryAddress ; + CFE_PSP_MemRead16 ( aligned_address, &write16 ) ; + write16 = (temp16 ) | (write16 & 0xFF00 ) ; + } +#else + + /* + ** Implementation for Big Endian architectures (PPC, Coldfire ) + */ + + /* + ** check the 1st lsb + */ + if( MemoryAddress & 0x00000001) + { + /* + ** writing the 8 high bit order of 16 bit field + */ + aligned_address = MemoryAddress - 1; + CFE_PSP_MemRead16 ( aligned_address ,&write16) ; + write16 = (write16 & 0xFF00) | ( temp16) ; + } + else + { + /* + ** writing the 8 low bit order of 16 bit field + */ + aligned_address = MemoryAddress ; + CFE_PSP_MemRead16 ( aligned_address, &write16 ) ; + write16 = (temp16 << 8 ) | (write16 & 0x00FF ) ; + } + +#endif + + return(CFE_PSP_EepromWrite16(aligned_address,write16)) ; + +} + +/* +** Name: CFE_PSP_EepromWriteEnable +** +** Purpose: +** Eable the eeprom for write operation +** +** Assumptions and Notes: +** +** Parameters: +** Bank: Which bank of EEPROM +** +** Global Inputs: None +** +** Global Outputs: None +** +** +** Return Values: +** CFE_PSP_SUCCESS +*/ +int32 CFE_PSP_EepromWriteEnable(uint32 Bank) +{ + return(CFE_PSP_SUCCESS) ; +} + +/* +** Name: CFE_PSP_EepromWriteDisable +** +** Purpose: +** Disable the eeprom from write operation +** +** Assumptions and Notes: +** +** Parameters: +** Bank: Which bank of EEPROM +** +** Global Inputs: None +** +** Global Outputs: None +** +** +** Return Values: +** CFE_PSP_SUCCESS +*/ +int32 CFE_PSP_EepromWriteDisable(uint32 Bank) +{ + return(CFE_PSP_SUCCESS) ; +} + + +/* +** Name: CFE_PSP_EepromPowerUp +** +** Purpose: +** Power up the eeprom +** Assumptions and Notes: +** +** Parameters: +** Bank: Which bank of EEPROM +** +** Global Inputs: None +** +** Global Outputs: None +** +** +** Return Values: +** CFE_PSP_SUCCESS +*/ +int32 CFE_PSP_EepromPowerUp(uint32 Bank) +{ + return(CFE_PSP_SUCCESS) ; +} + + + +/* +** Name: CFE_PSP_EepromPowerDown +** +** Purpose: +** Power down the eeprom +** Assumptions and Notes: +** +** Parameters: +** Bank: Which bank of EEPROM +** +** Global Inputs: None +** +** Global Outputs: None +** +** +** Return Values: +** CFE_PSP_SUCCESS +*/ +int32 CFE_PSP_EepromPowerDown(uint32 Bank) +{ + return(CFE_PSP_SUCCESS) ; +} diff --git a/src/components/implementation/no_interface/cFE_booter/cfe_psp_memrange.c b/src/components/implementation/no_interface/cFE_booter/cfe_psp_memrange.c new file mode 100644 index 0000000000..d7143479c8 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/cfe_psp_memrange.c @@ -0,0 +1,309 @@ +/* +** File : cfe_psp_memrange.c +** +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Author : Alan Cudmore +** +** Purpose: +** This file contains the memory range functions for the cFE Platform Support Package. +** The memory range is a table of valid memory address ranges maintained by the cFE. +** +** +*/ + +/* +** Include section +*/ + +#include "cfe_psp.h" + +#ifdef _ENHANCED_BUILD_ + +/* + * The "extern" declaration for the MemRange table is in the configdata header + */ +#include "cfe_psp_configdata.h" + +#else + +/* +** The CFE_PSP_MemoryTable is defined in the BSP section: +** Example: arch/x86/pc/linux/bsp/CFE_PSP_memtab.c +** That is where the CPU and board specific memory ranges are known. +*/ +extern CFE_PSP_MemTable_t CFE_PSP_MemoryTable[CFE_PSP_MEM_TABLE_SIZE]; + +#endif + +/* +** Name: CFE_PSP_MemValidateRange +** +** Purpose: +** Validate the memory range and type using the global CFE_PSP_MemoryTable +** +** Assumptions and Notes: +** +** Parameters: +** Address -- A 32 bit starting address of the memory range +** Size -- A 32 bit size of the memory range ( Address + Size = End Address ) +** MemoryType -- The memory type to validate, including but not limited to: +** CFE_PSP_MEM_RAM, CFE_PSP_MEM_EEPROM, or CFE_PSP_MEM_ANY +** Any defined CFE_PSP_MEM_* enumeration can be specified +** +** Global Inputs: None +** +** Global Outputs: None +** +** Return Values: +** CFE_PSP_SUCCESS -- Memory range and type information is valid and can be used. +** CFE_PSP_INVALID_MEM_ADDR -- Starting address is not valid +** CFE_PSP_INVALID_MEM_TYPE -- Memory type associated with the range does not match the passed in type. +** CFE_PSP_INVALID_MEM_RANGE -- The Memory range associated with the address is not large enough to contain +** Address + Size. +*/ +int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType) +{ + cpuaddr StartAddressToTest = Address; + cpuaddr EndAddressToTest = Address + Size - 1; + cpuaddr StartAddressInTable; + cpuaddr EndAddressInTable; + uint32 TypeInTable; + int32 ReturnCode = CFE_PSP_INVALID_MEM_ADDR; + uint32 i; + + /* + ** Before searching table, do a preliminary parameter validation + */ + if ( MemoryType != CFE_PSP_MEM_ANY && MemoryType != CFE_PSP_MEM_RAM && MemoryType != CFE_PSP_MEM_EEPROM ) + { + return(CFE_PSP_INVALID_MEM_TYPE); + } + + if ( EndAddressToTest < StartAddressToTest ) + { + return(CFE_PSP_INVALID_MEM_RANGE); + } + + for ( i = 0; i < CFE_PSP_MEM_TABLE_SIZE; i++ ) + { + /* + ** Only look at valid memory table entries + */ + if ( CFE_PSP_MemoryTable[i].MemoryType != CFE_PSP_MEM_INVALID ) + { + StartAddressInTable = CFE_PSP_MemoryTable[i].StartAddr; + EndAddressInTable = CFE_PSP_MemoryTable[i].StartAddr + CFE_PSP_MemoryTable[i].Size - 1; + TypeInTable = CFE_PSP_MemoryTable[i].MemoryType; + + /* + ** Step 1: Get the Address to Fit within the range + */ + if (( StartAddressToTest >= StartAddressInTable ) && ( StartAddressToTest <= EndAddressInTable )) + { + /* + ** Step 2: Does the End Address Fit within the Range? + ** should not have to test the lower address, + ** since the StartAddressToTest is already in the range. + ** Can it be fooled by overflowing the 32 bit int? + */ + if ( EndAddressToTest <= EndAddressInTable ) + { + /* + ** Step 3: Is the type OK? + */ + if ( MemoryType == CFE_PSP_MEM_ANY ) + { + ReturnCode = CFE_PSP_SUCCESS; + break; /* The range is valid, break out of the loop */ + } + else if ( MemoryType == CFE_PSP_MEM_RAM && TypeInTable == CFE_PSP_MEM_RAM ) + { + ReturnCode = CFE_PSP_SUCCESS; + break; /* The range is valid, break out of the loop */ + } + else if ( MemoryType == CFE_PSP_MEM_EEPROM && TypeInTable == CFE_PSP_MEM_EEPROM ) + { + ReturnCode = CFE_PSP_SUCCESS; + break; /* The range is valid, break out of the loop */ + } + else + { + ReturnCode = CFE_PSP_INVALID_MEM_TYPE; + /* The range is not valid, move to the next entry */ + } + } + else + { + ReturnCode = CFE_PSP_INVALID_MEM_RANGE; + /* The range is not valid, move to the next entry */ + } + } + else + { + ReturnCode = CFE_PSP_INVALID_MEM_ADDR; + /* The range is not valid, move to the next entry */ + } + } /* End if MemoryType != CFE_PSP_MEM_INVALID */ + + } /* End for */ + return(ReturnCode); +} + +/* +** Name: CFE_PSP_MemRanges +** +** Purpose: +** Return the number of memory ranges in the CFE_PSP_MemoryTable +** +** Assumptions and Notes: +** +** Parameters: +** None +** +** Global Inputs: None +** +** Global Outputs: None +** +** Return Values: +** Positive integer number of entries in the memory range table +*/ +uint32 CFE_PSP_MemRanges(void) +{ + return(CFE_PSP_MEM_TABLE_SIZE) ; +} + + +/* +** Name: CFE_PSP_MemRangeSet +** +** Purpose: +** This function populates one of the records in the CFE_PSP_MemoryTable. +** +** Assumptions and Notes: +** Because the table is fixed size, the entries are set by using the integer index. +** No validation is done with the address or size. +** +** Parameters: +** RangeNum -- A 32 bit integer ( starting with 0 ) specifying the MemoryTable entry. +** MemoryType -- The memory type to validate, including but not limited to: +** CFE_PSP_MEM_RAM, CFE_PSP_MEM_EEPROM, or CFE_PSP_MEM_ANY +** Any defined CFE_PSP_MEM_* enumeration can be specified +** Address -- A 32 bit starting address of the memory range +** Size -- A 32 bit size of the memory range ( Address + Size = End Address ) +** WordSize -- The minimum addressable size of the range: +** ( CFE_PSP_MEM_SIZE_BYTE, CFE_PSP_MEM_SIZE_WORD, CFE_PSP_MEM_SIZE_DWORD ) +** Attributes -- The attributes of the Memory Range: +** (CFE_PSP_MEM_ATTR_WRITE, CFE_PSP_MEM_ATTR_READ, CFE_PSP_MEM_ATTR_READWRITE) +** +** Global Inputs: Reads CFE_PSP_MemoryTable +** +** Global Outputs: Changes CFE_PSP_MemoryTable +** +** Return Values: +** CFE_PSP_SUCCESS -- Memory range set successfuly. +** CFE_PSP_INVALID_MEM_RANGE -- The index into the table is invalid +** CFE_PSP_INVALID_MEM_ADDR -- Starting address is not valid +** CFE_PSP_INVALID_MEM_TYPE -- Memory type associated with the range does not match the passed in type. +** OP_INVALID_MEM_SIZE -- The Memory range associated with the address is not large enough to contain +** Address + Size. +** CFE_PSP_INVALID_MEM_WORDSIZE -- The WordSIze parameter is not one of the predefined types. +** CFE_PSP_INVALID_MEM_ATTR -- The Attributes parameter is not one of the predefined types. +*/ +int32 CFE_PSP_MemRangeSet (uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, + uint32 Size, uint32 WordSize, uint32 Attributes) +{ + + if ( RangeNum >= CFE_PSP_MEM_TABLE_SIZE ) + { + return(CFE_PSP_INVALID_MEM_RANGE); + } + + if ( ( MemoryType != CFE_PSP_MEM_RAM ) && ( MemoryType != CFE_PSP_MEM_EEPROM ) ) + { + return(CFE_PSP_INVALID_MEM_TYPE); + } + + if ( ( WordSize != CFE_PSP_MEM_SIZE_BYTE ) && ( WordSize != CFE_PSP_MEM_SIZE_WORD ) && + ( WordSize != CFE_PSP_MEM_SIZE_DWORD ) ) + { + return(CFE_PSP_INVALID_MEM_WORDSIZE); + } + + if ( ( Attributes != CFE_PSP_MEM_ATTR_READ ) && ( Attributes != CFE_PSP_MEM_ATTR_WRITE ) && + ( Attributes != CFE_PSP_MEM_ATTR_READWRITE )) + { + return(CFE_PSP_INVALID_MEM_ATTR); + } + + /* + ** Parameters check out, add the range + */ + CFE_PSP_MemoryTable[RangeNum].MemoryType = MemoryType; + CFE_PSP_MemoryTable[RangeNum].StartAddr = StartAddr; + CFE_PSP_MemoryTable[RangeNum].Size = Size; + CFE_PSP_MemoryTable[RangeNum].WordSize = WordSize; + CFE_PSP_MemoryTable[RangeNum].Attributes = Attributes; + + return(CFE_PSP_SUCCESS) ; +} + +/* +** Name: CFE_PSP_MemRangeGet +** +** Purpose: +** This function retrieves one of the records in the CFE_PSP_MemoryTable. +** +** Assumptions and Notes: +** Becasue the table is fixed size, the entries are accessed by using the integer index. +** +** Parameters: +** RangeNum -- A 32 bit integer ( starting with 0 ) specifying the MemoryTable entry. +** *MemoryType -- A pointer to the 32 bit integer where the Memory Type is stored. +** Any defined CFE_PSP_MEM_* enumeration can be specified +** *Address -- A pointer to the 32 bit integer where the 32 bit starting address of the memory range +** is stored. +** *Size -- A pointer to the 32 bit integer where the 32 bit size of the memory range +** is stored. +** *WordSize -- A pointer to the 32 bit integer where the the minimum addressable size of the range: +** ( CFE_PSP_MEM_SIZE_BYTE, CFE_PSP_MEM_SIZE_WORD, CFE_PSP_MEM_SIZE_DWORD ) +** Attributes -- The attributes of the Memory Range: +** (CFE_PSP_MEM_ATTR_WRITE, CFE_PSP_MEM_ATTR_READ, CFE_PSP_MEM_ATTR_READWRITE) +** +** Global Inputs: Reads CFE_PSP_MemoryTable +** +** Global Outputs: Changes CFE_PSP_MemoryTable +** +** Return Values: +** CFE_PSP_SUCCESS -- Memory range returned successfuly. +** CFE_PSP_INVALID_POINTER -- Parameter error +** CFE_PSP_INVALID_MEM_RANGE -- The index into the table is invalid +*/ +int32 CFE_PSP_MemRangeGet (uint32 RangeNum, uint32 *MemoryType, cpuaddr *StartAddr, + uint32 *Size, uint32 *WordSize, uint32 *Attributes) +{ + + if ( MemoryType == NULL || StartAddr == NULL || Size == NULL || WordSize == NULL || Attributes == NULL ) + { + return(CFE_PSP_INVALID_POINTER); + } + + if ( RangeNum >= CFE_PSP_MEM_TABLE_SIZE ) + { + return(CFE_PSP_INVALID_MEM_RANGE); + } + + *MemoryType = CFE_PSP_MemoryTable[RangeNum].MemoryType; + *StartAddr = CFE_PSP_MemoryTable[RangeNum].StartAddr; + *Size = CFE_PSP_MemoryTable[RangeNum].Size; + *WordSize = CFE_PSP_MemoryTable[RangeNum].WordSize; + *Attributes = CFE_PSP_MemoryTable[RangeNum].Attributes; + + return(CFE_PSP_SUCCESS) ; +} diff --git a/src/components/implementation/no_interface/cFE_booter/cfe_psp_memtab.c b/src/components/implementation/no_interface/cFE_booter/cfe_psp_memtab.c new file mode 100644 index 0000000000..a6d4e0d1c5 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/cfe_psp_memtab.c @@ -0,0 +1,46 @@ +/* +** File : cfe_psp_memtab.c +** +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Author : Alan Cudmore +** +** Purpose: Memory Range Table for cFE/PSP. +** +** +*/ + +/* +** Includes +*/ + +#include "common_types.h" +#include "osapi.h" +#include "cfe_psp.h" +#include "cfe_psp_config.h" + + + +/* +** Valid memory map for this target. +** If you need to add more entries, increase CFE_PSP_MEM_TABLE_SIZE in the osconfig.h file. +*/ +CFE_PSP_MemTable_t CFE_PSP_MemoryTable[CFE_PSP_MEM_TABLE_SIZE] = +{ + { CFE_PSP_MEM_RAM, CFE_PSP_MEM_SIZE_DWORD, 0, 0xFFFFFFFF, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, +}; diff --git a/src/components/implementation/no_interface/cFE_booter/cfe_psp_memutils.c b/src/components/implementation/no_interface/cFE_booter/cfe_psp_memutils.c new file mode 100644 index 0000000000..6379c9c49a --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/cfe_psp_memutils.c @@ -0,0 +1,94 @@ +/* +** File : cfe_psp_memutils.c +** +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Author : Ezra Yeheskeli +** +** Purpose: +** This file contains some of the cFE Platform Support Layer. +** It contains the processor architecture specific calls. +** +** +*/ + +/* +** Include section +*/ + +#include + +/* +** User defined include files +*/ + +#include "cfe_psp.h" +/* +** global memory +*/ + +/* +** Name: CFE_PSP_MemCpy +** +** Purpose: +** Copies 'size' byte from memory address pointed by 'src' to memory +** address pointed by ' dst' For now we are using the standard c library +** call 'memcpy' but if we find we need to make it more efficient then +** we'll implement it in assembly. +** +** Assumptions and Notes: +** +** Parameters: +** dst : pointer to an address to copy to +** src : pointer address to copy from +** +** Global Inputs: None +** +** Global Outputs: None +** +** +** Return Values: CFE_PSP_SUCCESS +*/ +int32 CFE_PSP_MemCpy ( void *dst, void *src, uint32 size) +{ + memcpy( dst, src, size); + return(CFE_PSP_SUCCESS) ; +} + + + +/* +** Name: CFE_PSP_MemSet +** +** Purpose: +** Copies 'size' number of byte of value 'value' to memory address pointed +** by 'dst' .For now we are using the standard c library call 'memset' +** but if we find we need to make it more efficient then we'll implement +** it in assembly. +** +** +** Assumptions and Notes: +** +** Parameters: +** +** Global Inputs: None +** +** Global Outputs: None +** +** +** Return Values: CFE_PSP_SUCCESS +*/ +/* +** CFE_PSP_MemSet +*/ +int32 CFE_PSP_MemSet ( void *dst, uint8 value , uint32 size) +{ + memset( dst, (int)value, (size_t)size); + return(CFE_PSP_SUCCESS) ; +} diff --git a/src/components/implementation/no_interface/cFE_booter/cfe_psp_port.c b/src/components/implementation/no_interface/cFE_booter/cfe_psp_port.c new file mode 100644 index 0000000000..4e2a0eb9fd --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/cfe_psp_port.c @@ -0,0 +1,232 @@ +/* +** File : cfe_pep_memport.c +** +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Author : Ezra Yeheskeli +** +** Purpose: +** This file contains some of the cFE Platform Support Layer. +** It contains the processor architecture specific calls. +** +** 16-Nov-2003 Ezra Yeheskeli +** - First Creation. +** +*/ + +/* +** Include section +*/ + +#include "cfe_psp.h" + + +/* +** global memory +*/ + + + + +/* +** Name: CFE_PSP_PortRead8 +** +** Purpose: +** Read one byte of memory. +** +** +** Parameters: +** PortAddress : Address to be read +** ByteValue : The address content will be copied to the location pointed by +** this argument +** +** Global Inputs: None +** +** Global Outputs: None +** +** +** +** Return Values: CFE_PSP_SUCCESS +*/ +int32 CFE_PSP_PortRead8( cpuaddr PortAddress, uint8 *ByteValue ) +{ + + (*ByteValue) = (uint8)*((uint8 *)PortAddress) ; + + return(CFE_PSP_SUCCESS) ; +} + +/* +** Name: CFE_PSP_PortWrite8 +** +** Purpose: +** Write one byte of memory. +** +** +** Parameters: +** PortAddress : Address to be written to +** ByteValue : The content pointed by this argument will be copied to the +** address +** +** Global Inputs: None +** +** Global Outputs: None +** +** +** +** Return Values: +** CFE_PSP_SUCCESS +*/ +int32 CFE_PSP_PortWrite8 ( cpuaddr PortAddress, uint8 ByteValue ) +{ + *((uint8 *)PortAddress) = ByteValue; + return(CFE_PSP_SUCCESS) ; + +} + +/* +** Name: CFE_PSP_PortRead16 +** +** Purpose: +** Read 2 bytes of memory. +** +** +** Parameters: +** PortAddress : Address to be read +** uint16Value : The address content will be copied to the location pointed by +** this argument +** +** Global Inputs: None +** +** Global Outputs: None +** +** +** +** Return Values: +** CFE_PSP_SUCCESS +** CFE_PSP_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit +** addressing scheme. +*/ +int32 CFE_PSP_PortRead16( cpuaddr PortAddress, uint16 *uint16Value ) +{ + /* check 16 bit alignment , check the 1st lsb */ + if( PortAddress & 0x00000001) + { + return(CFE_PSP_ERROR_ADDRESS_MISALIGNED) ; + } + (*uint16Value) = *((uint16 *)PortAddress) ; + return(CFE_PSP_SUCCESS) ; + +} + + +/* +** Name: CFE_PSP_PortWrite16 +** +** Purpose: +** Write 2 byte of memory. +** +** +** Parameters: +** PortAddress : Address to be written to +** uint16Value : The content pointed by this argument will be copied to the +** address +** +** Global Inputs: None +** +** Global Outputs: None +** +** +** +** Return Values: +** CFE_PSP_SUCCESS +** CFE_PSP_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit +** addressing scheme. +*/ +int32 CFE_PSP_PortWrite16 ( cpuaddr PortAddress, uint16 uint16Value ) +{ + /* check 16 bit alignment , check the 1st lsb */ + if( PortAddress & 0x00000001) + { + return(CFE_PSP_ERROR_ADDRESS_MISALIGNED) ; + } + *((uint16 *)PortAddress) = uint16Value; + return(CFE_PSP_SUCCESS) ; +} + +/* +** Name: CFE_PSP_PortRead32 +** +** Purpose: +** Read 4 bytes of memory. +** +** +** Parameters: +** PortAddress : Address to be read +** uint32Value : The address content will be copied to the location pointed by +** this argument +** +** Global Inputs: None +** +** Global Outputs: None +** +** +** +** Return Values: +** CFE_PSP_SUCCESS +** CFE_PSP_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit +** addressing scheme. +*/ +int32 CFE_PSP_PortRead32( cpuaddr PortAddress, uint32 *uint32Value ) +{ + /* check 32 bit alignment */ + if( PortAddress & 0x00000003) + { + return(CFE_PSP_ERROR_ADDRESS_MISALIGNED) ; + } + (*uint32Value) = *((uint32 *)PortAddress) ; + return(CFE_PSP_SUCCESS) ; + +} + +/* +** Name: CFE_PSP_PortWrite32 +** +** Purpose: +** Write 4 byte of memory. +** +** +** Parameters: +** PortAddress : Address to be written to +** uint32Value : The content pointed by this argument will be copied to the +** address +** +** Global Inputs: None +** +** Global Outputs: None +** +** +** +** Return Values: +** CFE_PSP_SUCCESS +** CFE_PSP_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit +** addressing scheme. +*/ +int32 CFE_PSP_PortWrite32 ( cpuaddr PortAddress, uint32 uint32Value ) +{ + /* check 32 bit alignment */ + if( PortAddress & 0x00000003) + { + return(CFE_PSP_ERROR_ADDRESS_MISALIGNED) ; + } + *((uint32 *)PortAddress) = uint32Value; + return(CFE_PSP_SUCCESS) ; + +} + diff --git a/src/components/implementation/no_interface/cFE_booter/cfe_psp_ram.c b/src/components/implementation/no_interface/cFE_booter/cfe_psp_ram.c new file mode 100644 index 0000000000..b3be2991ac --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/cfe_psp_ram.c @@ -0,0 +1,228 @@ +/* +** File : cfe_psp_memram.c +** +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Author : Ezra Yeheskeli +** +** Purpose: +** This file contains some of the cFE Platform Support Layer. +** It contains the processor architecture specific calls. +** +** 16-Nov-2003 Ezra Yeheskeli +** - First Creation. +** +*/ + +/* +** Include section +*/ + +#include "cfe_psp.h" + + +/* +** global memory +*/ + +/* + ** Name: CFE_PSP_MemRead8 + ** + ** Purpose: + ** Read one byte of memory. + ** + ** + ** Parameters: + ** MemoryAddress : Address to be read + ** ByteValue : The address content will be copied to the location pointed by this argument + ** + ** Global Inputs: None + ** + ** Global Outputs: None + ** + ** + ** + ** Return Values: CFE_PSP_SUCCESS + */ +int32 CFE_PSP_MemRead8( cpuaddr MemoryAddress, uint8 *ByteValue ) +{ + + (*ByteValue) = *((uint8 *)MemoryAddress) ; + + return(CFE_PSP_SUCCESS) ; +} + +/* + ** Name: CFE_PSP_MemWrite8 + ** + ** Purpose: + ** Write one byte of memory. + ** + ** + ** Parameters: + ** MemoryAddress : Address to be written to + ** ByteValue : The content pointed by this argument will be copied to the address + ** + ** Global Inputs: None + ** + ** Global Outputs: None + ** + ** + ** + ** Return Values: + ** CFE_PSP_SUCCESS + */ +int32 CFE_PSP_MemWrite8 ( cpuaddr MemoryAddress, uint8 ByteValue ) +{ + *((uint8 *)MemoryAddress) = ByteValue; + return(CFE_PSP_SUCCESS) ; + +} + +/* + ** Name: CFE_PSP_MemRead16 + ** + ** Purpose: + ** Read 2 bytes of memory. + ** + ** + ** Parameters: + ** MemoryAddress : Address to be read + ** uint16Value : The address content will be copied to the location pointed by + ** this argument + ** + ** Global Inputs: None + ** + ** Global Outputs: None + ** + ** + ** + ** Return Values: + ** CFE_PSP_SUCCESS + ** CFE_PSP_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit + ** addressing scheme. + */ +int32 CFE_PSP_MemRead16( cpuaddr MemoryAddress, uint16 *uint16Value ) +{ + /* check 16 bit alignment , check the 1st lsb */ + if( MemoryAddress & 0x00000001) + { + return(CFE_PSP_ERROR_ADDRESS_MISALIGNED) ; + } + (*uint16Value) = *((uint16 *)MemoryAddress) ; + return(CFE_PSP_SUCCESS) ; + +} +/* + ** Name: CFE_PSP_MemWrite16 + ** + ** Purpose: + ** Write 2 byte of memory. + ** + ** + ** Parameters: + ** MemoryAddress : Address to be written to + ** uint16Value : The content pointed by this argument will be copied to the + ** address + ** + ** Global Inputs: None + ** + ** Global Outputs: None + ** + ** + ** + ** Return Values: + ** CFE_PSP_SUCCESS + ** CFE_PSP_ERROR_ADD_MISALIGNED The MemoryAddress is not aligned to 16 bit + ** addressing scheme. + */ +int32 CFE_PSP_MemWrite16 ( cpuaddr MemoryAddress, uint16 uint16Value ) +{ + /* check 16 bit alignment , check the 1st lsb */ + if( MemoryAddress & 0x00000001) + { + return(CFE_PSP_ERROR_ADDRESS_MISALIGNED) ; + } + *((uint16 *)MemoryAddress) = uint16Value; + return(CFE_PSP_SUCCESS) ; +} +/* + ** Name: CFE_PSP_MemRead32 + ** + ** Purpose: + ** Read 4 bytes of memory. + ** + ** + ** Parameters: + ** MemoryAddress : Address to be read + ** uint32Value : The address content will be copied to the location pointed by + ** this argument + ** + ** Global Inputs: None + ** + ** Global Outputs: None + ** + ** + ** + ** Return Values: + ** CFE_PSP_SUCCESS + ** CFE_PSP_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit + ** addressing scheme. + */ +int32 CFE_PSP_MemRead32( cpuaddr MemoryAddress, uint32 *uint32Value ) +{ + /* check 32 bit alignment */ + if( MemoryAddress & 0x00000003) + { + return(CFE_PSP_ERROR_ADDRESS_MISALIGNED) ; + } + (*uint32Value) = *((uint32 *)MemoryAddress) ; + + return(CFE_PSP_SUCCESS) ; +} + +/* + ** Name: CFE_PSP_MemWrite32 + ** + ** Purpose: + ** Write 4 byte of memory. + ** + ** + ** Parameters: + ** MemoryAddress : Address to be written to + ** uint32Value : The content pointed by this argument will be copied to the + ** address + ** + ** Global Inputs: None + ** + ** Global Outputs: None + ** + ** + ** + ** Return Values: + ** CFE_PSP_SUCCESS + ** CFE_PSP_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit + ** addressing scheme. + */ +int32 CFE_PSP_MemWrite32 ( cpuaddr MemoryAddress, uint32 uint32Value ) +{ + + /* check 32 bit alignment */ + if( MemoryAddress & 0x00000003) + { + return(CFE_PSP_ERROR_ADDRESS_MISALIGNED) ; + } + + *((uint32 *)MemoryAddress) = uint32Value; + + return(CFE_PSP_SUCCESS) ; +} + + + diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c index 90ec13db38..2aee2f80a9 100644 --- a/src/components/implementation/no_interface/cFE_booter/psp.c +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -8,6 +8,31 @@ #include "gen/osapi.h" #include "gen/cfe_psp.h" + +#ifdef _ENHANCED_BUILD_ + +#include + +/* + * Define the PSP-supported capacities to be the maximum allowed, + * (since the PC-linux PSP has the advantage of abundant disk space to hold this) + */ +#define CFE_PSP_CDS_SIZE (GLOBAL_CONFIGDATA.CfeConfig->CdsSize) +#define CFE_PSP_RESET_AREA_SIZE (GLOBAL_CONFIGDATA.CfeConfig->ResetAreaSize) +#define CFE_PSP_USER_RESERVED_SIZE (GLOBAL_CONFIGDATA.CfeConfig->UserReservedSize) + +#else + +#include "gen/cfe_es.h" /* For memory sizes */ +#include "gen/cfe_platform_cfg.h" /* for processor ID */ + +#define CFE_PSP_CDS_SIZE (CFE_ES_CDS_SIZE + 1024) +#define CFE_PSP_RESET_AREA_SIZE CFE_ES_RESET_AREA_SIZE +#define CFE_PSP_USER_RESERVED_SIZE CFE_ES_USER_RESERVED_SIZE + +#endif + + /* ** Function prototypes */ @@ -154,10 +179,15 @@ int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType) ** ( cleared ) on a Power On reset, and preserved during a processor reset. */ +char CDS_MEMORY[CFE_ES_CDS_SIZE]; + int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if (!SizeOfCDS) { + return CFE_PSP_ERROR; + } + *SizeOfCDS = CFE_ES_CDS_SIZE; + return CFE_PSP_SUCCESS; } /* ** CFE_PSP_GetCDSSize fetches the size of the OS Critical Data Store area. @@ -165,8 +195,13 @@ int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS) int32 CFE_PSP_WriteToCDS(void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumBytes) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if (!PtrToDataToWrite) { + return CFE_PSP_ERROR; + } + sl_cs_enter(); + memcpy(CDS_MEMORY + CDSOffset, PtrToDataToWrite, NumBytes); + sl_cs_exit(); + return CFE_PSP_SUCCESS; } /* ** CFE_PSP_WriteToCDS writes to the CDS Block. @@ -174,21 +209,29 @@ int32 CFE_PSP_WriteToCDS(void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumByt int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumBytes) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if (!PtrToDataToRead) { + return CFE_PSP_ERROR; + } + sl_cs_enter(); + memcpy(PtrToDataToRead, CDS_MEMORY + CDSOffset, NumBytes); + sl_cs_exit(); + return CFE_PSP_SUCCESS; } /* ** CFE_PSP_ReadFromCDS reads from the CDS Block */ -#define RESET_AREA_SIZE 132000 -char RESET_AREA[RESET_AREA_SIZE]; +// TODO: Make this dynamic based on constants +char RESET_AREA[CFE_PSP_CDS_SIZE]; int32 CFE_PSP_GetResetArea (cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) { + if (!PtrToResetArea || !SizeOfResetArea) { + return CFE_PSP_ERROR; + } *PtrToResetArea = (cpuaddr) RESET_AREA; - *SizeOfResetArea = RESET_AREA_SIZE; - return OS_SUCCESS; + *SizeOfResetArea = CFE_PSP_CDS_SIZE; + return CFE_PSP_SUCCESS; } /* ** CFE_PSP_GetResetArea returns the location and size of the ES Reset information area. @@ -209,21 +252,12 @@ int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk ) { - int32 return_code; - - if ( SizeOfVolDisk == NULL ) - { - return_code = CFE_PSP_ERROR; - } - else - { - *PtrToVolDisk = 0; - *SizeOfVolDisk = 0; - return_code = CFE_PSP_SUCCESS; - } - - return(return_code); - + if (!PtrToVolDisk || !SizeOfVolDisk) { + return CFE_PSP_ERROR; + } + *PtrToVolDisk = 0; + *SizeOfVolDisk = 0; + return CFE_PSP_SUCCESS; } /* ** CFE_PSP_GetVolatileDiskMem returns the location and size of the memory used for the cFE @@ -300,7 +334,8 @@ void CFE_PSP_WatchdogSet(uint32 WatchdogValue) void CFE_PSP_Panic(int32 ErrorCode) { - PANIC("Unimplemented method!"); // TODO: Implement me! + printc("Error code is %d\n", (int) ErrorCode); + PANIC("PANICKING!"); } /* ** CFE_PSP_Panic is called by the cFE Core startup code when it needs to abort the @@ -350,162 +385,3 @@ void CFE_PSP_SetDefaultExceptionEnvironment(void) ** Notes: The exception environment is local to each task Therefore this must be ** called for each task that that wants to do floating point and catch exceptions */ - - -/* -** I/O Port API -*/ -int32 CFE_PSP_PortRead8(cpuaddr PortAddress, uint8 *ByteValue) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_PortWrite8(cpuaddr PortAddress, uint8 ByteValue) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_PortRead16(cpuaddr PortAddress, uint16 *uint16Value) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_PortWrite16(cpuaddr PortAddress, uint16 uint16Value) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_PortRead32(cpuaddr PortAddress, uint32 *uint32Value) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_PortWrite32(cpuaddr PortAddress, uint32 uint32Value) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -/* -** Memory API -*/ -int32 CFE_PSP_MemRead8(cpuaddr MemoryAddress, uint8 *ByteValue) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_MemWrite8(cpuaddr MemoryAddress, uint8 ByteValue) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_MemRead16(cpuaddr MemoryAddress, uint16 *uint16Value) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_MemWrite16(cpuaddr MemoryAddress, uint16 uint16Value) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_MemRead32(cpuaddr MemoryAddress, uint32 *uint32Value) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_MemWrite32(cpuaddr MemoryAddress, uint32 uint32Value) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_MemCpy(void *dest, void *src, uint32 n) -{ - memcpy(dest, src, n); - return OS_SUCCESS; -} - -int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n) -{ - memset(dest, value, n); - return OS_SUCCESS; -} - -int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -uint32 CFE_PSP_MemRanges(void) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_MemRangeSet(uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, - uint32 Size, uint32 WordSize, uint32 Attributes) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_MemRangeGet (uint32 RangeNum, uint32 *MemoryType, cpuaddr *StartAddr, - uint32 *Size, uint32 *WordSize, uint32 *Attributes) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_EepromWrite8(cpuaddr MemoryAddress, uint8 ByteValue) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_EepromWrite16(cpuaddr MemoryAddress, uint16 uint16Value) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_EepromWrite32(cpuaddr MemoryAddress, uint32 uint32Value) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_EepromWriteEnable(uint32 Bank) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_EepromWriteDisable(uint32 Bank) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_EepromPowerUp(uint32 Bank) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} - -int32 CFE_PSP_EepromPowerDown(uint32 Bank) -{ - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} From 75e0315afda35102d4e498779ee4d758638fdd24 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 26 Jun 2017 18:09:16 -0400 Subject: [PATCH 051/122] Implement a bunch of psp routines, and add hacks to ostask --- .../no_interface/cFE_booter/cFE_entrypoint.c | 2 ++ .../no_interface/cFE_booter/cFE_util.c | 7 +++++++ .../no_interface/cFE_booter/cFE_util.h | 12 +++++++++-- .../no_interface/cFE_booter/ostask.c | 21 +++++++++---------- .../no_interface/cFE_booter/psp.c | 8 +++---- 5 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c index c4a8dc3b4a..d6e81939a7 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c @@ -137,6 +137,8 @@ void cos_init(void) { OS_printf("CFE_PSP: Starting the cFE with a POWER ON reset.\n"); } + CFE_PSP_SpacecraftId = args.SpacecraftId; + CFE_PSP_CpuId = args.CpuId; /* ** Initialize the OS API */ diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.c b/src/components/implementation/no_interface/cFE_booter/cFE_util.c index 0293c8df38..ef11ed4cdd 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.c @@ -6,6 +6,7 @@ #include #include +#include "gen/osapi.h" #include "cFE_util.h" void llprint(const char *s, int len) @@ -40,6 +41,12 @@ void panic_impl(const char* function, char* message){ assert(0); } +void print_with_error_name(char* message, int32 error) { + os_err_name_t local_name; + OS_GetErrorName(error, &local_name); + printc("%s, error %s\n", message, local_name); +} + void __isoc99_sscanf(void){ PANIC("__isoc99_sscanf not implemented!"); } diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.h b/src/components/implementation/no_interface/cFE_booter/cFE_util.h index 5510f243af..6aa50f8d69 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.h +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.h @@ -1,3 +1,6 @@ +#ifndef _cFE_util_ +#define _cFE_util_ + #include #include @@ -5,8 +8,11 @@ #include #include -#ifndef _cFE_util_ -#define _cFE_util_ +#include "gen/common_types.h" + +// These variables store the global SPACECRAFT_ID and CPU_ID +uint32 CFE_PSP_SpacecraftId; +uint32 CFE_PSP_CpuId; void llprint(const char *s, int len); @@ -19,6 +25,8 @@ int __attribute__((format(printf,1,2))) printc(char *fmt, ...); void panic_impl(const char* function, char* message); +void print_with_error_name(char* message, int32 error); + void __isoc99_sscanf(void); #endif diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 4b01b556b3..442054090d 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -16,7 +16,7 @@ void OS_SchedulerStart(cos_thd_fn_t main_delegate) { sl_init(); struct sl_thd* main_delegate_thread = sl_thd_alloc(main_delegate, NULL); - union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = 1}}; + union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = 255}}; sl_thd_param_set(main_delegate_thread, sp.v); sl_sched_loop(); @@ -65,7 +65,8 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, sl_cs_enter(); - if(task_id == NULL || task_name == NULL || stack_pointer == NULL || function_pointer == NULL){ + // Stack pointers can sometimes be null and that's ok for us + if(task_id == NULL || task_name == NULL || function_pointer == NULL){ result = OS_INVALID_POINTER; goto exit; } @@ -88,7 +89,7 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, struct sl_thd* thd = sl_thd_alloc(osal_task_entry_wrapper, function_pointer); assert(thd); - union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = priority}}; + union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = 255}}; sl_thd_param_set(thd, sp.v); struct sl_thd_policy* policy = sl_mod_thd_policy_get(thd); @@ -144,9 +145,7 @@ uint32 OS_TaskGetId(void) void OS_TaskExit(void) { - OS_TaskDelete(OS_TaskGetId()); - // TODO: Figure out if this is the right thing to do in case of failure - PANIC("Broken invariant, should be unreacheable!"); + return OS_ERR_NOT_IMPLEMENTED; } int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer) @@ -161,8 +160,8 @@ int32 OS_TaskDelay(uint32 millisecond) cycles_t start_time = sl_now(); while(sl_cyc2usec(sl_now() - start_time) / 1000 < millisecond) { - // FIXME: This is broken, busy loop for now - // sl_thd_yield(0); + // FIXME: Use an actual timeout once we have that + sl_thd_yield(0); } return OS_SUCCESS; } @@ -178,7 +177,7 @@ int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) return OS_ERR_INVALID_ID; } - union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = new_priority}}; + union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = 255}}; sl_thd_param_set(thd, sp.v); return OS_SUCCESS; @@ -575,7 +574,7 @@ int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint } sl_cs_exit(); // FIXME: Do an actually sensible yield here! - // sl_thd_yield(0); + sl_thd_yield(0); sl_cs_enter(); } @@ -611,7 +610,7 @@ int32 OS_SemaphoreTimedWait(struct semaphore* semaphores, uint32 max_semaphores, && sl_cyc2usec(sl_now() - start_cycles) < max_wait) { sl_cs_exit(); // FIXME: Do an actually sensible yield here! - // sl_thd_yield(0); + sl_thd_yield(0); sl_cs_enter(); } diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c index 2aee2f80a9..13d15b3e29 100644 --- a/src/components/implementation/no_interface/cFE_booter/psp.c +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -91,8 +91,7 @@ void CFE_PSP_FlushCaches(uint32 type, cpuaddr address, uint32 size); uint32 CFE_PSP_GetProcessorId(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return CFE_PSP_CpuId; } /* ** CFE_PSP_GetProcessorId returns the CPU ID as defined by the specific board @@ -102,8 +101,7 @@ uint32 CFE_PSP_GetProcessorId(void) uint32 CFE_PSP_GetSpacecraftId(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return CFE_PSP_SpacecraftId; } /* ** CFE_PSP_GetSpacecraftId retuns the Spacecraft ID (if any ) @@ -376,7 +374,7 @@ void CFE_PSP_AttachExceptions(void) void CFE_PSP_SetDefaultExceptionEnvironment(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + // TODO: Figure out if it is safe for us to just do nothing here } /* ** From ba87ec984079173ee16803043720f2872d2264dd Mon Sep 17 00:00:00 2001 From: Zach Day Date: Mon, 26 Jun 2017 18:10:02 -0400 Subject: [PATCH 052/122] Add error checking to OSAL methods in `osloader.c` Bailing out of the OSLoader methods with `PANIC` prevented unit tests from proceeding. The OSLoader methods now implement checking for the OSAL-defined fail states. Note that this commit does not add any actual loading functionality. --- .../no_interface/cFE_booter/osloader.c | 111 ++++++++++++++++-- 1 file changed, 99 insertions(+), 12 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index 4c0a962fb6..fbe01260b8 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -3,41 +3,128 @@ #include "gen/osapi.h" #include "gen/common_types.h" +struct module_internal_record { + int free; + cpuaddr entry_point; + uint32 host_module_id; + char filename[OS_MAX_PATH_LEN]; + char name[OS_MAX_API_NAME]; +}; + +struct module_internal_record module_table[OS_MAX_MODULES]; + /* ** Loader API */ int32 OS_ModuleTableInit(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + uint32 i; + + for (i = 0; i < OS_MAX_MODULES; i++) { + module_table[i].free = TRUE; + module_table[i].entry_point = 0; + module_table[i].host_module_id = 0; + module_table[i].addr.valid = FALSE; + strcpy(module_table[i].name, ""); + strcpy(module_table[i].filename, ""); + } + + /* TODO: Module table mutex. */ + + return OS_ERR_NOT_IMPLEMENTED; } int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + /* Check parameters. */ + if (symbol_address == NULL || symbol_name == NULL) { + return OS_INVALID_POINTER; + } + + /* TODO: Look up entrypoint. */ + + return OS_ERR_NOT_IMPLEMENTED; } int32 OS_SymbolTableDump(const char *filename, uint32 size_limit) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + /* Not needed. */ + return OS_ERR_NOT_IMPLEMENTED; } int32 OS_ModuleLoad(uint32 *module_id, const char *module_name, const char *filename) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + uint32 i; + uint32 possible_id; + char translated_path[OS_MAX_PATH_LEN]; + + /* Check parameters. */ + if (module_id == NULL || module_name == NULL || filename == NULL) { + return OS_INVALID_POINTER; + } + + /* Find a free id. */ + for (possible_id = 0; possible_id < OS_MAX_MODULES; possible_id++) { + if (module_table[possible_id].free == TRUE) break; + } + + /* Check bounds of that id. */ + if (possible_id >= OS_MAX_MODULES || module_table[possible_id].free == FALSE) { + return OS_ERR_NO_FREE_IDS; + } + + /* Check if the module was already loaded. */ + for (i = 0; i < OS_MAX_MODULES; i++) { + if (module_table[i].free == FALSE && strcmp(module_name, module_table[i].name) == 0) { + return OS_ERR_NAME_TAKEN; + } + } + + /* Claim the module id. */ + module_table[possible_id].free = FALSE; + + /* Translate the filename. */ + int32 return_code = OS_TranslatePath(filename, (char *)translated_path); + if (return_code != OS_SUCCESS) { + module_table[possible_id].free = TRUE; + return return_code; + } + + /* TODO: Load the module. */ + + return OS_ERR_NOT_IMPLEMENTED; } int32 OS_ModuleUnload(uint32 module_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + /* Check the given id. */ + if (module_id >= OS_MAX_MODULES || module_table[module_id].free == TRUE) { + return OS_ERR_INVALID_ID; + } + + /* TODO: Unload module. */ + + module_table[module_id].free = TRUE; + + return OS_ERR_NOT_IMPLEMENTED; } int32 OS_ModuleInfo(uint32 module_id, OS_module_prop_t *module_info) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if (module_info == NULL) { + return OS_INVALID_POINTER; + } + + if (module_id >= OS_MAX_MODULES || module_table[module_id].free == TRUE) { + return OS_ERR_INVALID_ID; + } + + module_info->entry_point = module_table[module_id].entry_point; + module_info->host_module_id = module_table[module_id].host_module_id; + strncpy(module_info->filename, module_table[module_id].filename); + strncpy(module_info->name, module_info[module_id].name); + + /* TODO: Address info? */ + + return OS_ERR_NOT_IMPLEMENTED; } From b3f3e7835a5de865757e132719ba69e71839e76b Mon Sep 17 00:00:00 2001 From: Zach Day Date: Mon, 26 Jun 2017 18:20:22 -0400 Subject: [PATCH 053/122] Fix incorrect number of arguments in `strncpy`. This commit also fixes a warning regarding returning an error message in a void function in `ostask`. --- .../implementation/no_interface/cFE_booter/osloader.c | 5 ++--- .../implementation/no_interface/cFE_booter/ostask.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index fbe01260b8..b5b20f40b6 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -24,7 +24,6 @@ int32 OS_ModuleTableInit(void) module_table[i].free = TRUE; module_table[i].entry_point = 0; module_table[i].host_module_id = 0; - module_table[i].addr.valid = FALSE; strcpy(module_table[i].name, ""); strcpy(module_table[i].filename, ""); } @@ -121,8 +120,8 @@ int32 OS_ModuleInfo(uint32 module_id, OS_module_prop_t *module_info) module_info->entry_point = module_table[module_id].entry_point; module_info->host_module_id = module_table[module_id].host_module_id; - strncpy(module_info->filename, module_table[module_id].filename); - strncpy(module_info->name, module_info[module_id].name); + strncpy(module_info->filename, module_table[module_id].filename, OS_MAX_API_NAME); + strncpy(module_info->name, module_info[module_id].name, OS_MAX_API_NAME); /* TODO: Address info? */ diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 442054090d..00bf569510 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -145,7 +145,7 @@ uint32 OS_TaskGetId(void) void OS_TaskExit(void) { - return OS_ERR_NOT_IMPLEMENTED; + PANIC("Unimplemented method!"); } int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer) From 9491cbae847bcc0a7622c73676b49b082ae4cb33 Mon Sep 17 00:00:00 2001 From: Zach Day Date: Mon, 26 Jun 2017 18:35:48 -0400 Subject: [PATCH 054/122] Fix no-free-ID error on uninitialized queues The `queue` struct had a field `free` that denoted whether or not the queue at the ID was in used. Because there is no function to initialize the queue array, all queues started with a `free` value of `FALSE`. The `free` field has been replaced with a `used` field, and all boolean checks have appropriately been inverted. --- .../no_interface/cFE_booter/osqueue.c | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osqueue.c b/src/components/implementation/no_interface/cFE_booter/osqueue.c index 73a599a0da..67ffcda3fb 100644 --- a/src/components/implementation/no_interface/cFE_booter/osqueue.c +++ b/src/components/implementation/no_interface/cFE_booter/osqueue.c @@ -10,7 +10,7 @@ // The main queue data structure. struct queue { // Whether or not the index of this queue is already taken. - int32 free; + int32 used; // The number of elements allowed in the queue. uint32 depth; @@ -49,27 +49,27 @@ OS_QueueCreate(uint32* queue_id, const char* queue_name, uint32 queue_depth, uin // Check to see if the name is already taken. for (i = 0 ; i < OS_MAX_QUEUES ; i++) { - if ((queues[i].free == FALSE) && strcmp((char*)queue_name, queues[i].name) == 0) { + if ((queues[i].used == TRUE) && strcmp((char*)queue_name, queues[i].name) == 0) { return OS_ERR_NAME_TAKEN; } } // Calculate the queue ID. for (qid = 0 ; qid < OS_MAX_QUEUES ; qid++) { - if (queues[qid].free == TRUE) { + if (queues[qid].used == FALSE) { break; } } // Fail if there are too many queues. - if (qid >= OS_MAX_QUEUES || queues[qid].free != TRUE) { + if (qid >= OS_MAX_QUEUES || queues[qid].used == TRUE) { return OS_ERR_NO_FREE_IDS; } // OS_ERROR may also be returned in the event that an OS call fails, but none are used here. - *queue_id = qid; - queues[*queue_id].free = FALSE; + *queue_id = qid; + queues[*queue_id].used = TRUE; queues[*queue_id].depth = queue_depth; queues[*queue_id].data_size = data_size; strcpy(queues[*queue_id].name, queue_name); @@ -83,12 +83,12 @@ OS_QueueDelete(uint32 queue_id) { return OS_ERR_INVALID_ID; } // Check if there is a queue to be deleted at the ID. - if (queues[queue_id].free == TRUE) { + if (queues[queue_id].used == FALSE) { return OS_ERR_INVALID_ID; } // Reset all values in the queue. - queues[queue_id].free = TRUE; + queues[queue_id].used = FALSE; queues[queue_id].depth = 0; queues[queue_id].data_size = 0; strcpy(queues[queue_id].name, ""); @@ -106,7 +106,7 @@ OS_QueueGet(uint32 queue_id, void* data, uint32 size, uint32* size_copied, int32 uint32 i; // Check if the requested queue exists. - if (queue_id > OS_MAX_QUEUES || queues[queue_id].free == TRUE) { + if (queue_id > OS_MAX_QUEUES || queues[queue_id].used == FALSE) { return OS_ERR_INVALID_ID; } @@ -154,7 +154,7 @@ OS_QueuePut(uint32 queue_id, const void* data, uint32 size, uint32 flags) uint32 i; // Check if the requested queue exists. - if (queues[queue_id].free == TRUE) { + if (queues[queue_id].used == FALSE) { return OS_ERR_INVALID_ID; } @@ -223,7 +223,7 @@ OS_QueueGetInfo(uint32 queue_id, OS_queue_prop_t* queue_prop) return OS_INVALID_POINTER; } - if (queues[queue_id].free == TRUE) { + if (queues[queue_id].used == FALSE) { return OS_ERR_INVALID_ID; } From bfedf774af633a05f44daa50045e37cb11fa8288 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 26 Jun 2017 19:44:03 -0400 Subject: [PATCH 055/122] Flag time base methods as unimplemented --- .../no_interface/cFE_booter/ostask.c | 11 +++++------ .../no_interface/cFE_booter/ostimer.c | 15 ++++++--------- .../implementation/no_interface/cFE_booter/psp.c | 8 ++++---- .../implementation/no_interface/cFE_booter/sl.c | 4 ++-- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 00bf569510..d762d4536a 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -54,6 +54,7 @@ int is_name_taken(const char* name) { */ // Necessary to control the number of created tasks +// FIXME: All tasks have the same priority! // TODO: Implement flags int32 OS_TaskCreate(uint32 *task_id, const char *task_name, osal_task_entry function_pointer, @@ -136,11 +137,9 @@ int32 OS_TaskDelete(uint32 task_id) uint32 OS_TaskGetId(void) { - struct sl_thd* thd = sl_thd_curr(); - if(!thd) { - PANIC("Could not get the current thread!"); - } - return thd->thdid; + thdid_t thdid = cos_thdid(); + assert(thdid != 0); + return thdid; } void OS_TaskExit(void) @@ -226,7 +225,7 @@ int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) */ void OS_IdleLoop(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + sl_thd_block(0); } /* diff --git a/src/components/implementation/no_interface/cFE_booter/ostimer.c b/src/components/implementation/no_interface/cFE_booter/ostimer.c index 5971691bbf..fe5a72ccb2 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostimer.c +++ b/src/components/implementation/no_interface/cFE_booter/ostimer.c @@ -13,28 +13,25 @@ int32 OS_TimerAPIInit(void) return 0; } +// TODO: Verify this API really insn't necessary int32 OS_TimeBaseCreate(uint32 *timer_id, const char *timebase_name, OS_TimerSync_t external_sync) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_ERR_NOT_IMPLEMENTED; } int32 OS_TimeBaseSet(uint32 timer_id, uint32 start_time, uint32 interval_time) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_ERR_NOT_IMPLEMENTED; } int32 OS_TimeBaseDelete(uint32 timer_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_ERR_NOT_IMPLEMENTED; } -int32 OS_TimeBaseGetIdByName(uint32 *timer_id, const char *timebase_name) +int32 OS_TimeBaseGetIdByName (uint32 *timer_id, const char *timebase_name) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_ERR_NOT_IMPLEMENTED; } diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c index 13d15b3e29..13c337726a 100644 --- a/src/components/implementation/no_interface/cFE_booter/psp.c +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -264,8 +264,8 @@ int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk ) int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *SizeOfKernelSegment) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + // TODO: Verify this is ok to remain unimplemented + return CFE_PSP_ERROR_NOT_IMPLEMENTED; } /* ** CFE_PSP_GetKernelTextSegmentInfo returns the location and size of the kernel memory. @@ -273,8 +273,8 @@ int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *Size int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFESegment) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + // TODO: Verify this is ok to remain unimplemented + return CFE_PSP_ERROR_NOT_IMPLEMENTED; } /* ** CFE_PSP_GetCFETextSegmentInfo returns the location and size of the kernel memory. diff --git a/src/components/implementation/no_interface/cFE_booter/sl.c b/src/components/implementation/no_interface/cFE_booter/sl.c index 55b108165b..eba6418d9f 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.c +++ b/src/components/implementation/no_interface/cFE_booter/sl.c @@ -259,8 +259,8 @@ sl_sched_loop(void) if (unlikely(t == sl__globals()->idle_thd)) continue; /* - * receiving scheduler notifications is not in critical section mainly for - * 1. scheduler thread can often be blocked in rcv, which can add to + * receiving scheduler notifications is not in critical section mainly for + * 1. scheduler thread can often be blocked in rcv, which can add to * interrupt execution or even AEP thread execution overheads. * 2. scheduler events are not acting on the sl_thd or the policy structures, so * having finer grained locks around the code that modifies sl_thd states is better. From 5f3ae279a9671435b72cb30bc268fa091712068e Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 27 Jun 2017 13:32:03 -0400 Subject: [PATCH 056/122] Fix NULL redefinition warnings in the cFE --- .../cFE_booter/cfe_psp_memrange.c | 46 ++++++++++--------- .../no_interface/cFE_booter/cfe_psp_memtab.c | 1 + .../no_interface/cFE_booter/cfe_psp_port.c | 9 ++-- .../no_interface/cFE_booter/cfe_psp_ram.c | 25 +++++----- 4 files changed, 40 insertions(+), 41 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cfe_psp_memrange.c b/src/components/implementation/no_interface/cFE_booter/cfe_psp_memrange.c index d7143479c8..1fd554ae24 100644 --- a/src/components/implementation/no_interface/cFE_booter/cfe_psp_memrange.c +++ b/src/components/implementation/no_interface/cFE_booter/cfe_psp_memrange.c @@ -2,12 +2,12 @@ ** File : cfe_psp_memrange.c ** ** -** Copyright (c) 2004-2011, United States Government as represented by -** Administrator for The National Aeronautics and Space Administration. +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. ** All Rights Reserved. ** ** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. +** distributed and modified only pursuant to the terms of that agreement. ** ** Author : Alan Cudmore ** @@ -22,6 +22,8 @@ ** Include section */ +#include + #include "cfe_psp.h" #ifdef _ENHANCED_BUILD_ @@ -50,7 +52,7 @@ extern CFE_PSP_MemTable_t CFE_PSP_MemoryTable[CFE_PSP_MEM_TABLE_SIZE]; ** ** Assumptions and Notes: ** -** Parameters: +** Parameters: ** Address -- A 32 bit starting address of the memory range ** Size -- A 32 bit size of the memory range ( Address + Size = End Address ) ** MemoryType -- The memory type to validate, including but not limited to: @@ -77,7 +79,7 @@ int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType) uint32 TypeInTable; int32 ReturnCode = CFE_PSP_INVALID_MEM_ADDR; uint32 i; - + /* ** Before searching table, do a preliminary parameter validation */ @@ -85,12 +87,12 @@ int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType) { return(CFE_PSP_INVALID_MEM_TYPE); } - + if ( EndAddressToTest < StartAddressToTest ) { return(CFE_PSP_INVALID_MEM_RANGE); } - + for ( i = 0; i < CFE_PSP_MEM_TABLE_SIZE; i++ ) { /* @@ -101,7 +103,7 @@ int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType) StartAddressInTable = CFE_PSP_MemoryTable[i].StartAddr; EndAddressInTable = CFE_PSP_MemoryTable[i].StartAddr + CFE_PSP_MemoryTable[i].Size - 1; TypeInTable = CFE_PSP_MemoryTable[i].MemoryType; - + /* ** Step 1: Get the Address to Fit within the range */ @@ -127,7 +129,7 @@ int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType) { ReturnCode = CFE_PSP_SUCCESS; break; /* The range is valid, break out of the loop */ - } + } else if ( MemoryType == CFE_PSP_MEM_EEPROM && TypeInTable == CFE_PSP_MEM_EEPROM ) { ReturnCode = CFE_PSP_SUCCESS; @@ -151,7 +153,7 @@ int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType) /* The range is not valid, move to the next entry */ } } /* End if MemoryType != CFE_PSP_MEM_INVALID */ - + } /* End for */ return(ReturnCode); } @@ -164,7 +166,7 @@ int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType) ** ** Assumptions and Notes: ** -** Parameters: +** Parameters: ** None ** ** Global Inputs: None @@ -188,9 +190,9 @@ uint32 CFE_PSP_MemRanges(void) ** ** Assumptions and Notes: ** Because the table is fixed size, the entries are set by using the integer index. -** No validation is done with the address or size. +** No validation is done with the address or size. ** -** Parameters: +** Parameters: ** RangeNum -- A 32 bit integer ( starting with 0 ) specifying the MemoryTable entry. ** MemoryType -- The memory type to validate, including but not limited to: ** CFE_PSP_MEM_RAM, CFE_PSP_MEM_EEPROM, or CFE_PSP_MEM_ANY @@ -229,19 +231,19 @@ int32 CFE_PSP_MemRangeSet (uint32 RangeNum, uint32 MemoryType, cpuaddr Sta { return(CFE_PSP_INVALID_MEM_TYPE); } - + if ( ( WordSize != CFE_PSP_MEM_SIZE_BYTE ) && ( WordSize != CFE_PSP_MEM_SIZE_WORD ) && ( WordSize != CFE_PSP_MEM_SIZE_DWORD ) ) { return(CFE_PSP_INVALID_MEM_WORDSIZE); } - + if ( ( Attributes != CFE_PSP_MEM_ATTR_READ ) && ( Attributes != CFE_PSP_MEM_ATTR_WRITE ) && ( Attributes != CFE_PSP_MEM_ATTR_READWRITE )) { return(CFE_PSP_INVALID_MEM_ATTR); } - + /* ** Parameters check out, add the range */ @@ -250,7 +252,7 @@ int32 CFE_PSP_MemRangeSet (uint32 RangeNum, uint32 MemoryType, cpuaddr Sta CFE_PSP_MemoryTable[RangeNum].Size = Size; CFE_PSP_MemoryTable[RangeNum].WordSize = WordSize; CFE_PSP_MemoryTable[RangeNum].Attributes = Attributes; - + return(CFE_PSP_SUCCESS) ; } @@ -263,13 +265,13 @@ int32 CFE_PSP_MemRangeSet (uint32 RangeNum, uint32 MemoryType, cpuaddr Sta ** Assumptions and Notes: ** Becasue the table is fixed size, the entries are accessed by using the integer index. ** -** Parameters: +** Parameters: ** RangeNum -- A 32 bit integer ( starting with 0 ) specifying the MemoryTable entry. ** *MemoryType -- A pointer to the 32 bit integer where the Memory Type is stored. ** Any defined CFE_PSP_MEM_* enumeration can be specified ** *Address -- A pointer to the 32 bit integer where the 32 bit starting address of the memory range ** is stored. -** *Size -- A pointer to the 32 bit integer where the 32 bit size of the memory range +** *Size -- A pointer to the 32 bit integer where the 32 bit size of the memory range ** is stored. ** *WordSize -- A pointer to the 32 bit integer where the the minimum addressable size of the range: ** ( CFE_PSP_MEM_SIZE_BYTE, CFE_PSP_MEM_SIZE_WORD, CFE_PSP_MEM_SIZE_DWORD ) @@ -293,17 +295,17 @@ int32 CFE_PSP_MemRangeGet (uint32 RangeNum, uint32 *MemoryType, cpuaddr *S { return(CFE_PSP_INVALID_POINTER); } - + if ( RangeNum >= CFE_PSP_MEM_TABLE_SIZE ) { return(CFE_PSP_INVALID_MEM_RANGE); } - + *MemoryType = CFE_PSP_MemoryTable[RangeNum].MemoryType; *StartAddr = CFE_PSP_MemoryTable[RangeNum].StartAddr; *Size = CFE_PSP_MemoryTable[RangeNum].Size; *WordSize = CFE_PSP_MemoryTable[RangeNum].WordSize; *Attributes = CFE_PSP_MemoryTable[RangeNum].Attributes; - + return(CFE_PSP_SUCCESS) ; } diff --git a/src/components/implementation/no_interface/cFE_booter/cfe_psp_memtab.c b/src/components/implementation/no_interface/cFE_booter/cfe_psp_memtab.c index a6d4e0d1c5..c2cef1e59b 100644 --- a/src/components/implementation/no_interface/cFE_booter/cfe_psp_memtab.c +++ b/src/components/implementation/no_interface/cFE_booter/cfe_psp_memtab.c @@ -20,6 +20,7 @@ ** Includes */ +#include #include "common_types.h" #include "osapi.h" #include "cfe_psp.h" diff --git a/src/components/implementation/no_interface/cFE_booter/cfe_psp_port.c b/src/components/implementation/no_interface/cFE_booter/cfe_psp_port.c index 4e2a0eb9fd..a88dd0aada 100644 --- a/src/components/implementation/no_interface/cFE_booter/cfe_psp_port.c +++ b/src/components/implementation/no_interface/cFE_booter/cfe_psp_port.c @@ -2,12 +2,12 @@ ** File : cfe_pep_memport.c ** ** -** Copyright (c) 2004-2011, United States Government as represented by -** Administrator for The National Aeronautics and Space Administration. +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. ** All Rights Reserved. ** ** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. +** distributed and modified only pursuant to the terms of that agreement. ** ** Author : Ezra Yeheskeli ** @@ -23,7 +23,7 @@ /* ** Include section */ - +#include #include "cfe_psp.h" @@ -229,4 +229,3 @@ int32 CFE_PSP_PortWrite32 ( cpuaddr PortAddress, uint32 uint32Value ) return(CFE_PSP_SUCCESS) ; } - diff --git a/src/components/implementation/no_interface/cFE_booter/cfe_psp_ram.c b/src/components/implementation/no_interface/cFE_booter/cfe_psp_ram.c index b3be2991ac..8fcae8fd57 100644 --- a/src/components/implementation/no_interface/cFE_booter/cfe_psp_ram.c +++ b/src/components/implementation/no_interface/cFE_booter/cfe_psp_ram.c @@ -2,12 +2,12 @@ ** File : cfe_psp_memram.c ** ** -** Copyright (c) 2004-2011, United States Government as represented by -** Administrator for The National Aeronautics and Space Administration. +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. ** All Rights Reserved. ** ** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. +** distributed and modified only pursuant to the terms of that agreement. ** ** Author : Ezra Yeheskeli ** @@ -23,7 +23,7 @@ /* ** Include section */ - +#include #include "cfe_psp.h" @@ -52,9 +52,9 @@ */ int32 CFE_PSP_MemRead8( cpuaddr MemoryAddress, uint8 *ByteValue ) { - + (*ByteValue) = *((uint8 *)MemoryAddress) ; - + return(CFE_PSP_SUCCESS) ; } @@ -82,7 +82,7 @@ int32 CFE_PSP_MemWrite8 ( cpuaddr MemoryAddress, uint8 ByteValue ) { *((uint8 *)MemoryAddress) = ByteValue; return(CFE_PSP_SUCCESS) ; - + } /* @@ -117,7 +117,7 @@ int32 CFE_PSP_MemRead16( cpuaddr MemoryAddress, uint16 *uint16Value ) } (*uint16Value) = *((uint16 *)MemoryAddress) ; return(CFE_PSP_SUCCESS) ; - + } /* ** Name: CFE_PSP_MemWrite16 @@ -176,14 +176,14 @@ int32 CFE_PSP_MemWrite16 ( cpuaddr MemoryAddress, uint16 uint16Value ) ** addressing scheme. */ int32 CFE_PSP_MemRead32( cpuaddr MemoryAddress, uint32 *uint32Value ) -{ +{ /* check 32 bit alignment */ if( MemoryAddress & 0x00000003) { return(CFE_PSP_ERROR_ADDRESS_MISALIGNED) ; } (*uint32Value) = *((uint32 *)MemoryAddress) ; - + return(CFE_PSP_SUCCESS) ; } @@ -212,7 +212,7 @@ int32 CFE_PSP_MemRead32( cpuaddr MemoryAddress, uint32 *uint32Value ) */ int32 CFE_PSP_MemWrite32 ( cpuaddr MemoryAddress, uint32 uint32Value ) { - + /* check 32 bit alignment */ if( MemoryAddress & 0x00000003) { @@ -223,6 +223,3 @@ int32 CFE_PSP_MemWrite32 ( cpuaddr MemoryAddress, uint32 uint32Value ) return(CFE_PSP_SUCCESS) ; } - - - From aef5c6304d13be628c0145f1b3423ea487ccce10 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 27 Jun 2017 17:59:41 -0400 Subject: [PATCH 057/122] index on (no branch): 5f3ae279 Fix NULL redefinition warnings in the cFE --- .../no_interface/cFE_booter/osapi.c | 16 ++- .../no_interface/cFE_booter/ostask.c | 92 ++++++--------- .../no_interface/cFE_booter/sl.h | 34 ++++-- .../no_interface/cFE_booter/sl_lock.c | 110 ++++++++++++++++++ .../no_interface/cFE_booter/sl_lock.h | 24 ++++ .../no_interface/cFE_booter/sl_semaphore.c | 79 +++++++++++++ .../no_interface/cFE_booter/sl_semaphore.h | 28 +++++ src/components/lib/musl-1.1.11/bin/musl-gcc | 2 +- 8 files changed, 307 insertions(+), 78 deletions(-) create mode 100644 src/components/implementation/no_interface/cFE_booter/sl_lock.c create mode 100644 src/components/implementation/no_interface/cFE_booter/sl_lock.h create mode 100644 src/components/implementation/no_interface/cFE_booter/sl_semaphore.c create mode 100644 src/components/implementation/no_interface/cFE_booter/sl_semaphore.h diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 9054fd5318..dc68320676 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -92,7 +92,7 @@ int32 OS_Tick2Micros(void) } OS_time_t local_time; -cycles_t old_cycle_count; +microsec_t last_time_check; OS_time_t OS_AdvanceTime(OS_time_t initial_time, microsec_t usec) { microsec_t old_seconds = (microsec_t) initial_time.seconds; @@ -116,20 +116,18 @@ int32 OS_GetLocalTime(OS_time_t *time_struct) return OS_INVALID_POINTER; } - if(old_cycle_count == 0) { + if(last_time_check == 0) { local_time = (OS_time_t) { .seconds = 1181683060, .microsecs = 0 }; - old_cycle_count = sl_now(); + last_time_check = sl_now_usec(); } else { - cycles_t new_cycle_count = sl_now(); - cycles_t elapsed_cycles = new_cycle_count - old_cycle_count; - - microsec_t elapsed_usec = sl_cyc2usec(elapsed_cycles); + microsec_t current_time = sl_now_usec(); + microsec_t elapsed_usec = current_time - last_time_check; local_time = OS_AdvanceTime(local_time, elapsed_usec); - old_cycle_count = new_cycle_count; + last_time_check = current_time; } *time_struct = local_time; @@ -145,7 +143,7 @@ int32 OS_SetLocalTime(OS_time_t *time_struct) } local_time = *time_struct; - old_cycle_count = sl_now(); + last_time_check = sl_now_usec(); return OS_SUCCESS; } /*end OS_SetLocalTime */ diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index d762d4536a..0f274b7967 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -5,6 +5,7 @@ #include "gen/common_types.h" #include "sl.h" +#include "sl_lock.h" #include @@ -12,6 +13,9 @@ /* ** Internal Task helper functions */ +// We need to keep track of this +thdid_t main_delegate_thread_id; + void OS_SchedulerStart(cos_thd_fn_t main_delegate) { sl_init(); @@ -19,6 +23,8 @@ void OS_SchedulerStart(cos_thd_fn_t main_delegate) { union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = 255}}; sl_thd_param_set(main_delegate_thread, sp.v); + main_delegate_thread_id = main_delegate_thread->thdid; + sl_sched_loop(); } @@ -37,7 +43,7 @@ int is_valid_name(const char* name) { } // TODO: Figure out how to check if names are taken -int is_name_taken(const char* name) { +int is_thread_name_taken(const char* name) { // for(int i = 0; i < num_tasks; i++) { // thdid_t task_id = task_ids[i]; // struct sl_thd_policy* task = sl_mod_thd_policy_get(sl_thd_lkup(task_id)); @@ -78,7 +84,7 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, goto exit; } - if(is_name_taken(task_name)) { + if(is_thread_name_taken(task_name)) { result = OS_ERR_NAME_TAKEN; goto exit; } @@ -137,9 +143,7 @@ int32 OS_TaskDelete(uint32 task_id) uint32 OS_TaskGetId(void) { - thdid_t thdid = cos_thdid(); - assert(thdid != 0); - return thdid; + return sl_thd_curr_id(); } void OS_TaskExit(void) @@ -149,16 +153,19 @@ void OS_TaskExit(void) int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer) { - sl_mod_thd_policy_get(sl_thd_lkup(OS_TaskGetId()))->delete_handler = function_pointer; + if(OS_TaskGetId() == main_delegate_thread_id) { + return OS_ERR_INVALID_ID; + } + sl_mod_thd_policy_get(sl_thd_curr())->delete_handler = function_pointer; return OS_SUCCESS; } int32 OS_TaskDelay(uint32 millisecond) { // TODO: Use Phanis extension - cycles_t start_time = sl_now(); + microsec_t start_time = sl_now_usec(); - while(sl_cyc2usec(sl_now() - start_time) / 1000 < millisecond) { + while((sl_now_usec() - start_time) / 1000 < millisecond) { // FIXME: Use an actual timeout once we have that sl_thd_yield(0); } @@ -184,6 +191,10 @@ int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) int32 OS_TaskRegister(void) { + if(OS_TaskGetId() == main_delegate_thread_id) { + return OS_ERR_INVALID_ID; + } + // Think it is safe for this to do nothing return OS_SUCCESS; } @@ -245,11 +256,8 @@ void OS_ApplicationShutdown(uint8 flag) struct mutex { int used; - - uint32 creator; - uint32 held; - thdid_t holder; - char name[OS_MAX_API_NAME]; + struct sl_lock lock; + OS_mut_sem_prop_t prop; }; struct mutex mutexes[OS_MAX_MUTEXES]; @@ -273,7 +281,7 @@ int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) uint32 id; for (id = 0; id < OS_MAX_MUTEXES; id++) { - if (mutexes[id].used && strcmp(sem_name, mutexes[id].name) == 0) { + if (mutexes[id].used && strcmp(sem_name, mutexes[id].prop.name) == 0) { result = OS_ERR_NAME_TAKEN; goto exit; } @@ -290,10 +298,11 @@ int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) } *sem_id = id; + mutexes[id].used = TRUE; - mutexes[id].held = FALSE; - mutexes[id].creator = sl_thd_curr()->thdid; - strcpy(mutexes[id].name, sem_name); + sl_lock_init(&mutexes[id].lock); + mutexes[id].prop.creator = sl_thd_curr_id(); + strcpy(mutexes[id].prop.name, sem_name); exit: sl_cs_exit(); @@ -311,12 +320,7 @@ int32 OS_MutSemGive(uint32 sem_id) goto exit; } - if (!mutexes[sem_id].held || mutexes[sem_id].holder != sl_thd_curr()->thdid) { - result = OS_SEM_FAILURE; - goto exit; - } - - mutexes[sem_id].held = FALSE; + sl_lock_unlock_no_cs(&mutexes[sem_id].lock); exit: sl_cs_exit(); @@ -330,34 +334,12 @@ int32 OS_MutSemTake(uint32 sem_id) sl_cs_enter(); - if (sem_id >= OS_MAX_MUTEXES) { - result = OS_ERR_INVALID_ID; - goto exit; - } - - while (mutexes[sem_id].held && mutexes[sem_id].used) { - int holder = mutexes[sem_id].holder; - - /* - * If we are preempted after the exit, and the holder is no longer holding - * the critical section, then we will yield to them and possibly waste a - * time-slice. This will be fixed the next iteration, as we will see an - * updated value of the holder, but we essentially lose a timeslice in the - * worst case. From a real-time perspective, this is bad, but we're erring - * on simplicity here. - */ - sl_cs_exit(); - sl_thd_yield(holder); - sl_cs_enter(); - } - - if (!mutexes[sem_id].used) { + if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { result = OS_ERR_INVALID_ID; goto exit; } - mutexes[sem_id].held = TRUE; - mutexes[sem_id].holder = sl_thd_curr()->thdid; + sl_lock_lock_no_cs(&mutexes[sem_id].lock); exit: sl_cs_exit(); @@ -375,7 +357,7 @@ int32 OS_MutSemDelete(uint32 sem_id) goto exit; } - if (mutexes[sem_id].held) { + if (sl_lock_holder(&mutexes[sem_id].lock) != 0) { result = OS_SEM_FAILURE; goto exit; } @@ -406,7 +388,7 @@ int32 OS_MutSemGetIdByName(uint32 *sem_id, const char *sem_name) int i; for (i = 0; i < OS_MAX_MUTEXES; i++) { - if (mutexes[i].used && (strcmp (mutexes[i].name, (char*) sem_name) == 0)) { + if (mutexes[i].used && (strcmp (mutexes[i].prop.name, (char*) sem_name) == 0)) { *sem_id = i; goto exit; } @@ -436,11 +418,7 @@ int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) goto exit; } - *mut_prop = (OS_mut_sem_prop_t) { - .creator = mutexes[sem_id].creator, - }; - - strcpy(mut_prop->name, mutexes[sem_id].name); + *mut_prop = mutexes[sem_id].prop; exit: sl_cs_exit(); @@ -505,7 +483,7 @@ int32 OS_SemaphoreCreate(struct semaphore* semaphores, uint32 max_semaphores, *sem_id = id; semaphores[id].used = TRUE; - semaphores[id].creator = sl_thd_curr()->thdid; + semaphores[id].creator = sl_thd_curr_id(); semaphores[id].count = sem_initial_value; strcpy(semaphores[id].name, sem_name); @@ -594,7 +572,7 @@ int32 OS_SemaphoreTimedWait(struct semaphore* semaphores, uint32 max_semaphores, uint32 sem_id, uint32 msecs) { int32 result = OS_SUCCESS; - cycles_t start_cycles = sl_now(); + microsec_t start_time = sl_now(); microsec_t max_wait = msecs * 1000; sl_cs_enter(); @@ -606,7 +584,7 @@ int32 OS_SemaphoreTimedWait(struct semaphore* semaphores, uint32 max_semaphores, while (semaphores[sem_id].used && semaphores[sem_id].count == 0 - && sl_cyc2usec(sl_now() - start_cycles) < max_wait) { + && (sl_now_usec() - start_time) < max_wait) { sl_cs_exit(); // FIXME: Do an actually sensible yield here! sl_thd_yield(0); diff --git a/src/components/implementation/no_interface/cFE_booter/sl.h b/src/components/implementation/no_interface/cFE_booter/sl.h index 2211c14e5a..a4999b859d 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.h +++ b/src/components/implementation/no_interface/cFE_booter/sl.h @@ -81,13 +81,20 @@ sl_thd_lkup(thdid_t tid) return sl_mod_thd_get(sl_thd_lookup_backend(tid)); } -static inline struct sl_thd * -sl_thd_curr(void) +static inline thdid_t +sl_thd_curr_id(void) { thdid_t tid = cos_thdid(); assert(tid != 0); assert(tid < MAX_NUM_THREADS); - return sl_thd_lkup(tid); + return tid; +} + + +static inline struct sl_thd * +sl_thd_curr(void) +{ + return sl_thd_lkup(sl_thd_curr_id()); } /* are we the owner of the critical section? */ @@ -185,10 +192,23 @@ sl_cs_exit(void) if (!ps_cas(&sl__globals()->lock.u.v, cached.v, 0)) goto retry; } +static inline microsec_t +sl_cyc2usec(cycles_t cyc) +{ return cyc / sl__globals()->cyc_per_usec; } + +static inline microsec_t +sl_usec2cyc(microsec_t usec) +{ return usec * sl__globals()->cyc_per_usec; } + static inline cycles_t sl_now(void) { return ps_tsc(); } +static inline microsec_t +sl_now_usec(void) +{ return sl_cyc2usec(sl_now()); } + + /* * Do a few things: 1. take the critical section if it isn't already * taken, 2. call schedule to find the next thread to run, 3. release @@ -325,14 +345,6 @@ static inline void sl_timeout_relative(cycles_t offset) { sl_timeout_oneshot(sl_now() + offset); } -static inline microsec_t -sl_cyc2usec(cycles_t cyc) -{ return cyc / sl__globals()->cyc_per_usec; } - -static inline microsec_t -sl_usec2cyc(microsec_t usec) -{ return usec * sl__globals()->cyc_per_usec; } - void sl_thd_param_set(struct sl_thd *t, sched_param_t sp); /* diff --git a/src/components/implementation/no_interface/cFE_booter/sl_lock.c b/src/components/implementation/no_interface/cFE_booter/sl_lock.c new file mode 100644 index 0000000000..107c78b806 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl_lock.c @@ -0,0 +1,110 @@ +#include "sl_lock.h" + +#include "sl.h" + +void sl_lock_init(struct sl_lock *lock) { + assert(lock); + + *lock = (struct sl_lock) { + .holder = 0 + }; +} + +thdid_t sl_lock_holder(struct sl_lock *lock) { + assert(lock); + return lock->holder; +} + +// If timeout is 0, ignore the timeout +int sl_lock_timeout_elapsed(microsec_t start_time, microsec_t timeout) { + if (timeout == 0 || (sl_now_usec() - start_time) <= timeout) { + return 0; + } + return 1; +} + +int sl_lock_lock_internal_no_cs(struct sl_lock *lock, microsec_t timeout) { + assert(lock); + + microsec_t start_time = sl_now_usec(); + while (lock->holder != 0 && !sl_lock_timeout_elapsed(start_time, timeout)) { + thdid_t holder = lock->holder; + + /* + * If we are preempted after the exit, and the holder is no longer holding + * the critical section, then we will yield to them and possibly waste a + * time-slice. This will be fixed the next iteration, as we will see an + * updated value of the holder, but we essentially lose a timeslice in the + * worst case. From a real-time perspective, this is bad, but we're erring + * on simplicity here. + */ + sl_cs_exit(); + sl_thd_yield(holder); + sl_cs_enter(); + } + + int took_lock = 0; + if (lock->holder == 0) { + lock->holder = sl_thd_curr_id(); + took_lock = 1; + } + return took_lock; +} + + +int sl_lock_lock_internal(struct sl_lock *lock, microsec_t timeout) { + sl_cs_enter(); + int result = sl_lock_lock_internal_no_cs(lock, timeout); + sl_cs_exit(); + return result; +} + +void sl_lock_lock(struct sl_lock *lock) { + assert(lock); + + // Lock internally, which should always succeed since timeout is 0 + assert(sl_lock_lock_internal(lock, 0) == 1); +} + +void sl_lock_lock_no_cs(struct sl_lock *lock) { + assert(lock); + + // Lock internally, which should always succeed since timeout is 0 + assert(sl_lock_lock_internal_no_cs(lock, 0) == 1); +} + + +int sl_lock_timed_lock(struct sl_lock *lock, microsec_t timeout) { + assert(lock); + + if (timeout == 0) { + return 0; + } + return sl_lock_lock_internal(lock, timeout); +} + +int sl_lock_timed_lock_no_cs(struct sl_lock *lock, microsec_t timeout) { + assert(lock); + + if (timeout == 0) { + return 0; + } + return sl_lock_lock_internal_no_cs(lock, timeout); +} + + +void sl_lock_unlock(struct sl_lock *lock) { + assert(lock); + sl_cs_enter(); + + sl_lock_unlock_no_cs(lock); + + sl_cs_exit(); +} + +void sl_lock_unlock_no_cs(struct sl_lock *lock) { + assert(lock); + + assert(lock->holder == sl_thd_curr_id()); + lock->holder = 0; +} diff --git a/src/components/implementation/no_interface/cFE_booter/sl_lock.h b/src/components/implementation/no_interface/cFE_booter/sl_lock.h new file mode 100644 index 0000000000..f325f0a5a4 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl_lock.h @@ -0,0 +1,24 @@ +#ifndef SL_LOCK_H +#define SL_LOCK_H + +#include + +struct sl_lock { + // will be 0 if no one holds the lock + thdid_t holder; +}; + +void sl_lock_init(struct sl_lock *lock); + +thdid_t sl_lock_holder(struct sl_lock *lock); + +void sl_lock_lock(struct sl_lock *lock); +void sl_lock_lock_no_cs(struct sl_lock *lock); + +int sl_lock_timed_lock(struct sl_lock *lock, microsec_t timeout); +int sl_lock_timed_lock_no_cs(struct sl_lock *lock, microsec_t timeout); + +void sl_lock_unlock(struct sl_lock *lock); +void sl_lock_unlock_no_cs(struct sl_lock *lock); + +#endif diff --git a/src/components/implementation/no_interface/cFE_booter/sl_semaphore.c b/src/components/implementation/no_interface/cFE_booter/sl_semaphore.c new file mode 100644 index 0000000000..1f3bf30004 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl_semaphore.c @@ -0,0 +1,79 @@ +#include "sl_semaphore.h" + +#include + +struct sl_semaphore_waiter { + thdid_t thdid; + struct ps_list list; +}; + +void sl_semaphore_init(struct sl_semaphore *semaphore, int initial_count) { + assert(semaphore); + + *semaphore = (struct sl_semaphore) { + .count = initial_count, + .epoch = 1 + }; + ps_list_head_init(&semaphore->waiters); +} + + +int sl_semaphore_is_held(struct sl_semaphore *semaphore) { + assert(semaphore); + + sl_cs_enter(); + int no_waiters = ps_list_head_empty(&semaphore->waiters); + sl_cs_exit(); + return !no_waiters; +} + + +int sl_semaphore_timeout_elapsed(microsec_t start_time, microsec_t timeout) { + if (timeout == 0 || (sl_now_usec() - start_time) <= timeout) { + return 0; + } + return 1; +} + +int sl_semaphore_take_internal_no_cs(struct sl_semaphore *semaphore, microsec_t timeout) { + assert(semaphore); + + struct sl_semaphore_waiter waiter = (struct sl_semaphore_waiter) { + .thdid = sl_thd_curr_id() + }; + ps_list_init(&waiter.list); + + microsec_t start_time = sl_now_usec(); + while (semaphore->count == 0 && !sl_semaphore_timeout_elapsed(start_time, timeout)) { + ps_list_head_add(&semaphore->waiters, &waiter, list); + sl_cs_exit(); + + sl_thd_block(0); + ps_list_rem(&waiter, list); + + sl_cs_enter(); + } + + int took_lock = 0; + if (lock->holder == 0) { + lock->holder = sl_thd_curr_id(); + took_lock = 1; + } + return took_lock; + +} + + +void sl_semaphore_take(struct sl_lock *lock); +void sl_semaphore_take_no_cs(struct sl_lock *lock) { + +} + +int sl_semaphore_timed_take(struct sl_lock *lock, microsec_t timeout); +int sl_semaphore_timed_take_no_cs(struct sl_lock *lock, microsec_t timeout); + +void sl_semaphore_release(struct sl_lock *lock); +void sl_semaphore_release_no_cs(struct sl_lock *lock); + +void sl_semaphore_flush(struct sl_lock *lock); +void sl_semaphore_flush_no_cs(struct sl_lock *lock); diff --git a/src/components/implementation/no_interface/cFE_booter/sl_semaphore.h b/src/components/implementation/no_interface/cFE_booter/sl_semaphore.h new file mode 100644 index 0000000000..d4bda86739 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl_semaphore.h @@ -0,0 +1,28 @@ +#ifndef SL_SEMAPHORE_H +#define SL_SEMAPHORE_H + +#include + +struct sl_semaphore { + int count; + int epoch; + struct ps_list_head waiters; +}; + +void sl_semaphore_init(struct sl_semaphore *semaphore, int initial_count); + +int sl_semaphore_is_held(struct sl_semaphore *semaphore); + +void sl_semaphore_take(struct sl_lock *lock); +void sl_semaphore_take_no_cs(struct sl_lock *lock); + +int sl_semaphore_timed_take(struct sl_lock *lock, microsec_t timeout); +int sl_semaphore_timed_take_no_cs(struct sl_lock *lock, microsec_t timeout); + +void sl_semaphore_release(struct sl_lock *lock); +void sl_semaphore_release_no_cs(struct sl_lock *lock); + +void sl_semaphore_flush(struct sl_lock *lock); +void sl_semaphore_flush_no_cs(struct sl_lock *lock); + +#endif diff --git a/src/components/lib/musl-1.1.11/bin/musl-gcc b/src/components/lib/musl-1.1.11/bin/musl-gcc index 28eb31f08a..d1c017d701 100755 --- a/src/components/lib/musl-1.1.11/bin/musl-gcc +++ b/src/components/lib/musl-1.1.11/bin/musl-gcc @@ -1,2 +1,2 @@ #!/bin/sh -exec "${REALGCC:-gcc}" "$@" -specs "/home/gparmer/tmp/composite/src/components/lib/musl-1.1.11/lib/musl-gcc.specs" +exec "${REALGCC:-gcc}" "$@" -specs "/home/vagrant/cFE2cos/composite/src/components/lib/musl-1.1.11/lib/musl-gcc.specs" From 170a02f67d3e887144ccd9a2324c1be475a28dc7 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 27 Jun 2017 18:09:35 -0400 Subject: [PATCH 058/122] Implement sl_lock --- .../no_interface/cFE_booter/sl_lock.c | 110 ++++++++++++++++++ .../no_interface/cFE_booter/sl_lock.h | 24 ++++ 2 files changed, 134 insertions(+) create mode 100644 src/components/implementation/no_interface/cFE_booter/sl_lock.c create mode 100644 src/components/implementation/no_interface/cFE_booter/sl_lock.h diff --git a/src/components/implementation/no_interface/cFE_booter/sl_lock.c b/src/components/implementation/no_interface/cFE_booter/sl_lock.c new file mode 100644 index 0000000000..107c78b806 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl_lock.c @@ -0,0 +1,110 @@ +#include "sl_lock.h" + +#include "sl.h" + +void sl_lock_init(struct sl_lock *lock) { + assert(lock); + + *lock = (struct sl_lock) { + .holder = 0 + }; +} + +thdid_t sl_lock_holder(struct sl_lock *lock) { + assert(lock); + return lock->holder; +} + +// If timeout is 0, ignore the timeout +int sl_lock_timeout_elapsed(microsec_t start_time, microsec_t timeout) { + if (timeout == 0 || (sl_now_usec() - start_time) <= timeout) { + return 0; + } + return 1; +} + +int sl_lock_lock_internal_no_cs(struct sl_lock *lock, microsec_t timeout) { + assert(lock); + + microsec_t start_time = sl_now_usec(); + while (lock->holder != 0 && !sl_lock_timeout_elapsed(start_time, timeout)) { + thdid_t holder = lock->holder; + + /* + * If we are preempted after the exit, and the holder is no longer holding + * the critical section, then we will yield to them and possibly waste a + * time-slice. This will be fixed the next iteration, as we will see an + * updated value of the holder, but we essentially lose a timeslice in the + * worst case. From a real-time perspective, this is bad, but we're erring + * on simplicity here. + */ + sl_cs_exit(); + sl_thd_yield(holder); + sl_cs_enter(); + } + + int took_lock = 0; + if (lock->holder == 0) { + lock->holder = sl_thd_curr_id(); + took_lock = 1; + } + return took_lock; +} + + +int sl_lock_lock_internal(struct sl_lock *lock, microsec_t timeout) { + sl_cs_enter(); + int result = sl_lock_lock_internal_no_cs(lock, timeout); + sl_cs_exit(); + return result; +} + +void sl_lock_lock(struct sl_lock *lock) { + assert(lock); + + // Lock internally, which should always succeed since timeout is 0 + assert(sl_lock_lock_internal(lock, 0) == 1); +} + +void sl_lock_lock_no_cs(struct sl_lock *lock) { + assert(lock); + + // Lock internally, which should always succeed since timeout is 0 + assert(sl_lock_lock_internal_no_cs(lock, 0) == 1); +} + + +int sl_lock_timed_lock(struct sl_lock *lock, microsec_t timeout) { + assert(lock); + + if (timeout == 0) { + return 0; + } + return sl_lock_lock_internal(lock, timeout); +} + +int sl_lock_timed_lock_no_cs(struct sl_lock *lock, microsec_t timeout) { + assert(lock); + + if (timeout == 0) { + return 0; + } + return sl_lock_lock_internal_no_cs(lock, timeout); +} + + +void sl_lock_unlock(struct sl_lock *lock) { + assert(lock); + sl_cs_enter(); + + sl_lock_unlock_no_cs(lock); + + sl_cs_exit(); +} + +void sl_lock_unlock_no_cs(struct sl_lock *lock) { + assert(lock); + + assert(lock->holder == sl_thd_curr_id()); + lock->holder = 0; +} diff --git a/src/components/implementation/no_interface/cFE_booter/sl_lock.h b/src/components/implementation/no_interface/cFE_booter/sl_lock.h new file mode 100644 index 0000000000..f325f0a5a4 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl_lock.h @@ -0,0 +1,24 @@ +#ifndef SL_LOCK_H +#define SL_LOCK_H + +#include + +struct sl_lock { + // will be 0 if no one holds the lock + thdid_t holder; +}; + +void sl_lock_init(struct sl_lock *lock); + +thdid_t sl_lock_holder(struct sl_lock *lock); + +void sl_lock_lock(struct sl_lock *lock); +void sl_lock_lock_no_cs(struct sl_lock *lock); + +int sl_lock_timed_lock(struct sl_lock *lock, microsec_t timeout); +int sl_lock_timed_lock_no_cs(struct sl_lock *lock, microsec_t timeout); + +void sl_lock_unlock(struct sl_lock *lock); +void sl_lock_unlock_no_cs(struct sl_lock *lock); + +#endif From 8648c1d6cec0e5a949baeec326b510b29f6d2bdc Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Wed, 28 Jun 2017 13:01:28 -0400 Subject: [PATCH 059/122] Remove the sscanf stubs, and add free and realloc stubs --- .../implementation/no_interface/cFE_booter/cFE_util.c | 9 +++++++-- .../implementation/no_interface/cFE_booter/cFE_util.h | 2 -- .../implementation/no_interface/cFE_booter/sl.h | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.c b/src/components/implementation/no_interface/cFE_booter/cFE_util.c index ef11ed4cdd..b8b8e3d24a 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.c @@ -47,6 +47,11 @@ void print_with_error_name(char* message, int32 error) { printc("%s, error %s\n", message, local_name); } -void __isoc99_sscanf(void){ - PANIC("__isoc99_sscanf not implemented!"); +void free(void* ptr) { + PANIC("Unimplemented method!"); +} + +void* realloc(void *ptr, size_t new_size) { + PANIC("Unimplemented method!"); + return NULL; } diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.h b/src/components/implementation/no_interface/cFE_booter/cFE_util.h index 6aa50f8d69..2b341cba0e 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.h +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.h @@ -27,6 +27,4 @@ void panic_impl(const char* function, char* message); void print_with_error_name(char* message, int32 error); -void __isoc99_sscanf(void); - #endif diff --git a/src/components/implementation/no_interface/cFE_booter/sl.h b/src/components/implementation/no_interface/cFE_booter/sl.h index a4999b859d..97f45455e9 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.h +++ b/src/components/implementation/no_interface/cFE_booter/sl.h @@ -75,7 +75,7 @@ static inline struct sl_thd * sl_thd_lkup(thdid_t tid) { assert(tid != 0); - if (!(tid < MAX_NUM_THREADS)) { + if (tid > MAX_NUM_THREADS) { return NULL; } return sl_mod_thd_get(sl_thd_lookup_backend(tid)); From 9eb4bcc1fdc31b0e6f70ed4c632a5a0df83538ae Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Wed, 28 Jun 2017 14:16:16 -0400 Subject: [PATCH 060/122] Fix linker error by reintroducing the sscanf stub --- .../no_interface/cFE_booter/cFE_util.c | 16 +++++++++++++--- .../no_interface/cFE_booter/cFE_util.h | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.c b/src/components/implementation/no_interface/cFE_booter/cFE_util.c index b8b8e3d24a..040a0c5c44 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.c @@ -48,10 +48,20 @@ void print_with_error_name(char* message, int32 error) { } void free(void* ptr) { - PANIC("Unimplemented method!"); + PANIC("No free implementation!"); } -void* realloc(void *ptr, size_t new_size) { - PANIC("Unimplemented method!"); +void* realloc(void* ptr, size_t new_size) { + PANIC("No realloc implementation!"); return NULL; } + +int __isoc99_sscanf(const char *buf, const char *fmt, ...) { + int count; + va_list ap; + + va_start(ap, fmt); + count = vsscanf(buf, fmt, ap); + va_end(ap); + return count; +} diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.h b/src/components/implementation/no_interface/cFE_booter/cFE_util.h index 2b341cba0e..d30d226f36 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.h +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.h @@ -27,4 +27,6 @@ void panic_impl(const char* function, char* message); void print_with_error_name(char* message, int32 error); +int __isoc99_sscanf(const char *str, const char *format, ...); + #endif From 32326a4c87b9682b83d5454d247dcf5b58cfc7a6 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 11 Jul 2017 11:56:48 -0400 Subject: [PATCH 061/122] Add sl_lock and integrate it with ostask --- .../no_interface/cFE_booter/ostask.c | 86 ++++++------- .../no_interface/cFE_booter/sl.c | 10 +- .../no_interface/cFE_booter/sl.h | 13 +- .../no_interface/cFE_booter/sl_lock.c | 114 +++--------------- .../no_interface/cFE_booter/sl_lock.h | 33 +++-- 5 files changed, 101 insertions(+), 155 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 0f274b7967..099cfb4f94 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -13,7 +13,7 @@ /* ** Internal Task helper functions */ -// We need to keep track of this +// We need to keep track of this to check if register or delete handler calls are invalid thdid_t main_delegate_thread_id; void OS_SchedulerStart(cos_thd_fn_t main_delegate) { @@ -143,7 +143,7 @@ int32 OS_TaskDelete(uint32 task_id) uint32 OS_TaskGetId(void) { - return sl_thd_curr_id(); + return sl_thdid(); } void OS_TaskExit(void) @@ -260,6 +260,7 @@ struct mutex { OS_mut_sem_prop_t prop; }; +struct sl_lock mutex_data_lock = SL_LOCK_STATIC_INIT(); struct mutex mutexes[OS_MAX_MUTEXES]; @@ -267,7 +268,7 @@ int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) { int32 result = OS_SUCCESS; - sl_cs_enter(); + sl_lock_take(&mutex_data_lock); if (sem_id == NULL || sem_name == NULL) { result = OS_INVALID_POINTER; @@ -301,11 +302,11 @@ int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) mutexes[id].used = TRUE; sl_lock_init(&mutexes[id].lock); - mutexes[id].prop.creator = sl_thd_curr_id(); + mutexes[id].prop.creator = sl_thdid(); strcpy(mutexes[id].prop.name, sem_name); exit: - sl_cs_exit(); + sl_lock_release(&mutex_data_lock); return result; } @@ -313,17 +314,17 @@ int32 OS_MutSemGive(uint32 sem_id) { int32 result = OS_SUCCESS; - sl_cs_enter(); + sl_lock_take(&mutex_data_lock); if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { result = OS_ERR_INVALID_ID; goto exit; } - sl_lock_unlock_no_cs(&mutexes[sem_id].lock); + sl_lock_release(&mutexes[sem_id].lock); exit: - sl_cs_exit(); + sl_lock_release(&mutex_data_lock); return result; } @@ -332,17 +333,17 @@ int32 OS_MutSemTake(uint32 sem_id) { int32 result = OS_SUCCESS; - sl_cs_enter(); + sl_lock_take(&mutex_data_lock); if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { result = OS_ERR_INVALID_ID; goto exit; } - sl_lock_lock_no_cs(&mutexes[sem_id].lock); + sl_lock_take(&mutexes[sem_id].lock); exit: - sl_cs_exit(); + sl_lock_release(&mutex_data_lock); return result; } @@ -350,7 +351,7 @@ int32 OS_MutSemTake(uint32 sem_id) int32 OS_MutSemDelete(uint32 sem_id) { int32 result = OS_SUCCESS; - sl_cs_enter(); + sl_lock_take(&mutex_data_lock); if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { result = OS_ERR_INVALID_ID; @@ -365,8 +366,7 @@ int32 OS_MutSemDelete(uint32 sem_id) mutexes[sem_id].used = FALSE; exit: - sl_cs_exit(); - + sl_lock_release(&mutex_data_lock); return result; } @@ -374,7 +374,7 @@ int32 OS_MutSemGetIdByName(uint32 *sem_id, const char *sem_name) { int32 result = OS_SUCCESS; - sl_cs_enter(); + sl_lock_take(&mutex_data_lock); if (sem_id == NULL || sem_name == NULL) { result = OS_INVALID_POINTER; @@ -398,14 +398,14 @@ int32 OS_MutSemGetIdByName(uint32 *sem_id, const char *sem_name) * or it was, and the sem_id isn't valid anymore */ result = OS_ERR_NAME_NOT_FOUND; exit: - sl_cs_exit(); + sl_lock_release(&mutex_data_lock); return result; } int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) { int32 result = OS_SUCCESS; - sl_cs_enter(); + sl_lock_take(&mutex_data_lock); if(!mut_prop) { @@ -421,7 +421,7 @@ int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) *mut_prop = mutexes[sem_id].prop; exit: - sl_cs_exit(); + sl_lock_release(&mutex_data_lock); return result; } @@ -438,7 +438,7 @@ struct semaphore { char name[OS_MAX_API_NAME]; }; - +struct sl_lock semaphore_data_lock = SL_LOCK_STATIC_INIT(); struct semaphore binary_semaphores[OS_MAX_BIN_SEMAPHORES]; struct semaphore counting_semaphores[OS_MAX_COUNT_SEMAPHORES]; @@ -450,7 +450,7 @@ int32 OS_SemaphoreCreate(struct semaphore* semaphores, uint32 max_semaphores, { int32 result = OS_SUCCESS; - sl_cs_enter(); + sl_lock_take(&semaphore_data_lock); if (sem_id == NULL || sem_name == NULL) { result = OS_INVALID_POINTER; @@ -483,12 +483,12 @@ int32 OS_SemaphoreCreate(struct semaphore* semaphores, uint32 max_semaphores, *sem_id = id; semaphores[id].used = TRUE; - semaphores[id].creator = sl_thd_curr_id(); + semaphores[id].creator = sl_thdid(); semaphores[id].count = sem_initial_value; strcpy(semaphores[id].name, sem_name); exit: - sl_cs_exit(); + sl_lock_release(&semaphore_data_lock); return result; } @@ -497,7 +497,7 @@ int32 OS_SemaphoreFlush(struct semaphore* semaphores, uint32 max_semaphores, uin int32 result = OS_SUCCESS; - sl_cs_enter(); + sl_lock_take(&semaphore_data_lock); if (sem_id >= max_semaphores || !semaphores[sem_id].used) { result = OS_ERR_INVALID_ID; @@ -507,7 +507,7 @@ int32 OS_SemaphoreFlush(struct semaphore* semaphores, uint32 max_semaphores, uin semaphores[sem_id].epoch += 1; exit: - sl_cs_exit(); + sl_lock_release(&semaphore_data_lock); return result; } @@ -516,7 +516,7 @@ int32 OS_SemaphoreGive(struct semaphore* semaphores, uint32 max_semaphores, uint { int32 result = OS_SUCCESS; - sl_cs_enter(); + sl_lock_take(&semaphore_data_lock); if (sem_id >= max_semaphores || !semaphores[sem_id].used) { result = OS_ERR_INVALID_ID; @@ -527,7 +527,7 @@ int32 OS_SemaphoreGive(struct semaphore* semaphores, uint32 max_semaphores, uint semaphores[sem_id].count += 1; exit: - sl_cs_exit(); + sl_lock_release(&semaphore_data_lock); return result; } @@ -536,7 +536,7 @@ int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint { int32 result = OS_SUCCESS; - sl_cs_enter(); + sl_lock_take(&semaphore_data_lock); if (sem_id >= max_semaphores) { result = OS_ERR_INVALID_ID; @@ -549,10 +549,11 @@ int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint if(semaphores[sem_id].epoch != starting_epoch) { goto exit; } - sl_cs_exit(); + sl_lock_release(&semaphore_data_lock); + // FIXME: Do an actually sensible yield here! sl_thd_yield(0); - sl_cs_enter(); + sl_lock_take(&semaphore_data_lock); } if (!semaphores[sem_id].used) { @@ -563,7 +564,7 @@ int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint semaphores[sem_id].count -= 1; exit: - sl_cs_exit(); + sl_lock_release(&semaphore_data_lock); return result; } @@ -575,7 +576,7 @@ int32 OS_SemaphoreTimedWait(struct semaphore* semaphores, uint32 max_semaphores, microsec_t start_time = sl_now(); microsec_t max_wait = msecs * 1000; - sl_cs_enter(); + sl_lock_take(&semaphore_data_lock); if (sem_id >= max_semaphores) { result = OS_ERR_INVALID_ID; @@ -585,10 +586,10 @@ int32 OS_SemaphoreTimedWait(struct semaphore* semaphores, uint32 max_semaphores, while (semaphores[sem_id].used && semaphores[sem_id].count == 0 && (sl_now_usec() - start_time) < max_wait) { - sl_cs_exit(); + sl_lock_release(&semaphore_data_lock); // FIXME: Do an actually sensible yield here! sl_thd_yield(0); - sl_cs_enter(); + sl_lock_take(&semaphore_data_lock); } if (!semaphores[sem_id].used) { @@ -604,7 +605,7 @@ int32 OS_SemaphoreTimedWait(struct semaphore* semaphores, uint32 max_semaphores, semaphores[sem_id].count -= 1; exit: - sl_cs_exit(); + sl_lock_release(&semaphore_data_lock); return result; } @@ -613,7 +614,7 @@ int32 OS_SemaphoreDelete(struct semaphore* semaphores, uint32 max_semaphores, uint32 sem_id) { int32 result = OS_SUCCESS; - sl_cs_enter(); + sl_lock_take(&semaphore_data_lock); if (sem_id >= max_semaphores || !semaphores[sem_id].used) { result = OS_ERR_INVALID_ID; @@ -623,7 +624,7 @@ int32 OS_SemaphoreDelete(struct semaphore* semaphores, uint32 max_semaphores, semaphores[sem_id].used = FALSE; exit: - sl_cs_exit(); + sl_lock_release(&semaphore_data_lock); return result; } @@ -633,7 +634,7 @@ int32 OS_SemaphoreGetIdByName(struct semaphore* semaphores, uint32 max_semaphore { int32 result = OS_SUCCESS; - sl_cs_enter(); + sl_lock_take(&semaphore_data_lock); if (sem_id == NULL || sem_name == NULL) { result = OS_INVALID_POINTER; @@ -657,7 +658,7 @@ int32 OS_SemaphoreGetIdByName(struct semaphore* semaphores, uint32 max_semaphore * or it was, and the sem_id isn't valid anymore */ result = OS_ERR_NAME_NOT_FOUND; exit: - sl_cs_exit(); + sl_lock_release(&semaphore_data_lock); return result; } @@ -705,7 +706,7 @@ int32 OS_BinSemGetIdByName(uint32 *sem_id, const char *sem_name) int32 OS_BinSemGetInfo(uint32 sem_id, OS_bin_sem_prop_t *bin_prop) { int32 result = OS_SUCCESS; - sl_cs_enter(); + sl_lock_take(&semaphore_data_lock); if(!bin_prop) { @@ -726,7 +727,7 @@ int32 OS_BinSemGetInfo(uint32 sem_id, OS_bin_sem_prop_t *bin_prop) strcpy(bin_prop->name, binary_semaphores[sem_id].name); exit: - sl_cs_exit(); + sl_lock_release(&semaphore_data_lock); return result; } @@ -768,7 +769,7 @@ int32 OS_CountSemGetIdByName(uint32 *sem_id, const char *sem_name) int32 OS_CountSemGetInfo(uint32 sem_id, OS_count_sem_prop_t *count_prop) { int32 result = OS_SUCCESS; - sl_cs_enter(); + sl_lock_take(&semaphore_data_lock); if(!count_prop) { @@ -789,6 +790,7 @@ int32 OS_CountSemGetInfo(uint32 sem_id, OS_count_sem_prop_t *count_prop) strcpy(count_prop->name, counting_semaphores[sem_id].name); exit: - sl_cs_exit(); + sl_lock_release(&semaphore_data_lock); + return result; } diff --git a/src/components/implementation/no_interface/cFE_booter/sl.c b/src/components/implementation/no_interface/cFE_booter/sl.c index eba6418d9f..fba297ec66 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.c +++ b/src/components/implementation/no_interface/cFE_booter/sl.c @@ -104,11 +104,10 @@ sl_thd_wakeup(thdid_t tid) } void -sl_thd_yield(thdid_t tid) +sl_thd_yield_cs_exit(thdid_t tid) { struct sl_thd *t = sl_thd_curr(); - sl_cs_enter(); if (tid) { struct sl_thd *to = sl_thd_lkup(tid); @@ -118,8 +117,13 @@ sl_thd_yield(thdid_t tid) sl_mod_yield(sl_mod_thd_policy_get(t), NULL); sl_cs_exit_schedule(); } +} - return; +void +sl_thd_yield(thdid_t tid) +{ + sl_cs_enter(); + sl_thd_yield_cs_exit(tid); } static struct sl_thd * diff --git a/src/components/implementation/no_interface/cFE_booter/sl.h b/src/components/implementation/no_interface/cFE_booter/sl.h index 97f45455e9..25e5cc0995 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.h +++ b/src/components/implementation/no_interface/cFE_booter/sl.h @@ -75,27 +75,25 @@ static inline struct sl_thd * sl_thd_lkup(thdid_t tid) { assert(tid != 0); - if (tid > MAX_NUM_THREADS) { - return NULL; - } + if (unlikely(tid > MAX_NUM_THREADS)) return NULL; return sl_mod_thd_get(sl_thd_lookup_backend(tid)); } static inline thdid_t -sl_thd_curr_id(void) +sl_thdid(void) { thdid_t tid = cos_thdid(); + assert(tid != 0); assert(tid < MAX_NUM_THREADS); + return tid; } static inline struct sl_thd * sl_thd_curr(void) -{ - return sl_thd_lkup(sl_thd_curr_id()); -} +{ return sl_thd_lkup(sl_thdid()); } /* are we the owner of the critical section? */ static inline int @@ -310,6 +308,7 @@ void sl_thd_block(thdid_t tid); /* wakeup a thread that has (or soon will) block */ void sl_thd_wakeup(thdid_t tid); void sl_thd_yield(thdid_t tid); +void sl_thd_yield_cs_exit(thdid_t tid); /* The entire thread allocation and free API */ struct sl_thd *sl_thd_alloc(cos_thd_fn_t fn, void *data); diff --git a/src/components/implementation/no_interface/cFE_booter/sl_lock.c b/src/components/implementation/no_interface/cFE_booter/sl_lock.c index 107c78b806..7ac5793603 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_lock.c +++ b/src/components/implementation/no_interface/cFE_booter/sl_lock.c @@ -1,110 +1,36 @@ -#include "sl_lock.h" - #include "sl.h" +#include "sl_lock.h" -void sl_lock_init(struct sl_lock *lock) { - assert(lock); - - *lock = (struct sl_lock) { - .holder = 0 - }; +void +sl_lock_init(struct sl_lock *lock) +{ + *lock = SL_LOCK_STATIC_INIT(); } -thdid_t sl_lock_holder(struct sl_lock *lock) { - assert(lock); +thdid_t +sl_lock_holder(struct sl_lock *lock) +{ return lock->holder; } -// If timeout is 0, ignore the timeout -int sl_lock_timeout_elapsed(microsec_t start_time, microsec_t timeout) { - if (timeout == 0 || (sl_now_usec() - start_time) <= timeout) { - return 0; - } - return 1; -} - -int sl_lock_lock_internal_no_cs(struct sl_lock *lock, microsec_t timeout) { - assert(lock); - - microsec_t start_time = sl_now_usec(); - while (lock->holder != 0 && !sl_lock_timeout_elapsed(start_time, timeout)) { - thdid_t holder = lock->holder; +int +sl_lock_timed_take(struct sl_lock *lock, microsec_t max_wait_time) +{ + int result; + cycles_t deadline = sl_now() + sl_usec2cyc(max_wait_time); - /* - * If we are preempted after the exit, and the holder is no longer holding - * the critical section, then we will yield to them and possibly waste a - * time-slice. This will be fixed the next iteration, as we will see an - * updated value of the holder, but we essentially lose a timeslice in the - * worst case. From a real-time perspective, this is bad, but we're erring - * on simplicity here. - */ - sl_cs_exit(); - sl_thd_yield(holder); + sl_cs_enter(); + while (lock->holder != 0 && sl_now() < deadline) { + sl_thd_yield_cs_exit(lock->holder); sl_cs_enter(); } - int took_lock = 0; if (lock->holder == 0) { - lock->holder = sl_thd_curr_id(); - took_lock = 1; + lock->holder = sl_thdid(); + result = 1; + } else { + result = 0; } - return took_lock; -} - - -int sl_lock_lock_internal(struct sl_lock *lock, microsec_t timeout) { - sl_cs_enter(); - int result = sl_lock_lock_internal_no_cs(lock, timeout); sl_cs_exit(); return result; } - -void sl_lock_lock(struct sl_lock *lock) { - assert(lock); - - // Lock internally, which should always succeed since timeout is 0 - assert(sl_lock_lock_internal(lock, 0) == 1); -} - -void sl_lock_lock_no_cs(struct sl_lock *lock) { - assert(lock); - - // Lock internally, which should always succeed since timeout is 0 - assert(sl_lock_lock_internal_no_cs(lock, 0) == 1); -} - - -int sl_lock_timed_lock(struct sl_lock *lock, microsec_t timeout) { - assert(lock); - - if (timeout == 0) { - return 0; - } - return sl_lock_lock_internal(lock, timeout); -} - -int sl_lock_timed_lock_no_cs(struct sl_lock *lock, microsec_t timeout) { - assert(lock); - - if (timeout == 0) { - return 0; - } - return sl_lock_lock_internal_no_cs(lock, timeout); -} - - -void sl_lock_unlock(struct sl_lock *lock) { - assert(lock); - sl_cs_enter(); - - sl_lock_unlock_no_cs(lock); - - sl_cs_exit(); -} - -void sl_lock_unlock_no_cs(struct sl_lock *lock) { - assert(lock); - - assert(lock->holder == sl_thd_curr_id()); - lock->holder = 0; -} diff --git a/src/components/implementation/no_interface/cFE_booter/sl_lock.h b/src/components/implementation/no_interface/cFE_booter/sl_lock.h index f325f0a5a4..7611432ef1 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_lock.h +++ b/src/components/implementation/no_interface/cFE_booter/sl_lock.h @@ -1,24 +1,39 @@ #ifndef SL_LOCK_H #define SL_LOCK_H -#include +#include struct sl_lock { // will be 0 if no one holds the lock - thdid_t holder; + volatile thdid_t holder; }; +#define SL_LOCK_STATIC_INIT() (struct sl_lock){ .holder = 0 } + void sl_lock_init(struct sl_lock *lock); thdid_t sl_lock_holder(struct sl_lock *lock); -void sl_lock_lock(struct sl_lock *lock); -void sl_lock_lock_no_cs(struct sl_lock *lock); - -int sl_lock_timed_lock(struct sl_lock *lock, microsec_t timeout); -int sl_lock_timed_lock_no_cs(struct sl_lock *lock, microsec_t timeout); +static inline void sl_lock_take(struct sl_lock *lock) +{ + sl_cs_enter(); + while (lock->holder != 0) { + sl_thd_yield_cs_exit(lock->holder); + sl_cs_enter(); + } + lock->holder = sl_thdid(); + sl_cs_exit(); +} + +int sl_lock_timed_take(struct sl_lock *lock, microsec_t max_wait_time); + +static inline void sl_lock_release(struct sl_lock *lock) +{ + sl_cs_enter(); + assert(lock->holder == sl_thdid()); + lock->holder = 0; + sl_cs_exit(); +} -void sl_lock_unlock(struct sl_lock *lock); -void sl_lock_unlock_no_cs(struct sl_lock *lock); #endif From beab83b5935aadd8061afef6004af12ce3164f98 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Wed, 12 Jul 2017 11:52:32 -0400 Subject: [PATCH 062/122] Fix the ps submodule, which had changes that were lost in the merge --- src/components/lib/ps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/lib/ps b/src/components/lib/ps index 4707e7d1a4..5749bd695f 160000 --- a/src/components/lib/ps +++ b/src/components/lib/ps @@ -1 +1 @@ -Subproject commit 4707e7d1a4faef5c3c3e9754dbb2e6e4980c9e1f +Subproject commit 5749bd695f8eb4529b879bd4d9cfdfe6add3bdd0 From 40a9bb9f637989d31b22fafac4860dfc4aab44db Mon Sep 17 00:00:00 2001 From: Joseph Espy Date: Wed, 12 Jul 2017 12:42:13 -0400 Subject: [PATCH 063/122] Increase the default max number of symbols for the linker We have surpassed the max number of symbols so I have increased it by 4X --- src/platform/linker/cl_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/linker/cl_macros.h b/src/platform/linker/cl_macros.h index e01fd0fc20..8bc06f0c94 100644 --- a/src/platform/linker/cl_macros.h +++ b/src/platform/linker/cl_macros.h @@ -35,7 +35,7 @@ #define UNDEF_SYMB_TYPE 0x1 #define EXPORTED_SYMB_TYPE 0x2 -#define MAX_SYMBOLS 1024 +#define MAX_SYMBOLS 1024 * 4 #define MAX_TRUSTED 32 #define MAX_SYMB_LEN 256 From effa171cdb8c8ba9a95857f20f6686a7c68a7714 Mon Sep 17 00:00:00 2001 From: Joseph Espy Date: Sat, 15 Jul 2017 02:38:06 -0400 Subject: [PATCH 064/122] Implement a functional filesystem for the cFE The cFE requires that the osal provide a nearly posix compliant filesystem. This includes abstractions for directory streams, file descriptors, and physical volumes. I have provided a filesystem implementation which fulfills these abstractions and implements all of the required API. --- .../no_interface/cFE_booter/osapi.c | 1 + .../no_interface/cFE_booter/osfiles.c | 185 +++-- .../no_interface/cFE_booter/osfilesys.c | 700 +++++++++++++++--- .../no_interface/cFE_booter/osfilesys.h | 162 +++- 4 files changed, 846 insertions(+), 202 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index dc68320676..cc737b9d7a 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -25,6 +25,7 @@ int32 OS_API_Init(void) cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); cos_defcompinfo_init(); + OS_FS_Init(); have_initialized = 1; } diff --git a/src/components/implementation/no_interface/cFE_booter/osfiles.c b/src/components/implementation/no_interface/cFE_booter/osfiles.c index 6b04c83855..d4b313f473 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfiles.c +++ b/src/components/implementation/no_interface/cFE_booter/osfiles.c @@ -9,6 +9,11 @@ int32 OS_FS_Init(void) { + uint32 ret = 0; + ret = newfs_init("/ramdev0", "RAM", 512, 4096); + if (ret != OS_FS_SUCCESS) return ret; + ret = tar_parse(); + if (ret != OS_FS_SUCCESS) return ret; return OS_FS_SUCCESS; } @@ -17,7 +22,9 @@ int32 OS_FS_Init(void) */ int32 OS_creat(const char *path, int32 access) { - PANIC("Read Only Filesystem"); + int32 ret = chk_path_new(path); + if (ret) return ret; + file_creat(path); return 0; } @@ -26,10 +33,9 @@ int32 OS_creat(const char *path, int32 access) */ int32 OS_open(const char *path, int32 access, uint32 mode) { - if (access != OS_READ_ONLY) PANIC("Read Only Filesystem!"); - if (!path) return OS_FS_ERR_INVALID_POINTER; - if (strlen(path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; - return open(path); + int32 ret = chk_path(path); + if (ret) return ret; + return file_open(path); } /* @@ -37,7 +43,7 @@ int32 OS_open(const char *path, int32 access, uint32 mode) */ int32 OS_close(int32 filedes) { - return close(filedes); + return file_close(filedes); } /* @@ -45,7 +51,7 @@ int32 OS_close(int32 filedes) */ int32 OS_read(int32 filedes, void *buffer, uint32 nbytes) { - return read(filedes, buffer, nbytes); + return file_read(filedes, buffer, nbytes); } /* @@ -53,17 +59,16 @@ int32 OS_read(int32 filedes, void *buffer, uint32 nbytes) */ int32 OS_write(int32 filedes, void *buffer, uint32 nbytes) { - PANIC("Read Only Filesystem!"); - return 0; + return file_write(filedes, buffer, nbytes); } /* * Changes the permissions of a file + * This is not used by the cFE and UT tests that it returns NOT_IMPLEMENTED */ int32 OS_chmod(const char *path, uint32 access) { - PANIC("Read Only Filesystem!"); - return 0; + return OS_ERR_NOT_IMPLEMENTED; } /* @@ -71,8 +76,10 @@ int32 OS_chmod(const char *path, uint32 access) */ int32 OS_stat(const char *path, os_fstat_t *filestats) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if (filestats == NULL) return OS_FS_ERR_INVALID_POINTER; + int32 ret = chk_path(path); + if (ret) return ret; + return file_stat(path, filestats); } /* @@ -80,8 +87,7 @@ int32 OS_stat(const char *path, os_fstat_t *filestats) */ int32 OS_lseek(int32 filedes, int32 offset, uint32 whence) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return file_lseek(filedes, offset, whence); } /* @@ -89,7 +95,9 @@ int32 OS_lseek(int32 filedes, int32 offset, uint32 whence) */ int32 OS_remove(const char *path) { - PANIC("Read Only Filesystem!"); + int32 ret = chk_path(path); + if (ret) return ret; + file_remove(path); return 0; } @@ -98,8 +106,11 @@ int32 OS_remove(const char *path) */ int32 OS_rename(const char *old_filename, const char *new_filename) { - PANIC("Read Only Filesystem!"); - return 0; + int32 ret = chk_path(old_filename); + if (ret) return ret; + ret = chk_path(new_filename); + if (ret) return ret; + return file_rename(old_filename, new_filename); } /* @@ -107,8 +118,16 @@ int32 OS_rename(const char *old_filename, const char *new_filename) */ int32 OS_cp(const char *src, const char *dest) { - PANIC("Read Only Filesystem!"); - return 0; + if (!src || !dest) return OS_FS_ERR_INVALID_POINTER; + if (strlen((char *)src) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + if (strlen((char *)dest) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + if (strlen(path_to_name((char *)src)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; + if (strlen(path_to_name((char *)dest)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; + int32 ret = chk_path(src); + if (ret) return ret; + ret = chk_path_new(dest); + if (ret) return ret; + return file_cp(src, dest); } /* @@ -116,8 +135,16 @@ int32 OS_cp(const char *src, const char *dest) */ int32 OS_mv(const char *src, const char *dest) { - PANIC("Read Only Filesystem!"); - return 0; + if (!src || !dest) return OS_FS_ERR_INVALID_POINTER; + if (strlen((char *)src) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + if (strlen((char *)dest) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + if (strlen(path_to_name((char *)src)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; + if (strlen(path_to_name((char *)dest)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; + int32 ret = chk_path(src); + if (ret) return ret; + ret = chk_path_new(dest); + if (ret) return ret; + return file_mv(src, dest); } /* @@ -125,8 +152,10 @@ int32 OS_mv(const char *src, const char *dest) */ int32 OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if (fd_prop == NULL) return OS_FS_ERR_INVALID_POINTER; + if (filedes <= 0 || filedes > MAX_NUM_FILES) return OS_FS_ERR_INVALID_FD; + + return file_FDGetInfo(filedes, fd_prop); } /* @@ -134,8 +163,14 @@ int32 OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) */ int32 OS_FileOpenCheck(char *Filename) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + int32 ret = chk_path(Filename); + if (ret) return OS_FS_ERR_INVALID_POINTER; + + struct fsobj *file = file_find(Filename); + if (file == NULL) return OS_INVALID_POINTER; + if (file->refcnt == 0) return OS_FS_ERROR; + return OS_FS_SUCCESS; + } /* @@ -143,8 +178,11 @@ int32 OS_FileOpenCheck(char *Filename) */ int32 OS_CloseAllFiles(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + uint32 i; + for (i = 1 ; i < MAX_NUM_FILES + 1 ; i++) { + OS_close(i); + } + return OS_FS_SUCCESS; } /* @@ -152,10 +190,13 @@ int32 OS_CloseAllFiles(void) */ int32 OS_CloseFileByName(char *Filename) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; -} + int32 ret = chk_path(Filename); + if (ret) return OS_FS_ERR_INVALID_POINTER; + struct fsobj *file = file_find(Filename); + if (file == NULL || file->filedes == 0) return OS_FS_ERR_INVALID_POINTER; + return OS_close(file->filedes); +} /****************************************************************************** ** Directory API @@ -163,20 +204,25 @@ int32 OS_CloseFileByName(char *Filename) /* * Makes a new directory + * access is not used by cFE */ int32 OS_mkdir(const char *path, uint32 access) { - PANIC("Read Only Filesystem!"); - return 0; + int32 ret = chk_path_new(path); + if (ret) return ret; + return file_mkdir(path, access); } /* * Opens a directory for searching + * TODO: Check for error codes conflicting with real values */ os_dirp_t OS_opendir(const char *path) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if(chk_path(path) != OS_FS_SUCCESS) return NULL; + int32 filedes = file_open(path); + if (filedes == OS_FS_ERROR) return NULL;; + return (os_dirp_t) file_open(path); } /* @@ -184,8 +230,8 @@ os_dirp_t OS_opendir(const char *path) */ int32 OS_closedir(os_dirp_t directory) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if (directory == NULL) return OS_FS_ERR_INVALID_POINTER; + return file_close((int32) directory); } /* @@ -193,7 +239,8 @@ int32 OS_closedir(os_dirp_t directory) */ void OS_rewinddir(os_dirp_t directory) { - PANIC("Unimplemented method!"); // TODO: Implement me! + file_rewinddir(); + return; } /* @@ -201,8 +248,8 @@ void OS_rewinddir(os_dirp_t directory) */ os_dirent_t * OS_readdir(os_dirp_t directory) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if (directory == NULL) return NULL; + return file_readdir( (int32) directory); } /* @@ -210,8 +257,9 @@ os_dirent_t * OS_readdir(os_dirp_t directory) */ int32 OS_rmdir(const char *path) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + int32 ret = chk_path(path); + if (ret) return ret; + return file_rmdir(path); } /****************************************************************************** @@ -220,19 +268,14 @@ int32 OS_rmdir(const char *path) /* * Makes a file system */ -int32 OS_mkfs(char *address,char *devname, char *volname, +int32 OS_mkfs(char *address, char *devname, char *volname, uint32 blocksize, uint32 numblocks) { - uint32 ret = 0; if (address) return OS_FS_ERR_INVALID_POINTER; if (!devname || !volname) return OS_FS_ERR_INVALID_POINTER; if (strlen(devname) >= OS_FS_DEV_NAME_LEN || strlen(volname) >= OS_FS_VOL_NAME_LEN) - return OS_FS_ERROR; - ret = newfs_init(devname, volname, blocksize, numblocks); - if (ret != OS_FS_SUCCESS) return ret; - ret = tar_parse(); - if (ret != OS_FS_SUCCESS) return ret; - return OS_FS_SUCCESS; + return OS_FS_ERR_PATH_TOO_LONG; + return newfs_init(devname, volname, blocksize, numblocks); } /* * Mounts a file system @@ -240,7 +283,7 @@ int32 OS_mkfs(char *address,char *devname, char *volname, int32 OS_mount(const char *devname, char *mountpoint) { if (!devname || !mountpoint) return OS_FS_ERR_INVALID_POINTER; - return mount(devname, mountpoint); + return fs_mount(devname, mountpoint); } /* @@ -260,8 +303,8 @@ int32 OS_initfs(char *address, char *devname, char *volname, uint32 blocksize, u */ int32 OS_rmfs(char *devname) { - PANIC("Read Only Filesystem!"); // TODO: Implement me! - return 0; + if (devname == NULL) return OS_FS_ERR_INVALID_POINTER; + return rmfs(devname); } /* @@ -270,7 +313,7 @@ int32 OS_rmfs(char *devname) int32 OS_unmount(const char *mountpoint) { if (!mountpoint) return OS_FS_ERR_INVALID_POINTER; - return unmount(mountpoint); + return fs_unmount(mountpoint); } /* @@ -278,8 +321,11 @@ int32 OS_unmount(const char *mountpoint) */ int32 OS_fsBlocksFree(const char *name) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + + int32 ret = chk_path(name); + if (ret) return ret; + + return 10; } /* @@ -289,8 +335,11 @@ int32 OS_fsBlocksFree(const char *name) */ int32 OS_fsBytesFree(const char *name, uint64 *bytes_free) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if (bytes_free == NULL) return OS_FS_ERR_INVALID_POINTER; + int32 ret = chk_path(name); + if (ret) return ret; + + return 10 * F_PART_DATA_SIZE; } /* @@ -299,8 +348,7 @@ int32 OS_fsBytesFree(const char *name, uint64 *bytes_free) */ os_fshealth_t OS_chkfs(const char *name, boolean repair) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_ERR_NOT_IMPLEMENTED; } /* @@ -308,8 +356,10 @@ os_fshealth_t OS_chkfs(const char *name, boolean repair) */ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, char * MountPoint) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if (PhysDriveName == NULL || MountPoint == NULL) return OS_FS_ERR_INVALID_POINTER; + int32 ret = chk_path(MountPoint); + if (ret) return ret; + return Filesys_GetPhysDriveName(PhysDriveName, MountPoint); } /* @@ -318,6 +368,10 @@ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, char * MountPoint) */ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) { + if (VirtualPath == NULL || LocalPath == NULL) return OS_FS_ERR_INVALID_POINTER; + int32 ret = chk_path(VirtualPath); + if (ret) return ret; + strcpy(LocalPath, VirtualPath); return OS_FS_SUCCESS; } @@ -327,8 +381,8 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) */ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + if (filesys_info == NULL) return OS_FS_ERR_INVALID_POINTER; + return Filesys_GetFsInfo(filesys_info); } /****************************************************************************** @@ -339,6 +393,5 @@ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) * command to the file specified by the given OSAPI file descriptor */ int32 OS_ShellOutputToFile(char* Cmd, int32 OS_fd) { - PANIC("Read Only Filesystem!"); // TODO: Implement me! - return 0; + return OS_ERR_NOT_IMPLEMENTED; } diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.c b/src/components/implementation/no_interface/cFE_booter/osfilesys.c index 0c5ac1c2b8..42eccbb739 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.c +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.c @@ -1,19 +1,11 @@ #include "cFE_util.h" #include "osfilesys.h" -struct FS fs[MAX_NUM_FS]; +struct fs filesystem[MAX_NUM_FS]; +struct fs *openfs; +struct fsobj *openfile; struct fsobj files[MAX_NUM_FILES]; - -/* - * Notes on this version: - * This is not the final implementation of a file system for the cFE on COS - * For now the file system is read only and staticly allocates for fsobj and FS - * The next step is to write a dumb allocator/deallocator and use it for - * new fs, fsobj, and file data - * I have been intentional to restrict memory specific details to this file - * osfilesys.h and osfiles.c 'should' not care about how FS, fsobj, and data - * are stored in memory. - */ +struct cos_compinfo *ci; /****************************************************************************** ** Tar Level Methods @@ -22,7 +14,7 @@ struct fsobj files[MAX_NUM_FILES]; /* * Loads the position in memory of linked tar file system * Checks for badly linked or no linked tar file. The names given by - * the linker are non-intuative so a description of error checking is given: + * the linker are non-intuitive so a description of error checking is given: * First checks to make sure that symbols have been overwritten by linking * process. Next checks that the size is greater than 0. Finally checks that * the end of the tar is after the start @@ -42,7 +34,11 @@ uint32 tar_load() } /* - * parses a loaded tar into fs[0] + * parses a loaded tar into filesystem[0] + * precondition: tar has been loaded by tar_load, a filesystem has been initialized + * with newfs with the devname of tar + * Postcondition: A proper error code is returned OR the tar is represented in memory + * at filesystem 0 */ uint32 tar_parse() { @@ -50,24 +46,29 @@ uint32 tar_parse() assert(size < INT32_MAX); assert(end - start > 0); assert(size == (size_t) (end - start)); - assert(fs[0].root->filedes == 1); //first fs should be rooted by first file - - if (!fs[0].devname) return OS_FS_ERR_DRIVE_NOT_CREATED; - - struct fsobj *o = fs[0].root; + uint32 i; + openfs = &filesystem[0]; uint32 offset = 0; + struct fsobj *o; while (offset + start < end) { + if (newfile_get(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + //tar ends after two empty records - if ( !(offset + start)[0] && !(offset + start)[TAR_BLOCKSIZE]) return OS_FS_SUCCESS; - - if (tar_cphdr(offset, o)) return OS_FS_ERR_DRIVE_NOT_CREATED; - if (file_insert(o, &fs[0])) return OS_FS_ERR_DRIVE_NOT_CREATED; - //data is alligned to 512 byte blocks. a header is 500 bytes, and - // the file's data begins exactly after the header - // therefor the next header is 500 + o->size rounded up to a mult of 512 - offset += round_to_blocksize(o->size + 500); - if (newfile_get(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + if ( !(offset + start)[0] && !(offset + start)[TAR_BLOCKSIZE]) { + o->filedes = 0; + return OS_FS_SUCCESS; + } + + if (tar_cphdr(offset, o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + if (file_insert(o, offset + start)) return OS_FS_ERR_DRIVE_NOT_CREATED; + + /* + * data is aligned to 512 byte blocks. a header is 500 bytes, and + * the file's data begins exactly after the header + * therefor the next header is 500 + o->size rounded up to a mult of 512 + */ + offset += round_to_blocksize(o->size + 500); } //tar ends before two empty records are found @@ -79,52 +80,60 @@ uint32 tar_parse() */ uint32 tar_cphdr(uint32 tar_offset, struct fsobj *file) { - //TODO: store filenames without paths assert(tar_offset < size); assert(file->filedes > 0); - + struct f_part *part; + newpart_get(&part); + part->memtype = STATIC; char *location = start; location += tar_offset; - file->name = location; + memmove(location + 1, location, strlen(location)); + location[0] = '/'; + file->name = path_to_name(location); if (*(location + strlen(location) - 1) == '/') { - file->type = FSOBJ_DIR; - file->size = 0; + file->type = FSOBJ_DIR; + file->size = 0; } else{ - file->type = FSOBJ_FILE; - file->size = oct_to_dec(location + 124); - file->data = location + 500; + file->type = FSOBJ_FILE; + file->size = oct_to_dec(location + 124); + file->file_part = part; + file->file_part->data = location + 500; } return OS_FS_SUCCESS; } -//this could be more performant bithack -uint32 round_to_blocksize(uint32 offset) -{ - if (offset % TAR_BLOCKSIZE) return offset + (TAR_BLOCKSIZE - (offset % TAR_BLOCKSIZE)); - return offset; -} - /****************************************************************************** ** fsobj Level Methods ******************************************************************************/ -uint32 fsobj_init(struct fsobj *o) +int32 chk_fd(int32 filedes) +{ + if (filedes > OS_MAX_NUM_OPEN_FILES)return OS_FS_ERR_INVALID_FD; + if (filedes == 0) return OS_FS_ERR_INVALID_FD; + + struct fsobj *o = &files[filedes - 1]; + + if (o->filedes != filedes) return OS_FS_ERR_INVALID_FD; + return OS_FS_SUCCESS; +} + +uint32 newpart_get(struct f_part **part) { - assert(o); - assert(o->filedes > 0); - - o->name = "EXAMPLE_NAME"; - o->type = FSOBJ_DIR; - o->size = 0; - o->refcnt = 0; - o->data = NULL; - o->child = o->parent = NULL; - o->next = o->prev = NULL; + if (ci == NULL) { + struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); + ci = &(defci->ci); + } + *part = cos_page_bump_alloc(ci); + assert(part != NULL); + (*part)->next = NULL; + (*part)->prev = NULL; + (*part)->file = NULL; + (*part)->data = (char *) part + sizeof(part); return OS_FS_SUCCESS; } -//finds the next open file +//finds the next free file uint32 newfile_get(struct fsobj **o) { uint32 count = 0; @@ -138,28 +147,25 @@ uint32 newfile_get(struct fsobj **o) return OS_FS_SUCCESS; } -uint32 file_insert(struct fsobj *o, struct FS *filesys) +uint32 file_insert(struct fsobj *o, char *path) { - assert(filesys && filesys->root && filesys->root->filedes); - if (filesys->root == o) return OS_FS_SUCCESS; - - insert(o, filesys->root); - - return OS_FS_SUCCESS; -} + //paths should always begin with '/' but we do not need it here + if (path[0] != '/') return OS_FS_ERR_PATH_INVALID; + path++; -//could be written iteratively to use less stackframe if that becomes an issue -// Root is -uint32 insert(struct fsobj *o, struct fsobj *root) -{ - assert(root && o); - assert(strlen(root->name) < strlen(o->name)); + if (openfs->root == NULL) { + openfs->root = o; + return OS_FS_SUCCESS; + } + assert(o && path && openfs); + assert(openfs->root && openfs->root->filedes); + if (openfs->root == o) return OS_FS_SUCCESS; + struct fsobj *root = openfs->root; + assert(root->name); //loop terminates when it finds a place to put o, either at the end of a //list of children or as the first in an empty children list while (1) { - assert(strcmp(root->name, o->name) !=0 ); - assert(strspn(o->name, root->name) >= strlen(root->name)); //if there is no child, then insert as child if (!root->child) { o->parent = root; @@ -168,9 +174,13 @@ uint32 insert(struct fsobj *o, struct fsobj *root) } root = root->child; + do { + path++; + } while (path[0]!= '/'); + //precondition: root is the first in a non-empty list of children - //postcondition: root is an ancestor of o - while (strspn(o->name, root->name) < strlen(root->name)) { + //postcondition: root is an ancestor of o or o has been inserted in list + while (strspn(path, root->name) < strlen(root->name)) { if (!root->next) { root->next = o; o->prev = root; @@ -185,75 +195,483 @@ uint32 insert(struct fsobj *o, struct fsobj *root) return 0; } -int32 open(const char *path) { - assert(fs[0].root && !fs[1].root); - struct fsobj *root = fs[0].root; - root = find(path, root); - if (!root) return OS_FS_ERROR; - root->refcnt++; - return root->filedes; +int32 file_open(const char *path) { + assert(openfs); + openfs = &(filesystem[0]); + assert(openfs->root); + struct fsobj *file = file_find(path); + if (file == NULL) return OS_FS_ERROR; + assert(1 > file->refcnt); // we do not yet support concurrent file access + file->refcnt++; + file->position.open_part = file->file_part; + file->position.addr = file->position.open_part->data; + file->position.file_offset = 0; + file->position.part_offset = 0; + return file->filedes; } -int32 close(int32 filedes) { +int32 file_close(int32 filedes) { + + int32 ret = chk_fd(filedes); + if (ret) return ret; + uint32 index = filedes + 1; - if (files[index].filedes != filedes) return OS_FS_ERROR; - if (files[index].refcnt < 1) return OS_FS_ERROR; + if (files[index].refcnt < 1) return OS_FS_ERROR; files[index].refcnt--; return OS_FS_SUCCESS; } -int32 read(int32 filedes, void *buffer, uint32 nbytes) { - if (!buffer) return OS_FS_ERR_INVALID_POINTER; - if (files[filedes + 1].filedes != filedes) return OS_FS_ERROR; - if (files[filedes + 1].refcnt < 1) return OS_FS_ERROR; - if (nbytes == 0) return 0; - memcpy(buffer, files[filedes + 1].data, nbytes); +int32 file_read(int32 filedes, void *buffer, uint32 nbytes) +{ + if (!buffer) return OS_FS_ERR_INVALID_POINTER; + int32 ret = chk_fd(filedes); + if (ret) return ret; + + struct fsobj *o = &files[filedes - 1]; + struct f_part *part = o->position.open_part; + + if (o->refcnt < 1) return OS_FS_ERROR; + if (o->type == FSOBJ_DIR) return OS_FS_ERROR; + + // nbytes > number of bytes left in file, only number left are read + if (nbytes > o->size - o->position.file_offset) { + nbytes = o->size - o->position.file_offset; + } + + if (nbytes == 0) return 0; + uint32 bytes_to_read = nbytes; + + if (o->file_part->memtype == DYNAMIC){ + uint32 read_size; //the length of a continuous segment to be read from + while (1) { + read_size = F_PART_DATA_SIZE - o->position.file_offset; + part = o->position.open_part; + + if (bytes_to_read > read_size) { + + memcpy(buffer, &part->data[o->position.part_offset], read_size); + + buffer += read_size; + bytes_to_read -= read_size; + o->position.file_offset += read_size; + + if (part->next == NULL) { + o->position.part_offset = F_PART_DATA_SIZE; + return nbytes - bytes_to_read; + } + + o->position.open_part = part->next; + o->position.part_offset = 0; + o->position.addr = part->data; + + } else if (bytes_to_read == read_size) { + + memcpy(buffer, &part->data[o->position.part_offset], read_size); + + o->position.file_offset += read_size; + o->position.addr += read_size; + + if (part->next == NULL) { + o->position.part_offset = F_PART_DATA_SIZE; + return nbytes; + } + + o->position.open_part = part->next; + o->position.part_offset = 0; + return nbytes; + + // bytes_to_read < the continuous space left on f_part + } else { + memcpy(buffer, &part->data[o->position.part_offset], bytes_to_read); + o->position.part_offset += bytes_to_read; + o->position.file_offset += bytes_to_read; + o->position.addr += bytes_to_read; + return OS_FS_SUCCESS; + } + } + } else { + memcpy(buffer, &part->data[o->position.file_offset], bytes_to_read); + o->position.part_offset += bytes_to_read; + o->position.file_offset += bytes_to_read; + o->position.addr += bytes_to_read; + return nbytes; + } + + PANIC("Unreachable Statement"); + return 0; +} + +int32 file_write(int32 filedes, void *buffer, uint32 nbytes) +{ + if (!buffer) return OS_FS_ERR_INVALID_POINTER; + int32 ret = chk_fd(filedes); + if (ret) return ret; + + struct fsobj *o = &files[filedes - 1]; + + if (o->refcnt < 1) return OS_FS_ERROR; + if (o->file_part->memtype == STATIC)return OS_FS_ERROR; + if (o->type == FSOBJ_DIR) return OS_FS_ERROR; + + if (nbytes == 0) return 0; + uint32 bytes_to_write = nbytes; + uint32 bytes_remaining = F_PART_DATA_SIZE - o->position.part_offset; + + //while there are enough bytes to be written to fill a f_part + while (bytes_to_write > bytes_remaining) { + memcpy(o->position.addr, buffer, bytes_remaining); + o->position.file_offset += bytes_remaining; + buffer += bytes_remaining; + bytes_to_write -= bytes_remaining; + o->position.part_offset = 0; + if (o->position.open_part->next == NULL) { + struct f_part *part; + newpart_get(&part); + part->memtype = DYNAMIC; + part->file = o; + part->next = NULL; + part->prev = o->position.open_part; + o->position.open_part->next = part; + } + + o->position.open_part = o->position.open_part->next; + o->position.addr = o->position.open_part->data; + bytes_remaining = F_PART_DATA_SIZE - o->position.part_offset; + } + + //bytes_to_write < bytes_remaining + memcpy(o->position.addr, buffer, bytes_to_write); + o->position.addr += bytes_to_write; + o->position.part_offset += bytes_to_write; + o->position.file_offset += bytes_to_write; + if (o->size < o->position.file_offset) { + o->size = o->position.file_offset; + } return nbytes; } -struct fsobj *find(const char *path, struct fsobj *root) +void file_rewinddir() { - assert(root); - assert(strlen(root->name) < strlen(path)); - while (1) { - assert(strcmp(root->name, path) !=0 ); - assert(strspn(path, root->name) >= strlen(root->name)); - if (!root->child) return NULL; + if (!openfile) return; + if (openfile->parent == NULL) return; + assert(openfile->parent->child); + openfile = openfile->parent->child; + return; +} - root = root->child; +struct fsobj *file_find(const char *path) +{ + //paths should always begin with '/' dir names do not + if (path[0] != '/') return NULL; + path++; + + assert(path); + if(!openfs || !openfs->root) return NULL; + struct fsobj *root = openfs->root; + assert(root && root->name); + if (strlen(root->name) > strlen(path)) return NULL; + + while (1) { + // iterate through linked list of children while (strspn(path, root->name) < strlen(root->name)) { if (!strcmp(root->name, path)) return root; if (!root->next) return NULL; root = root->next; } + //root must now be parent of final location + if (!strcmp(root->name, path)) return root; + assert(strspn(path, root->name) >= strlen(root->name)); + if (!root->child) return NULL; + + root = root->child; + while (path[0] != '/') { + path++; + } + path++; + } PANIC("Unreachable Statement"); return NULL; } +int32 file_mkdir(const char *path, uint32 access) +{ + assert(path); + struct fsobj *o; + if (newfile_get(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + o->name = path_to_name((char *) path); + o->type = FSOBJ_DIR; + o->size = 0; + if (file_insert(o, (char *) path)) return OS_FS_ERR_PATH_INVALID; + + return OS_FS_SUCCESS; +} + +int32 file_rmdir(const char *path) +{ + assert(path); + struct fsobj *root = file_find(path); + if (root == NULL) return OS_FS_ERROR; + struct fsobj *cur; + + while (root->child) { + + // if cur is the last leaf in a list + if (cur->next == NULL && cur->child == NULL) { + if (cur->prev != NULL) { + assert(cur->prev->next == cur); + cur = cur->prev; + rm(cur->next); + } + else { + assert(cur->parent->child == cur); + cur = cur->parent; + rm(cur->child); + } + } else if (cur->child != NULL) { + cur = cur->child; + } else { //cur->next !=NULL + cur = cur->next; + } + } + + rm(root); + return OS_FS_SUCCESS; +} + +int32 file_creat(const char *path) +{ + assert(path); + struct fsobj *o; + if (newfile_get(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + o->name = (char *) path; + o->type = FSOBJ_FILE; + o->size = 0; + struct f_part *part; + newpart_get(&part); + part->memtype = DYNAMIC; + o->file_part = part; + part->file = o; + part->data = (char *) part + sizeof(part); + if (file_insert(o, (char *) path)) return OS_FS_ERR_DRIVE_NOT_CREATED; + + return OS_FS_SUCCESS; +} + +int32 file_remove(const char *path) +{ + struct fsobj *file = file_find(path); + if (!file) return OS_FS_ERR_PATH_INVALID; + rm(file); + return OS_FS_SUCCESS; +} + +int32 file_rename(const char *old_filename, const char *new_filename) +{ + struct fsobj *file = file_find(old_filename); + if (!file) return OS_FS_ERR_PATH_INVALID; + file->name = path_to_name((char *)new_filename); + return OS_FS_SUCCESS; +} + +// This is not a full implementation of all that is required by posix +// but it is enough to pass UT and is all the info relevant to this FS +int32 file_stat(const char *path, os_fstat_t *filestats) +{ + struct fsobj *file = file_find(path); + if (file == NULL) return OS_FS_ERROR; + filestats->st_dev = 0; + filestats->st_ino = file->filedes; + if (file->type == FSOBJ_FILE) { + filestats->st_mode = S_IFREG; + } + if (file->type == FSOBJ_DIR) { + filestats->st_mode = S_IFDIR; + } + filestats->st_size = file->size; + filestats->st_blksize = F_PART_DATA_SIZE; + filestats->st_blocks = 1 + file->size % F_PART_DATA_SIZE; + return OS_FS_SUCCESS; +} + +int32 file_lseek(int32 filedes, int32 offset, uint32 whence) +{ + int32 ret = chk_fd(filedes); + if (ret) return ret; + + struct fsobj *o = &files[filedes - 1]; + uint32 target_offset = 0; + + // wasnt sure if it should be legal to pass negative offset, went with yes + if (whence == SEEK_SET) { + + if (offset < 0) return OS_FS_ERROR; + target_offset = offset; + + } else if (whence == SEEK_CUR) { + + if (offset + (int32) o->position.file_offset < 0) return OS_FS_ERROR; + target_offset += o->position.file_offset; + + } else if (whence == SEEK_END) { + + if (offset + (int32) o->position.file_offset < 0) return OS_FS_ERROR; + target_offset += o->size; + + } else { + return OS_FS_ERROR; + } + // you cannot write past the end of a static file + if ( target_offset > o->size && o->file_part->memtype == STATIC) { + return OS_FS_ERROR; + } + + o->position.open_part = o->file_part; + o->position.file_offset = 0; + + while ( target_offset - o->position.file_offset > F_PART_DATA_SIZE) { + + // seeking past the end of a file writes zeros until that position + if (o->position.open_part->next == NULL) { + struct f_part *part; + newpart_get(&part); + part->memtype = DYNAMIC; + part->file = o; + part->next = NULL; + part->prev = o->position.open_part; + o->position.open_part->next = part; + } + + o->position.open_part = o->position.open_part->next; + o->position.file_offset += F_PART_DATA_SIZE; + + } + + o->position.file_offset += target_offset % F_PART_DATA_SIZE; + o->position.part_offset = target_offset % F_PART_DATA_SIZE; + o->position.addr = o->position.open_part->data + target_offset % F_PART_DATA_SIZE; + + if (o->position.file_offset > size) { + size = o->position.file_offset; + } + + assert(o->position.file_offset == target_offset); + return target_offset; +} + +int32 file_cp(const char *src, const char *dest) +{ + struct fsobj *file_src, *file_dest; + int32 src_desc = file_open(src); + if (src_desc <= 0 || src_desc > MAX_NUM_FILES) return OS_FS_ERROR; + file_src = &files[src_desc - 1]; + + newfile_get(&file_dest); + + if(file_src == NULL || file_src->type == FSOBJ_DIR){ + return OS_FS_ERR_INVALID_POINTER; + } + + file_insert(file_dest, (char *) dest); + file_dest->name = path_to_name( (char *) dest); + file_dest->size = 0; + file_dest->mode = file_src->mode; + file_dest->type = FSOBJ_FILE; + + /* + * yeah, this is sub-optimal + * but I don't expect this to be called at all, much less with large files + */ + + uint32 dest_desc = file_dest->filedes; + + char temp_buff[file_src->size]; + file_read(src_desc, temp_buff,file_src->size); + file_write(file_dest->filedes, temp_buff, file_src->size); + + return OS_FS_SUCCESS; +} + +int32 file_mv(const char *src, const char *dest) +{ + + struct fsobj *file; + uint32 desc = file_open(src); + if (desc <= 0 || desc > MAX_NUM_FILES) return OS_FS_ERROR; + file = &files[desc - 1]; + + if (file->next) { + file->next->prev = file->prev; + } + if (file->prev) { + file->prev->next = file->next; + } + if (file->parent->child == file) { + file->parent->child = file->next; + } + + file_insert(file, (char *) dest); + file->name = path_to_name((char *) dest); + return OS_FS_SUCCESS; +} + +/* + * currently conflates name and path. + * perhaps it would be a good idea to track path in fsobj + */ +int32 file_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) +{ + struct fsobj *o = &files[filedes - 1]; + + if (o->filedes != filedes) return OS_FS_ERR_INVALID_FD; + if (o->refcnt > 0) return OS_FS_ERROR; + fd_prop->OSfd = o->filedes; + memcpy(&fd_prop->Path,o->name, strlen(o->name)); + fd_prop->User = 0; + fd_prop->IsValid = 1; + return OS_FS_SUCCESS; +} + + +struct dirent *file_readdir(int32 filedes) +{ + if () + struct dirent *p = NULL;i + return p; +} + /****************************************************************************** ** fs Level Methods ******************************************************************************/ -uint32 mount(const char *devname, char *mountpoint) +uint32 fs_mount(const char *devname, char *mountpoint) { uint32 i; - for (i=0 ; i < MAX_NUM_FS && fs[i].devname != NULL ; i++) { - if (!strcmp(fs[i].devname, devname)) { - fs[i].mountpoint = mountpoint; + assert(devname); + for (i=0 ; i < MAX_NUM_FS && filesystem[i].devname != NULL ; i++) { + if (!strcmp(filesystem[i].devname, devname)) { + + struct fsobj *o; + if (newfile_get(&o)) return OS_FS_ERROR; + filesystem[i].mountpoint = mountpoint; + openfs = &filesystem[i]; + if (filesystem[i].root == NULL) { + file_mkdir(mountpoint, 0); + } return OS_FS_SUCCESS; } } return OS_FS_ERROR; } -uint32 unmount(const char *mountpoint) { +uint32 fs_unmount(const char *mountpoint) { uint32 i; - for (i=0 ; i < MAX_NUM_FS ; i++) { - if (mountpoint != NULL && !strcmp(fs[i].mountpoint, mountpoint)) { - fs[i].mountpoint = NULL; + assert(mountpoint); + for (i = 0 ; i < MAX_NUM_FS && filesystem[i].mountpoint != NULL ; i++) { + if (mountpoint != NULL && !strcmp(filesystem[i].mountpoint, mountpoint)) { + filesystem[i].mountpoint = NULL; return OS_FS_SUCCESS; } } @@ -263,18 +681,14 @@ uint32 unmount(const char *mountpoint) { /* * Given a pointer to an FS, inits values and fsobj for root */ -uint32 fs_init(struct FS *filesys, char *devname, char *volname, uint32 blocksize, uint32 numblocks) +uint32 fs_init(struct fs *filesys, char *devname, char *volname, uint32 blocksize, uint32 numblocks) { - struct fsobj *o = NULL; - if (newfile_get(&o)) return OS_FS_ERROR; - if (fsobj_init(o)) return OS_FS_ERROR; filesys->devname = devname; + filesys->volname = volname; filesys->mountpoint = ""; filesys->blocksize = blocksize; filesys->numblocks = numblocks; - filesys->root = o; - filesys->next = NULL; - filesys->prev = NULL; + filesys->root = NULL; return OS_FS_SUCCESS; } @@ -286,23 +700,75 @@ uint32 newfs_init(char *devname, char *volname, uint32 blocksize, uint32 numbloc if (strlen(devname) >= OS_FS_DEV_NAME_LEN || strlen(volname) >= OS_FS_VOL_NAME_LEN) return OS_FS_ERROR; - //the first filesystem is always the tar - if (!fs[0].devname) { + + // the first filesystem is always the tar + if (filesystem[0].devname == NULL) { ret = tar_load(); if (ret != OS_FS_SUCCESS) return ret; - ret = fs_init(&fs[0], devname, volname, blocksize, numblocks); + ret = fs_init(&filesystem[0], devname, volname, blocksize, numblocks); if (ret != OS_FS_SUCCESS) return ret; return OS_FS_SUCCESS; } - while (count < MAX_NUM_FS && fs[count].devname) { + // filesystem[0] is initialized during OS_FS_Init + if (strcmp(devname, filesystem[0].devname) == 0) return OS_SUCCESS; + + while (count < MAX_NUM_FS && filesystem[count].devname) { count++; } if (count == MAX_NUM_FS) return OS_FS_ERR_DRIVE_NOT_CREATED; - ret = fs_init(&fs[count], devname, volname, blocksize, numblocks); + ret = fs_init(&filesystem[count], devname, volname, blocksize, numblocks); if (ret !=OS_FS_SUCCESS) return ret; + openfs = &filesystem[count]; + return OS_FS_SUCCESS; +} + +int32 rmfs(char *devname) +{ + if (!devname) return OS_FS_ERR_INVALID_POINTER; + + uint32 i; + for (i = 0 ; i < MAX_NUM_FS && filesystem[i].devname != NULL ; i++) { + if (devname && filesystem[i].devname && !strcmp(filesystem[i].devname,devname)) { + filesystem[i].devname = NULL; + filesystem[i].volname = NULL; + filesystem[i].mountpoint = NULL; + filesystem[i].blocksize = 0; + filesystem[i].numblocks = 0; + filesystem[i].root = NULL; + return OS_FS_SUCCESS; + } + } + return OS_FS_ERROR; + +} + +int32 Filesys_GetPhysDriveName(char * PhysDriveName, char * MountPoint) +{ + uint32 i; + for (i = 0 ; i < MAX_NUM_FS && filesystem[i].devname != NULL ; i++) { + if (filesystem[i].mountpoint && !strcmp(filesystem[i].mountpoint,MountPoint)) { + memcpy(PhysDriveName, "RAM FS\n",7); + return OS_FS_SUCCESS; + } + } + return OS_FS_ERROR; +} +int32 Filesys_GetFsInfo(os_fsinfo_t *filesys_info) +{ + filesys_info->MaxFds = MAX_NUM_FILES; + uint32 i, count = 0; + for (i = 0 ; i < MAX_NUM_FILES ; i++) { + if (files[i].filedes == 0) count++; + } + filesys_info->FreeFds = count; + filesys_info->MaxVolumes = MAX_NUM_FS; + for (i = 0, count = 0 ; i < MAX_NUM_FS ; i++){ + if (filesystem[i].devname == NULL) count++; + } + filesys_info->FreeVolumes = count; return OS_FS_SUCCESS; } diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.h b/src/components/implementation/no_interface/cFE_booter/osfilesys.h index 3770f2b03f..3059014774 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.h +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.h @@ -1,9 +1,15 @@ #include "cFE_util.h" -#include + #include "gen/common_types.h" #include "gen/osapi.h" #include "gen/osapi-os-filesys.h" +#include + +#include +#include +#include + // Not to be confused with similar OSAL constants. // These are only to define size of statically allocated data #define MAX_NUM_FS 3 @@ -12,6 +18,9 @@ #define TAR_BLOCKSIZE 512 #define INT32_MAX 0x7FFFFFF //2^31 - 1 +// a page is 4096, size of f_part is 5 values * 4 bytes +#define F_PART_DATA_SIZE 4096-4*5 + //should be overwritten by linking step in build process __attribute__((weak)) char _binary_cFEfs_tar_size=0; __attribute__((weak)) char _binary_cFEfs_tar_start=0; @@ -27,41 +36,64 @@ typedef enum { FSOBJ_DIR, } fsobj_type_t; +struct file_position { + struct f_part *open_part; //part of file being read/written to + uint32 part_offset; //offset into part's data + uint32 file_offset; //position within file as a whole + char *addr; +}; + struct fsobj { char *name; - int32 filedes; // 0 for free file, posative for tracked file + int32 filedes; // 0 for free file, positive for tracked file fsobj_type_t type; size_t size; - uint32 refcnt; //number of programs which have opened it - char *data; + struct file_position position; + uint32 refcnt; //number of threads which have opened it + uint32 mode; + struct f_part *file_part; struct fsobj *next, *prev; - struct fsobj *child, *parent; /* child != NULL iff type = dir */ + struct fsobj *child, *parent; // child != NULL iff type = dir +}; + +typedef enum { + STATIC, + DYNAMIC, +} fpart_type; + +struct f_part { + struct fsobj *file; + struct f_part *next, *prev; + fpart_type memtype; + char *data; }; -struct FS { +struct fs { char *devname; char *volname; char *mountpoint; uint32 blocksize; uint32 numblocks; struct fsobj *root; - struct FS *next, *prev; }; /****************************************************************************** ** Tar Level Methods ******************************************************************************/ +uint32 FS_entrypoint(); +uint32 FS_posttest(); +uint32 BFT(struct fsobj *o); + uint32 tar_load(); + uint32 tar_parse(); int32 tar_read(uint32 offset, char *buf, uint32 req_sz); uint32 tar_cphdr(uint32 tar_offset, struct fsobj *file); -uint32 round_to_blocksize(uint32 offset); - static inline uint32 oct_to_dec(char *oct) { int32 i, base; @@ -80,34 +112,126 @@ static inline uint32 oct_to_dec(char *oct) return tot; } +//this could be more performant bithack +static inline uint32 round_to_blocksize(uint32 offset) +{ + if (offset % TAR_BLOCKSIZE) return offset + (TAR_BLOCKSIZE - (offset % TAR_BLOCKSIZE)); + return offset; +} + + +static inline char *path_to_name(char *path){ + + uint32 path_len = strlen(path), offset; + assert(path[path_len - 2] != '/' && path_len > 1); + + // offset is second to last char in path, because last char may be trailing / + for ( offset = path_len - 2 ; path[offset] != '/' && offset > 0 ; offset--) { + //do nothing + } + assert(0 < strlen(path + offset + 1)); + return path + offset + 1; +} + /****************************************************************************** ** fsobj Level Methods ******************************************************************************/ +static inline int32 rm(struct fsobj *o) +{ + assert(o && o->child == NULL); + + // if o is first in list of children + if (o->prev == NULL && o->parent) { + assert(o->parent->child == o); + // if next = null this still works + o->parent->child = o->next; + } -uint32 fsobj_init(struct fsobj *o); + // these still work if next or prev = null + if (o->prev) o->prev->next = o->next; + if (o->next) o->next->prev = o->prev; + + //we do not do deallocate file data but we do reuse fsobj + o->name = NULL; + o->filedes = 0; + o->size = 0; + o->refcnt = 0; + o->mode = 0; + o->file_part = NULL; + return OS_FS_SUCCESS; +} + +uint32 newpart_get(struct f_part **part); uint32 newfile_get(struct fsobj **o); -uint32 file_insert(struct fsobj *o, struct FS *fs); +uint32 file_insert(struct fsobj *o, char *path); + +int32 file_open(const char *path); + +int32 file_close(int32 filedes); + +void file_rewinddir(); + +int32 file_read(int32 filedes, void *buffer, uint32 nbytes); + +int32 file_write(int32 filedes, void *buffer, uint32 nbytes); + +struct fsobj *file_find(const char *path); + +int32 file_mkdir(const char *path, uint32 access); + +int32 file_rmdir(const char *path); -uint32 insert(struct fsobj *o, struct fsobj *root); +int32 file_creat(const char *path); -int32 open(const char *path); +int32 file_remove(const char *path); -int32 close(int32 filedes); +int32 file_rename(const char *old_filename, const char *new_filename); -int32 read(int32 filedes, void *buffer, uint32 nbytes); +int32 file_cp(const char *src, const char *dest); -struct fsobj *find(const char *path, struct fsobj *root); +int32 file_mv(const char *src, const char *dest); +int32 file_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop); + +int32 file_stat(const char *path, os_fstat_t *filestats); + +int32 file_lseek(int32 filedes, int32 offset, uint32 whence); + +struct dirent *file_readdir(int32 filedes); /****************************************************************************** ** fs Level Methods ******************************************************************************/ -uint32 mount(const char *devname, char *mountpoint); +// chk_path checks if a path is the right format for a path, and if it exits +static inline int32 chk_path(const char *path) +{ + if (path == NULL) return OS_FS_ERR_INVALID_POINTER; + if (strlen(path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + if (path[0] != '/') return OS_FS_ERR_PATH_INVALID; + if (file_find(path) == NULL) return OS_FS_ERR_PATH_INVALID; + return 0; +} + +// chk_path_new is for files that should not already be in the filesystem +static inline int32 chk_path_new(const char *path) +{ + if (path == NULL) return OS_FS_ERR_INVALID_POINTER; + if (strlen(path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + return OS_FS_SUCCESS; +} + +uint32 fs_mount(const char *devname, char *mountpoint); -uint32 unmount(const char *mountpoint); +uint32 fs_unmount(const char *mountpoint); -uint32 fs_init(struct FS *filesys, char *devname, char *volname, uint32 blocksize, uint32 numblocks); +uint32 fs_init(struct fs *filesys, char *devname, char *volname, uint32 blocksize, uint32 numblocks); uint32 newfs_init(char *defilvname, char *volname, uint32 blocksize, uint32 numblocks); + +int32 rmfs(char *devname); + +int32 Filesys_GetPhysDriveName(char * PhysDriveName, char * MountPoint); + +int32 Filesys_GetFsInfo(os_fsinfo_t *finesys_info); From 5a533f5ddf9a58fa24fcf7d7176c667e358c5969 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sun, 16 Jul 2017 15:16:45 -0400 Subject: [PATCH 065/122] Update cFE_booter's copy of the sl library --- .../no_interface/cFE_booter/Makefile | 2 +- .../no_interface/cFE_booter/ostask.c | 39 +-- .../no_interface/cFE_booter/sl.c | 268 ++++++++++++++++-- .../no_interface/cFE_booter/sl.h | 170 +++++++---- .../no_interface/cFE_booter/sl_consts.h | 3 +- .../no_interface/cFE_booter/sl_mod_fprr.c | 45 ++- .../no_interface/cFE_booter/sl_plugins.h | 4 - .../no_interface/cFE_booter/sl_thd.h | 7 + .../cFE_booter/sl_thd_static_backend.c | 8 +- 9 files changed, 419 insertions(+), 127 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index 866068b92e..428deee4f9 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -4,7 +4,7 @@ COMPONENT=cFE_booter.o INTERFACES= DEPENDENCIES= IF_LIB:=./composite_cFE.o $(wildcard test/*.o) -ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api -lcos_defkernel_api +ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api -lcos_defkernel_api -lheap include ../../Makefile.subsubdir CFLAGS += -I./gen -I ./test/shared $(CPPFLAGS) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 099cfb4f94..68d5e964ea 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -22,7 +22,6 @@ void OS_SchedulerStart(cos_thd_fn_t main_delegate) { struct sl_thd* main_delegate_thread = sl_thd_alloc(main_delegate, NULL); union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = 255}}; sl_thd_param_set(main_delegate_thread, sp.v); - main_delegate_thread_id = main_delegate_thread->thdid; sl_sched_loop(); @@ -60,7 +59,6 @@ int is_thread_name_taken(const char* name) { */ // Necessary to control the number of created tasks -// FIXME: All tasks have the same priority! // TODO: Implement flags int32 OS_TaskCreate(uint32 *task_id, const char *task_name, osal_task_entry function_pointer, @@ -96,7 +94,7 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, struct sl_thd* thd = sl_thd_alloc(osal_task_entry_wrapper, function_pointer); assert(thd); - union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = 255}}; + union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = priority}}; sl_thd_param_set(thd, sp.v); struct sl_thd_policy* policy = sl_mod_thd_policy_get(thd); @@ -115,14 +113,9 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, int32 OS_TaskDelete(uint32 task_id) { - int32 result = OS_SUCCESS; - - sl_cs_enter(); - struct sl_thd* thd = sl_thd_lkup(task_id); if(!thd) { - result = OS_ERR_INVALID_ID; - goto exit; + return OS_ERR_INVALID_ID; } @@ -135,10 +128,7 @@ int32 OS_TaskDelete(uint32 task_id) sl_thd_free(thd); -exit: - sl_cs_exit(); - - return result; + return OS_SUCCESS; } uint32 OS_TaskGetId(void) @@ -162,13 +152,8 @@ int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer) int32 OS_TaskDelay(uint32 millisecond) { - // TODO: Use Phanis extension - microsec_t start_time = sl_now_usec(); - - while((sl_now_usec() - start_time) / 1000 < millisecond) { - // FIXME: Use an actual timeout once we have that - sl_thd_yield(0); - } + cycles_t wakeup = sl_now() + sl_usec2cyc(millisecond * 1000); + sl_thd_block_timeout(0, wakeup); return OS_SUCCESS; } @@ -183,7 +168,7 @@ int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) return OS_ERR_INVALID_ID; } - union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = 255}}; + union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = new_priority}}; sl_thd_param_set(thd, sp.v); return OS_SUCCESS; @@ -551,8 +536,9 @@ int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint } sl_lock_release(&semaphore_data_lock); - // FIXME: Do an actually sensible yield here! - sl_thd_yield(0); + // TODO: Do something smarter than blocking for 10 milliseconds + cycles_t timeout = sl_now() + sl_usec2cyc(10000); + sl_thd_block_timeout(0, timeout); sl_lock_take(&semaphore_data_lock); } @@ -587,8 +573,9 @@ int32 OS_SemaphoreTimedWait(struct semaphore* semaphores, uint32 max_semaphores, && semaphores[sem_id].count == 0 && (sl_now_usec() - start_time) < max_wait) { sl_lock_release(&semaphore_data_lock); - // FIXME: Do an actually sensible yield here! - sl_thd_yield(0); + // TODO: Do something smarter than blocking for 2 milliseconds + cycles_t timeout = sl_now() + sl_usec2cyc(2000); + sl_thd_block_timeout(0, timeout); sl_lock_take(&semaphore_data_lock); } @@ -791,6 +778,6 @@ int32 OS_CountSemGetInfo(uint32 sem_id, OS_count_sem_prop_t *count_prop) exit: sl_lock_release(&semaphore_data_lock); - + return result; } diff --git a/src/components/implementation/no_interface/cFE_booter/sl.c b/src/components/implementation/no_interface/cFE_booter/sl.c index fba297ec66..8f567c9378 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.c +++ b/src/components/implementation/no_interface/cFE_booter/sl.c @@ -11,6 +11,8 @@ #include #include +#include "cFE_util.h" + struct sl_global sl_global_data; /* @@ -51,6 +53,100 @@ sl_cs_exit_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, sched return 0; } +/* Timeout and wakeup functionality */ +/* + * TODO: + * (comments from Gabe) + * We likely want to replace all of this with rb-tree with nodes internal to the threads. + * This heap is fast, but the static memory allocation is not great. + */ +struct timeout_heap { + struct heap h; + void *data[SL_MAX_NUM_THDS]; +}; + +static struct timeout_heap timeout_heap; + +struct heap * +sl_timeout_heap(void) +{ return &timeout_heap.h; } + +static inline void +sl_timeout_block(struct sl_thd *t, cycles_t timeout) +{ + assert(t && t->timeout_idx == -1); /* not already in heap */ + assert(heap_size(sl_timeout_heap()) < SL_MAX_NUM_THDS); + + if (!timeout) { + cycles_t tmp = t->periodic_cycs; + + assert(t->period); + t->periodic_cycs += t->period; /* implicit timeout = task period */ + assert(tmp < t->periodic_cycs); /* wraparound check */ + t->timeout_cycs = t->periodic_cycs; + } else { + t->timeout_cycs = timeout; + } + + t->wakeup_cycs = 0; + heap_add(sl_timeout_heap(), t); +} + +static inline void +sl_timeout_remove(struct sl_thd *t) +{ + assert(t && t->timeout_idx > 0); + assert(heap_size(sl_timeout_heap())); + + heap_remove(sl_timeout_heap(), t->timeout_idx); + t->timeout_idx = -1; +} + +static int +__sl_timeout_compare_min(void *a, void *b) +{ + /* FIXME: logic for wraparound in either timeout_cycs */ + return ((struct sl_thd *)a)->timeout_cycs <= ((struct sl_thd *)b)->timeout_cycs; +} + +static void +__sl_timeout_update_idx(void *e, int pos) +{ ((struct sl_thd *)e)->timeout_idx = pos; } + +static void +sl_timeout_init(void) +{ + sl_timeout_period(SL_PERIOD_US); + heap_init(sl_timeout_heap(), SL_MAX_NUM_THDS, __sl_timeout_compare_min, __sl_timeout_update_idx); +} + +/* + * @return: 1 if it's already WOKEN. + * 0 if it successfully blocked in this call. + */ +int +sl_thd_block_no_cs(struct sl_thd *t, sl_thd_state block_type) +{ + assert(t); + assert(block_type == SL_THD_BLOCKED_TIMEOUT || block_type == SL_THD_BLOCKED); + + if (unlikely(t->state == SL_THD_WOKEN)) { + t->state = SL_THD_RUNNABLE; + return 1; + } + + + if (t->state != SL_THD_RUNNABLE) { + printc("state = %d\n", (int) t->state); + } + + assert(t->state == SL_THD_RUNNABLE); + t->state = block_type; + sl_mod_block(sl_mod_thd_policy_get(t)); + + return 0; +} + void sl_thd_block(thdid_t tid) { @@ -61,40 +157,126 @@ sl_thd_block(thdid_t tid) sl_cs_enter(); t = sl_thd_curr(); - if (unlikely(t->state == SL_THD_WOKEN)) { - t->state = SL_THD_RUNNABLE; + if (t->state == SL_THD_FREE) goto done; + if (sl_thd_block_no_cs(t, SL_THD_BLOCKED)) { sl_cs_exit(); return; } - assert(t->state == SL_THD_RUNNABLE); - t->state = SL_THD_BLOCKED; - sl_mod_block(sl_mod_thd_policy_get(t)); +done: sl_cs_exit_schedule(); return; } -void -sl_thd_wakeup(thdid_t tid) +/* + * if timeout == 0, blocks on timeout = last periodic wakeup + task period + * @return: 0 if blocked in this call. 1 if already WOKEN! + */ +static inline int +sl_thd_block_timeout_intern(thdid_t tid, cycles_t timeout) { struct sl_thd *t; - thdcap_t thdcap; - tcap_t tcap; - tcap_prio_t prio; sl_cs_enter(); - t = sl_thd_lkup(tid); - if (unlikely(!t)) goto done; + t = sl_thd_curr(); + + if (t->state == SL_THD_FREE) goto done; + if (sl_thd_block_no_cs(t, SL_THD_BLOCKED_TIMEOUT)) { + sl_cs_exit(); + return 1; + } + + + assert(timeout || t->period); + sl_timeout_block(t, timeout); + +done: + sl_cs_exit_schedule(); + + return 0; +} + +cycles_t +sl_thd_block_timeout(thdid_t tid, cycles_t abs_timeout) +{ + cycles_t jitter = 0, wcycs, tcycs; + struct sl_thd *t = sl_thd_curr(); + + /* TODO: dependencies not yet supported */ + assert(!tid); + + if (unlikely(!abs_timeout)) { + sl_thd_block(tid); + goto done; + } + + if (sl_thd_block_timeout_intern(tid, abs_timeout)) goto done; + wcycs = t->wakeup_cycs; + tcycs = t->timeout_cycs; + if (wcycs > tcycs) jitter = wcycs - tcycs; + +done: + return jitter; +} + +unsigned int +sl_thd_block_periodic(thdid_t tid) +{ + cycles_t wcycs, pcycs; + unsigned int jitter = 0; + struct sl_thd *t = sl_thd_curr(); + + /* TODO: dependencies not yet supported */ + assert(!tid); + + if (sl_thd_block_timeout_intern(tid, 0)) goto done; + wcycs = t->wakeup_cycs; + pcycs = t->periodic_cycs; + if (wcycs > pcycs) jitter = ((unsigned int)((wcycs - pcycs) / t->period)) + 1; + +done: + return jitter; +} + +/* + * @return: 1 if it's already RUNNABLE. + * 0 if it was woken up in this call + */ +int +sl_thd_wakeup_no_cs(struct sl_thd *t) +{ + assert(t); if (unlikely(t->state == SL_THD_RUNNABLE)) { t->state = SL_THD_WOKEN; - goto done; + return 1; } - assert(t->state == SL_THD_BLOCKED); + if (! (t->state == SL_THD_BLOCKED || t->state == SL_THD_BLOCKED_TIMEOUT)) { + printc("state = %d", (int) t->state); + } + /* TODO: for AEP threads, wakeup events from kernel could be level-triggered. */ + assert(t->state == SL_THD_BLOCKED || t->state == SL_THD_BLOCKED_TIMEOUT); t->state = SL_THD_RUNNABLE; sl_mod_wakeup(sl_mod_thd_policy_get(t)); + + return 0; +} + +void +sl_thd_wakeup(thdid_t tid) +{ + struct sl_thd *t; + tcap_t tcap; + tcap_prio_t prio; + + sl_cs_enter(); + t = sl_thd_lkup(tid); + if (unlikely(!t)) goto done; + + if (t->state == SL_THD_BLOCKED_TIMEOUT) sl_timeout_remove(t); + if(sl_thd_wakeup_no_cs(t)) goto done; sl_cs_exit_schedule(); return; @@ -112,6 +294,7 @@ sl_thd_yield_cs_exit(thdid_t tid) struct sl_thd *to = sl_thd_lkup(tid); assert(to); + assert(to->state == SL_THD_RUNNABLE); sl_cs_exit_switchto(to); } else { sl_mod_yield(sl_mod_thd_policy_get(t), NULL); @@ -129,18 +312,23 @@ sl_thd_yield(thdid_t tid) static struct sl_thd * sl_thd_alloc_init(thdid_t tid, thdcap_t thdcap) { - struct sl_thd_policy *tp = NULL; - struct sl_thd *t = NULL; + struct sl_thd_policy *tp = NULL; + struct sl_thd *t = NULL; - tp = sl_thd_alloc_backend(tid); + tp = sl_thd_alloc_backend(tid); if (!tp) goto done; - t = sl_mod_thd_get(tp); + t = sl_mod_thd_get(tp); - t->thdid = tid; - t->thdcap = thdcap; - t->state = SL_THD_RUNNABLE; + t->thdid = tid; + t->thdcap = thdcap; + t->state = SL_THD_RUNNABLE; sl_thd_index_add_backend(sl_mod_thd_policy_get(t)); + t->period = t->timeout_cycs = t->periodic_cycs = 0; + t->wakeup_cycs = 0; + t->timeout_idx = -1; + t->prio = TCAP_PRIO_MIN; + done: return t; } @@ -179,10 +367,27 @@ sl_thd_comp_alloc(struct cos_defcompinfo *comp) void sl_thd_free(struct sl_thd *t) { - sl_thd_index_rem_backend(sl_mod_thd_policy_get(t)); - t->state = SL_THD_FREE; - /* TODO: add logic for the graveyard to delay this deallocation if t == current */ - sl_thd_free_backend(sl_mod_thd_policy_get(t)); + struct sl_thd *ct = sl_thd_curr(); + + sl_cs_enter(); + /* remove the thread from the timeout queue before freeing it */ + if (t->state == SL_THD_BLOCKED_TIMEOUT) { + assert(t != ct); + sl_timeout_remove(t); + } + + sl_thd_index_rem_backend(sl_mod_thd_policy_get(t)); + t->state = SL_THD_FREE; + /* TODO: add logic for the graveyard to delay this deallocation if t == current */ + sl_thd_free_backend(sl_mod_thd_policy_get(t)); + + if (unlikely(t == ct)) { + sl_cs_exit_schedule(); + /* should never get here */ + assert(0); + } + + sl_cs_exit(); } void @@ -192,6 +397,17 @@ sl_thd_param_set(struct sl_thd *t, sched_param_t sp) unsigned int value; sched_param_get(sp, &type, &value); + + switch (type) { + case SCHEDP_WINDOW: + { + t->period = sl_usec2cyc(value); + t->periodic_cycs = sl_now(); /* TODO: synchronize for all tasks */ + break; + } + default: break; + } + sl_mod_thd_param_set(sl_mod_thd_policy_get(t), type, value); } @@ -223,7 +439,7 @@ sl_init(void) sl_thd_init_backend(); sl_mod_init(); - sl_timeout_mod_init(); + sl_timeout_init(); /* Create the scheduler thread for us */ g->sched_thd = sl_thd_alloc_init(cos_thdid(), BOOT_CAPTBL_SELF_INITTHD_BASE); diff --git a/src/components/implementation/no_interface/cFE_booter/sl.h b/src/components/implementation/no_interface/cFE_booter/sl.h index 25e5cc0995..96ec90eb53 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.h +++ b/src/components/implementation/no_interface/cFE_booter/sl.h @@ -35,6 +35,8 @@ #include #include #include +#include +#include /* Critical section (cs) API to protect scheduler data-structures */ struct sl_cs { @@ -66,7 +68,6 @@ static inline struct sl_global * sl__globals(void) { return &sl_global_data; } -/* FIXME: integrate with param_set */ static inline void sl_thd_setprio(struct sl_thd *t, tcap_prio_t p) { t->prio = p; } @@ -86,7 +87,7 @@ sl_thdid(void) assert(tid != 0); assert(tid < MAX_NUM_THREADS); - + return tid; } @@ -177,6 +178,8 @@ sl_cs_exit(void) union sl_cs_intern csi, cached; sched_tok_t tok; + assert(sl_cs_owner()); + retry: tok = cos_sched_sync(); csi.v = sl__globals()->lock.u.v; @@ -190,6 +193,49 @@ sl_cs_exit(void) if (!ps_cas(&sl__globals()->lock.u.v, cached.v, 0)) goto retry; } +/* + * if tid == 0, just block the current thread; otherwise, create a + * dependency from this thread on the target tid (i.e. when the + * scheduler chooses to run this thread, we will run the dependency + * instead (note that "dependency" is transitive). + */ +void sl_thd_block(thdid_t tid); +/* + * @abs_timeout: absolute timeout at which thread should be woken-up. + * if abs_timeout == 0, block forever = sl_thd_block() + * + * @returns: 0 if the thread is woken up by external events before timeout. + * +ve - number of cycles elapsed from abs_timeout before the thread + * was woken up by Timeout module. + */ +cycles_t sl_thd_block_timeout(thdid_t tid, cycles_t abs_timeout); +/* + * blocks for a timeout = next replenishment period of the task. + * Note: care should be taken to not interleave this with sl_thd_block_timeout(). + * It may be required to interleave, in such cases, timeout values in + * sl_thd_block_timeout() should not be greater than or equal to + * the task's next replenishment period. + * + * @returns: 0 if the thread is woken up by external events before timeout. + * +ve - number of periods elapsed. (1 if it wokeup exactly at timeout = next period) + */ +unsigned int sl_thd_block_periodic(thdid_t tid); +int sl_thd_block_no_cs(struct sl_thd *t, sl_thd_state block_type); + +/* wakeup a thread that has (or soon will) block */ +void sl_thd_wakeup(thdid_t tid); +int sl_thd_wakeup_no_cs(struct sl_thd *t); + +void sl_thd_yield(thdid_t tid); +void sl_thd_yield_cs_exit(thdid_t tid); + +/* The entire thread allocation and free API */ +struct sl_thd *sl_thd_alloc(cos_thd_fn_t fn, void *data); +struct sl_thd *sl_thd_comp_alloc(struct cos_defcompinfo *comp); +void sl_thd_free(struct sl_thd *t); + +void sl_thd_param_set(struct sl_thd *t, sched_param_t sp); + static inline microsec_t sl_cyc2usec(cycles_t cyc) { return cyc / sl__globals()->cyc_per_usec; } @@ -206,6 +252,74 @@ static inline microsec_t sl_now_usec(void) { return sl_cyc2usec(sl_now()); } +/* + * Time and timeout API. + * + * This can be used by the scheduler policy module *and* by the + * surrounding component code. To avoid race conditions between + * reading the time, and setting a timeout, we avoid relative time + * measurements. sl_now gives the current cycle count that is on an + * absolute timeline. The periodic function sets a period that can be + * used when a timeout has happened, the relative function sets a + * timeout relative to now, and the oneshot timeout sets a timeout on + * the same absolute timeline as returned by sl_now. + */ +void sl_timeout_period(cycles_t period); + +static inline cycles_t +sl_timeout_period_get(void) +{ return sl__globals()->period; } + +static inline void +sl_timeout_oneshot(cycles_t absolute_us) +{ + sl__globals()->timer_next = absolute_us; + sl__globals()->timeout_next = tcap_cyc2time(absolute_us); +} + +static inline void +sl_timeout_relative(cycles_t offset) +{ sl_timeout_oneshot(sl_now() + offset); } + +static inline void +sl_timeout_expended(microsec_t now, microsec_t oldtimeout) +{ + cycles_t offset; + + assert(now >= oldtimeout); + + /* in virtual environments, or with very small periods, we might miss more than one period */ + offset = (now - oldtimeout) % sl_timeout_period_get(); + sl_timeout_oneshot(now + sl_timeout_period_get() - offset); +} + +/* to get timeout heap. not a public api */ +struct heap *sl_timeout_heap(void); + +/* wakeup any blocked threads! */ +static inline void +sl_timeout_wakeup_expired(cycles_t now) +{ + if (!heap_size(sl_timeout_heap())) return; + + do { + struct sl_thd *tp, *th; + + tp = heap_peek(sl_timeout_heap()); + assert(tp); + + /* FIXME: logic for wraparound in current tsc */ + if (likely(tp->timeout_cycs > now)) break; + + th = heap_highest(sl_timeout_heap()); + assert(th && th == tp); + th->timeout_idx = -1; + + assert(th->wakeup_cycs == 0); + th->wakeup_cycs = now; + sl_thd_wakeup_no_cs(th); + } while (heap_size(sl_timeout_heap())); +} /* * Do a few things: 1. take the critical section if it isn't already @@ -249,7 +363,8 @@ sl_cs_exit_schedule_nospin_arg(struct sl_thd *to) tok = cos_sched_sync(); now = sl_now(); offset = (s64_t)(globals->timer_next - now); - if (globals->timer_next && offset <= 0) sl_timeout_mod_expended(now, globals->timer_next); + if (globals->timer_next && offset <= 0) sl_timeout_expended(now, globals->timer_next); + sl_timeout_wakeup_expired(now); /* * Once we exit, we can't trust t's memory as it could be @@ -298,54 +413,6 @@ sl_cs_exit_switchto(struct sl_thd *to) } } -/* - * if tid == 0, just block the current thread; otherwise, create a - * dependency from this thread on the target tid (i.e. when the - * scheduler chooses to run this thread, we will run the dependency - * instead (note that "dependency" is transitive). - */ -void sl_thd_block(thdid_t tid); -/* wakeup a thread that has (or soon will) block */ -void sl_thd_wakeup(thdid_t tid); -void sl_thd_yield(thdid_t tid); -void sl_thd_yield_cs_exit(thdid_t tid); - -/* The entire thread allocation and free API */ -struct sl_thd *sl_thd_alloc(cos_thd_fn_t fn, void *data); -struct sl_thd *sl_thd_comp_alloc(struct cos_defcompinfo *comp); -void sl_thd_free(struct sl_thd *t); - -/* - * Time and timeout API. - * - * This can be used by the scheduler policy module *and* by the - * surrounding component code. To avoid race conditions between - * reading the time, and setting a timeout, we avoid relative time - * measurements. sl_now gives the current cycle count that is on an - * absolute timeline. The periodic function sets a period that can be - * used when a timeout has happened, the relative function sets a - * timeout relative to now, and the oneshot timeout sets a timeout on - * the same absolute timeline as returned by sl_now. - */ -void sl_timeout_period(cycles_t period); - -static inline cycles_t -sl_timeout_period_get(void) -{ return sl__globals()->period; } - -static inline void -sl_timeout_oneshot(cycles_t absolute_us) -{ - sl__globals()->timer_next = absolute_us; - sl__globals()->timeout_next = tcap_cyc2time(absolute_us); -} - -static inline void -sl_timeout_relative(cycles_t offset) -{ sl_timeout_oneshot(sl_now() + offset); } - -void sl_thd_param_set(struct sl_thd *t, sched_param_t sp); - /* * Initialization protocol in cos_init: initialization of * library-internal data-structures, and then the ability for the @@ -359,5 +426,4 @@ void sl_thd_param_set(struct sl_thd *t, sched_param_t sp); void sl_init(void); void sl_sched_loop(void); - #endif /* SL_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_consts.h b/src/components/implementation/no_interface/cFE_booter/sl_consts.h index bdcda220cc..7990910dc0 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_consts.h +++ b/src/components/implementation/no_interface/cFE_booter/sl_consts.h @@ -1,6 +1,7 @@ #ifndef SL_CONSTS #define SL_CONSTS -#define SL_PERIOD_US 100 +#define SL_PERIOD_US 1000 +#define SL_MAX_NUM_THDS MAX_NUM_THREADS #endif /* SL_CONSTS */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c index e9340c8aac..ca61a3fd27 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c +++ b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c @@ -3,9 +3,11 @@ #include #include -#define SL_FPRR_NPRIOS 256 -#define SL_FPRR_HIGHEST 0 -#define SL_FPRR_LOWEST (SL_FPRR_NPRIOS-1) +#define SL_FPRR_NPRIOS 257 +#define SL_FPRR_PRIO_HIGHEST 0 +#define SL_FPRR_PRIO_LOWEST (SL_FPRR_NPRIOS-1) + +#define SL_FPRR_PERIOD_US_MIN SL_PERIOD_US struct ps_list_head threads[SL_FPRR_NPRIOS]; @@ -26,8 +28,6 @@ sl_mod_schedule(void) return t; } - assert(0); - return NULL; } @@ -40,7 +40,7 @@ sl_mod_block(struct sl_thd_policy *t) void sl_mod_wakeup(struct sl_thd_policy *t) { - assert(t->priority <= SL_FPRR_LOWEST && ps_list_singleton_d(t)); + assert(t->priority <= SL_FPRR_PRIO_LOWEST && ps_list_singleton_d(t)); ps_list_head_append_d(&threads[t->priority], t); } @@ -48,8 +48,7 @@ sl_mod_wakeup(struct sl_thd_policy *t) void sl_mod_yield(struct sl_thd_policy *t, struct sl_thd_policy *yield_to) { - assert(t); - assert(t->priority <= SL_FPRR_LOWEST); + assert(t->priority <= SL_FPRR_PRIO_LOWEST); ps_list_rem_d(t); ps_list_head_append_d(&threads[t->priority], t); @@ -58,7 +57,7 @@ sl_mod_yield(struct sl_thd_policy *t, struct sl_thd_policy *yield_to) void sl_mod_thd_create(struct sl_thd_policy *t) { - t->priority = SL_FPRR_LOWEST; + t->priority = SL_FPRR_PRIO_LOWEST; t->period = 0; t->period_usec = 0; ps_list_init_d(t); @@ -71,10 +70,30 @@ sl_mod_thd_delete(struct sl_thd_policy *t) void sl_mod_thd_param_set(struct sl_thd_policy *t, sched_param_type_t type, unsigned int v) { - assert(type == SCHEDP_PRIO && v < SL_FPRR_NPRIOS); - ps_list_rem_d(t); /* if we're already on a list, and we're updating priority */ - t->priority = v; - ps_list_head_append_d(&threads[t->priority], t); + switch (type) { + case SCHEDP_PRIO: + { + assert(v < SL_FPRR_NPRIOS); + ps_list_rem_d(t); /* if we're already on a list, and we're updating priority */ + t->priority = v; + ps_list_head_append_d(&threads[t->priority], t); + sl_thd_setprio(sl_mod_thd_get(t), t->priority); + + break; + } + case SCHEDP_WINDOW: + { + struct sl_thd *td = sl_mod_thd_get(t); + + assert(v >= SL_FPRR_PERIOD_US_MIN); + t->period_usec = v; + t->period = sl_usec2cyc(v); + /* FIXME: synchronize periods for all tasks */ + + break; + } + default: assert(0); + } } void diff --git a/src/components/implementation/no_interface/cFE_booter/sl_plugins.h b/src/components/implementation/no_interface/cFE_booter/sl_plugins.h index ad719101b6..a2972e57f9 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_plugins.h +++ b/src/components/implementation/no_interface/cFE_booter/sl_plugins.h @@ -44,8 +44,4 @@ void sl_mod_thd_delete(struct sl_thd_policy *t); void sl_mod_thd_param_set(struct sl_thd_policy *t, sched_param_type_t type, unsigned int val); void sl_mod_init(void); -/* API for handling timer management */ -void sl_timeout_mod_expended(cycles_t now, cycles_t oldtimeout); -void sl_timeout_mod_init(void); - #endif /* SL_PLUGINS_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_thd.h b/src/components/implementation/no_interface/cFE_booter/sl_thd.h index 3d98fe31da..0d09403624 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_thd.h +++ b/src/components/implementation/no_interface/cFE_booter/sl_thd.h @@ -11,6 +11,7 @@ typedef enum { SL_THD_FREE = 0, SL_THD_BLOCKED, + SL_THD_BLOCKED_TIMEOUT, SL_THD_WOKEN, /* if a race causes a wakeup before the inevitable block */ SL_THD_RUNNABLE, SL_THD_DYING, @@ -22,6 +23,12 @@ struct sl_thd { thdcap_t thdcap; tcap_prio_t prio; struct sl_thd *dependency; + + cycles_t period; + cycles_t periodic_cycs; /* for implicit periodic timeouts */ + cycles_t timeout_cycs; /* next timeout - used in timeout API */ + cycles_t wakeup_cycs; /* actual last wakeup - used in timeout API for jitter information, etc */ + int timeout_idx; /* timeout heap index, used in timeout API */ }; #ifndef assert diff --git a/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c b/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c index 953dd1441f..14ee6df337 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c +++ b/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c @@ -10,13 +10,13 @@ #include #include -static struct sl_thd_policy sl_threads[MAX_NUM_THREADS]; +static struct sl_thd_policy sl_threads[SL_MAX_NUM_THDS]; /* Default implementations of backend functions */ struct sl_thd_policy * sl_thd_alloc_backend(thdid_t tid) { - assert(tid < MAX_NUM_THREADS); + assert(tid < SL_MAX_NUM_THDS); return &sl_threads[tid]; } @@ -35,10 +35,10 @@ sl_thd_index_rem_backend(struct sl_thd_policy *t) struct sl_thd_policy * sl_thd_lookup_backend(thdid_t tid) { - assert(tid < MAX_NUM_THREADS); + assert(tid < SL_MAX_NUM_THDS); return &sl_threads[tid]; } void sl_thd_init_backend(void) -{ } +{ assert(SL_MAX_NUM_THDS <= MAX_NUM_THREADS); } From 7146b84d8976e21344d0a760111f72db65cff9bf Mon Sep 17 00:00:00 2001 From: Zach Day Date: Mon, 17 Jul 2017 15:42:11 -0400 Subject: [PATCH 066/122] Store symbol names in `cobj` The original format of `cobj` only stores the address of a symbol along with an index. The OSAL needs to be able to look up symbols by name, and @gparmer and I have decided that the best way to parse the objects would be to use Composite's existing `cobj` parsing library rather than writing an ELF parser. This commit adds a new field to the `cobj_symb`, `name`. In the future, this implementation will avoid wasting memory by putting symbol names at the end of the cobj. --- src/components/include/cobj_format.h | 4 +++- src/components/lib/cobj_format.c | 3 ++- src/platform/linker/loadall.c | 18 +++++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/components/include/cobj_format.h b/src/components/include/cobj_format.h index e81da3fce4..fabd9f2655 100644 --- a/src/components/include/cobj_format.h +++ b/src/components/include/cobj_format.h @@ -70,6 +70,8 @@ enum { }; struct cobj_symb { + /* TODO: this is a big ol' waste of space */ + char name[64]; u32_t type; u32_t vaddr; } __attribute__((packed)); @@ -88,7 +90,7 @@ struct cobj_header *cobj_create(u32_t id, char *name, u32_t nsect, char *space, unsigned int sz, u32_t flags); int cobj_sect_init(struct cobj_header *h, unsigned int sect_idx, u32_t flags, u32_t vaddr, u32_t size); -int cobj_symb_init(struct cobj_header *h, unsigned int symb_idx, u32_t type, u32_t vaddr); +int cobj_symb_init(struct cobj_header *h, unsigned int symb_idx, const char *name, u32_t type, u32_t vaddr); int cobj_cap_init(struct cobj_header *h, unsigned int cap_idx, u32_t cap_off, u32_t dest_id, u32_t sfn, u32_t cstub, u32_t sstub, u32_t fault_num); diff --git a/src/components/lib/cobj_format.c b/src/components/lib/cobj_format.c index 44f0e8d11f..27e9b72572 100644 --- a/src/components/lib/cobj_format.c +++ b/src/components/lib/cobj_format.c @@ -193,12 +193,13 @@ cobj_sect_init(struct cobj_header *h, unsigned int sect_idx, u32_t flags, u32_t } int -cobj_symb_init(struct cobj_header *h, unsigned int symb_idx, u32_t type, u32_t vaddr) +cobj_symb_init(struct cobj_header *h, unsigned int symb_idx, const char *name, u32_t type, u32_t vaddr) { struct cobj_symb *s; s = cobj_symb_get(h, symb_idx); if (!s) return -1; + strcpy(s->name, name); s->type = type; s->vaddr = vaddr; diff --git a/src/platform/linker/loadall.c b/src/platform/linker/loadall.c index 59bd00955f..cce5c23c1d 100644 --- a/src/platform/linker/loadall.c +++ b/src/platform/linker/loadall.c @@ -85,16 +85,28 @@ int make_cobj_symbols(struct service_symbs *s, struct cobj_header *h) }; /* Create the sumbols */ - printl(PRINT_DEBUG, "%s loaded by Composite -- Symbols:\n", s->obj); + printl(PRINT_DEBUG, "%s loaded by Composite\n", s->obj); + printl(PRINT_DEBUG, "\tMap symbols:\n"); for (i = 0 ; map[i].name != NULL ; i++) { addr = (u32_t)get_symb_address(&s->exported, map[i].name); - printl(PRINT_DEBUG, "\taddr %x, nsymb %d\n", addr, i); - if (addr && cobj_symb_init(h, symb_offset++, map[i].type, addr)) { + printl(PRINT_DEBUG, "\tname %s, addr %x, nsymb %d\n", map[i].name, addr, i); + if (addr && cobj_symb_init(h, symb_offset++, map[i].name, map[i].type, addr)) { printl(PRINT_HIGH, "boot component: couldn't create cobj symb for %s (%d).\n", map[i].name, i); return -1; } } + /* Begin to write all symbols */ + printl(PRINT_DEBUG, "\tExported symbols:\n"); + while (s) { + struct symb_type exports = s->exported; + for (i = 0; i < exports.num_symbs; i++) { + printl(PRINT_DEBUG, "\tname %s, addr %x, nsymb %d\n", exports.symbs[i].name, exports.symbs[i].addr, i); + cobj_symb_init(h, symb_offset++, exports.symbs[i].name, COBJ_SYMB_EXPORTED, i); + } + s = s->next; + } + return 0; } From 4d650bc6f0d4e9ab8af39eb3c2229cee23cd314e Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 18 Jul 2017 16:16:04 -0400 Subject: [PATCH 067/122] Fix broken OSAL thread unit tests sl_thd_free had a bunch of bugs and unconsidered corner cases, so me and phani went through and fixed them! This fixed a lot of the ostask unit tests, and we're basically compliant now. --- .../no_interface/cFE_booter/ostask.c | 39 +++++++++++++++---- .../no_interface/cFE_booter/sl.c | 12 ++---- .../no_interface/cFE_booter/sl.h | 8 +++- .../no_interface/cFE_booter/sl_mod_fprr.c | 4 ++ 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 68d5e964ea..26e206a113 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -41,7 +41,7 @@ int is_valid_name(const char* name) { return FALSE; } -// TODO: Figure out how to check if names are taken +// TODO: Figure out how to check if thread names are taken int is_thread_name_taken(const char* name) { // for(int i = 0; i < num_tasks; i++) { // thdid_t task_id = task_ids[i]; @@ -106,6 +106,8 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, *task_id = (uint32) thd->thdid; + printc("created task with id %d\n", (int) *task_id); + exit: sl_cs_exit(); return result; @@ -113,6 +115,8 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, int32 OS_TaskDelete(uint32 task_id) { + printc("Deleting task %d\n", (int) task_id); + struct sl_thd* thd = sl_thd_lkup(task_id); if(!thd) { return OS_ERR_INVALID_ID; @@ -127,6 +131,7 @@ int32 OS_TaskDelete(uint32 task_id) } sl_thd_free(thd); + printc("successfully deleted task %d\n", (int) task_id); return OS_SUCCESS; } @@ -138,7 +143,14 @@ uint32 OS_TaskGetId(void) void OS_TaskExit(void) { - PANIC("Unimplemented method!"); + sl_thd_free(sl_thd_curr()); + + // TODO: Fix yield so that I can yield here, not do this weird hack + // Have to use this hack, since we can't yield from a free thread + sl_cs_enter(); + sl_cs_exit_schedule(); + + PANIC("Should be unreachable!"); } int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer) @@ -180,6 +192,8 @@ int32 OS_TaskRegister(void) return OS_ERR_INVALID_ID; } + printc("registering task %d\n", (int) sl_thdid()); + // Think it is safe for this to do nothing return OS_SUCCESS; } @@ -198,13 +212,13 @@ int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) } struct sl_thd* thd = sl_thd_lkup(task_id); - if (!thd) { + // TODO: Fix this ugly workaround + if (!thd || thd->state == SL_THD_FREE) { return OS_ERR_INVALID_ID; } struct sl_thd_policy* thd_policy = sl_mod_thd_policy_get(thd); assert(thd_policy); - // TODO: Consider moving this sequence of calls to a helper function *task_prop = thd_policy->osal_task_prop; return OS_SUCCESS; } @@ -501,6 +515,8 @@ int32 OS_SemaphoreGive(struct semaphore* semaphores, uint32 max_semaphores, uint { int32 result = OS_SUCCESS; + printc("giving semaphore %d\n", (int) sem_id); + sl_lock_take(&semaphore_data_lock); if (sem_id >= max_semaphores || !semaphores[sem_id].used) { @@ -513,12 +529,15 @@ int32 OS_SemaphoreGive(struct semaphore* semaphores, uint32 max_semaphores, uint exit: sl_lock_release(&semaphore_data_lock); + printc("gave semaphore %d\n", (int) sem_id); return result; } int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint32 sem_id) { + printc("taking semaphore %d\n", (int) sem_id); + int32 result = OS_SUCCESS; sl_lock_take(&semaphore_data_lock); @@ -536,9 +555,11 @@ int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint } sl_lock_release(&semaphore_data_lock); - // TODO: Do something smarter than blocking for 10 milliseconds - cycles_t timeout = sl_now() + sl_usec2cyc(10000); + printc("blocking on take\n"); + // TODO: Do something smarter than blocking for 3 millisecond + cycles_t timeout = sl_now() + sl_usec2cyc(3 * 1000); sl_thd_block_timeout(0, timeout); + printc("unblocked on take\n"); sl_lock_take(&semaphore_data_lock); } @@ -552,6 +573,8 @@ int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint exit: sl_lock_release(&semaphore_data_lock); + printc("took semaphore %d\n", (int) sem_id); + return result; } @@ -573,8 +596,8 @@ int32 OS_SemaphoreTimedWait(struct semaphore* semaphores, uint32 max_semaphores, && semaphores[sem_id].count == 0 && (sl_now_usec() - start_time) < max_wait) { sl_lock_release(&semaphore_data_lock); - // TODO: Do something smarter than blocking for 2 milliseconds - cycles_t timeout = sl_now() + sl_usec2cyc(2000); + // TODO: Do something smarter than blocking for 3 milliseconds + cycles_t timeout = sl_now() + sl_usec2cyc(3 * 1000); sl_thd_block_timeout(0, timeout); sl_lock_take(&semaphore_data_lock); } diff --git a/src/components/implementation/no_interface/cFE_booter/sl.c b/src/components/implementation/no_interface/cFE_booter/sl.c index 8f567c9378..c901fb30df 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.c +++ b/src/components/implementation/no_interface/cFE_booter/sl.c @@ -135,11 +135,6 @@ sl_thd_block_no_cs(struct sl_thd *t, sl_thd_state block_type) return 1; } - - if (t->state != SL_THD_RUNNABLE) { - printc("state = %d\n", (int) t->state); - } - assert(t->state == SL_THD_RUNNABLE); t->state = block_type; sl_mod_block(sl_mod_thd_policy_get(t)); @@ -253,9 +248,6 @@ sl_thd_wakeup_no_cs(struct sl_thd *t) return 1; } - if (! (t->state == SL_THD_BLOCKED || t->state == SL_THD_BLOCKED_TIMEOUT)) { - printc("state = %d", (int) t->state); - } /* TODO: for AEP threads, wakeup events from kernel could be level-triggered. */ assert(t->state == SL_THD_BLOCKED || t->state == SL_THD_BLOCKED_TIMEOUT); t->state = SL_THD_RUNNABLE; @@ -376,6 +368,8 @@ sl_thd_free(struct sl_thd *t) sl_timeout_remove(t); } + sl_mod_thd_delete(sl_mod_thd_policy_get(t)); + sl_thd_index_rem_backend(sl_mod_thd_policy_get(t)); t->state = SL_THD_FREE; /* TODO: add logic for the graveyard to delay this deallocation if t == current */ @@ -423,7 +417,7 @@ sl_timeout_period(microsec_t period) /* engage space heater mode */ void sl_idle(void *d) -{ while (1) ; } +{ while (1) sl_thd_yield(0); } void sl_init(void) diff --git a/src/components/implementation/no_interface/cFE_booter/sl.h b/src/components/implementation/no_interface/cFE_booter/sl.h index 96ec90eb53..f1189d2451 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.h +++ b/src/components/implementation/no_interface/cFE_booter/sl.h @@ -379,12 +379,18 @@ sl_cs_exit_schedule_nospin_arg(struct sl_thd *to) } if (likely(!to)) { pt = sl_mod_schedule(); - if (unlikely(!pt)) t = sl__globals()->idle_thd; + + if (unlikely(!pt)) { + t = sl__globals()->idle_thd; + } else t = sl_mod_thd_get(pt); } thdcap = t->thdcap; prio = t->prio; + + assert(t->state != SL_THD_FREE); + sl_cs_exit(); /* TODO: enable per-thread tcaps for interrupt threads */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c index ca61a3fd27..b0bc120033 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c +++ b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c @@ -3,6 +3,8 @@ #include #include +#include "cFE_util.h" + #define SL_FPRR_NPRIOS 257 #define SL_FPRR_PRIO_HIGHEST 0 #define SL_FPRR_PRIO_LOWEST (SL_FPRR_NPRIOS-1) @@ -28,6 +30,8 @@ sl_mod_schedule(void) return t; } + + printc("Found nothing to schedule...\n"); return NULL; } From 0f5be70a48ec7a37e0204c0025e63d30c51b56cd Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 18 Jul 2017 16:26:49 -0400 Subject: [PATCH 068/122] Remove debugging prints in cFE_booter/ostask.c --- .../no_interface/cFE_booter/ostask.c | 18 +----------------- .../no_interface/cFE_booter/sl.c | 5 +---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 26e206a113..22d1842ece 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -106,8 +106,6 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, *task_id = (uint32) thd->thdid; - printc("created task with id %d\n", (int) *task_id); - exit: sl_cs_exit(); return result; @@ -115,8 +113,6 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, int32 OS_TaskDelete(uint32 task_id) { - printc("Deleting task %d\n", (int) task_id); - struct sl_thd* thd = sl_thd_lkup(task_id); if(!thd) { return OS_ERR_INVALID_ID; @@ -131,7 +127,6 @@ int32 OS_TaskDelete(uint32 task_id) } sl_thd_free(thd); - printc("successfully deleted task %d\n", (int) task_id); return OS_SUCCESS; } @@ -192,8 +187,6 @@ int32 OS_TaskRegister(void) return OS_ERR_INVALID_ID; } - printc("registering task %d\n", (int) sl_thdid()); - // Think it is safe for this to do nothing return OS_SUCCESS; } @@ -515,8 +508,6 @@ int32 OS_SemaphoreGive(struct semaphore* semaphores, uint32 max_semaphores, uint { int32 result = OS_SUCCESS; - printc("giving semaphore %d\n", (int) sem_id); - sl_lock_take(&semaphore_data_lock); if (sem_id >= max_semaphores || !semaphores[sem_id].used) { @@ -529,15 +520,12 @@ int32 OS_SemaphoreGive(struct semaphore* semaphores, uint32 max_semaphores, uint exit: sl_lock_release(&semaphore_data_lock); - printc("gave semaphore %d\n", (int) sem_id); return result; } int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint32 sem_id) { - printc("taking semaphore %d\n", (int) sem_id); - int32 result = OS_SUCCESS; sl_lock_take(&semaphore_data_lock); @@ -555,11 +543,10 @@ int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint } sl_lock_release(&semaphore_data_lock); - printc("blocking on take\n"); // TODO: Do something smarter than blocking for 3 millisecond cycles_t timeout = sl_now() + sl_usec2cyc(3 * 1000); sl_thd_block_timeout(0, timeout); - printc("unblocked on take\n"); + sl_lock_take(&semaphore_data_lock); } @@ -572,9 +559,6 @@ int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint exit: sl_lock_release(&semaphore_data_lock); - - printc("took semaphore %d\n", (int) sem_id); - return result; } diff --git a/src/components/implementation/no_interface/cFE_booter/sl.c b/src/components/implementation/no_interface/cFE_booter/sl.c index c901fb30df..8e6b38c266 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl.c +++ b/src/components/implementation/no_interface/cFE_booter/sl.c @@ -152,13 +152,12 @@ sl_thd_block(thdid_t tid) sl_cs_enter(); t = sl_thd_curr(); - if (t->state == SL_THD_FREE) goto done; + if (sl_thd_block_no_cs(t, SL_THD_BLOCKED)) { sl_cs_exit(); return; } -done: sl_cs_exit_schedule(); return; @@ -176,7 +175,6 @@ sl_thd_block_timeout_intern(thdid_t tid, cycles_t timeout) sl_cs_enter(); t = sl_thd_curr(); - if (t->state == SL_THD_FREE) goto done; if (sl_thd_block_no_cs(t, SL_THD_BLOCKED_TIMEOUT)) { sl_cs_exit(); return 1; @@ -186,7 +184,6 @@ sl_thd_block_timeout_intern(thdid_t tid, cycles_t timeout) assert(timeout || t->period); sl_timeout_block(t, timeout); -done: sl_cs_exit_schedule(); return 0; From 205956cf75c68b7939bda0ad0606416370102552 Mon Sep 17 00:00:00 2001 From: Joseph Espy Date: Wed, 19 Jul 2017 10:29:27 -0400 Subject: [PATCH 069/122] fix filesystem directory api and style issues Implemented many changes suggested during the pull request process. Many of the changes are style or low impact changes. The largest change is the directory API. The directory stream now behaves as expected, and a few methods have been moved so that their implementations are all in one place. --- .../no_interface/cFE_booter/osapi.c | 2 + .../no_interface/cFE_booter/osfiles.c | 148 +++--- .../no_interface/cFE_booter/osfilesys.c | 426 +++++++++++------- .../no_interface/cFE_booter/osfilesys.h | 125 +++-- 4 files changed, 421 insertions(+), 280 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index cc737b9d7a..acccb4a881 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -25,7 +25,9 @@ int32 OS_API_Init(void) cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); cos_defcompinfo_init(); + OS_FS_Init(); + have_initialized = 1; } diff --git a/src/components/implementation/no_interface/cFE_booter/osfiles.c b/src/components/implementation/no_interface/cFE_booter/osfiles.c index d4b313f473..01b5f9a9bf 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfiles.c +++ b/src/components/implementation/no_interface/cFE_booter/osfiles.c @@ -23,8 +23,8 @@ int32 OS_FS_Init(void) int32 OS_creat(const char *path, int32 access) { int32 ret = chk_path_new(path); - if (ret) return ret; - file_creat(path); + if (ret != OS_FS_SUCCESS) return ret; + file_create((char *)path); return 0; } @@ -34,8 +34,8 @@ int32 OS_creat(const char *path, int32 access) int32 OS_open(const char *path, int32 access, uint32 mode) { int32 ret = chk_path(path); - if (ret) return ret; - return file_open(path); + if (ret != OS_FS_SUCCESS) return ret; + return file_open((char *)path); } /* @@ -76,10 +76,10 @@ int32 OS_chmod(const char *path, uint32 access) */ int32 OS_stat(const char *path, os_fstat_t *filestats) { - if (filestats == NULL) return OS_FS_ERR_INVALID_POINTER; + if (!filestats) return OS_FS_ERR_INVALID_POINTER; int32 ret = chk_path(path); - if (ret) return ret; - return file_stat(path, filestats); + if (ret != OS_FS_SUCCESS) return ret; + return file_stat((char *)path, filestats); } /* @@ -96,8 +96,8 @@ int32 OS_lseek(int32 filedes, int32 offset, uint32 whence) int32 OS_remove(const char *path) { int32 ret = chk_path(path); - if (ret) return ret; - file_remove(path); + if (ret != OS_FS_SUCCESS) return ret; + file_remove((char *)path); return 0; } @@ -107,10 +107,10 @@ int32 OS_remove(const char *path) int32 OS_rename(const char *old_filename, const char *new_filename) { int32 ret = chk_path(old_filename); - if (ret) return ret; + if (ret != OS_FS_SUCCESS) return ret; ret = chk_path(new_filename); - if (ret) return ret; - return file_rename(old_filename, new_filename); + if (ret != OS_FS_SUCCESS) return ret; + return file_rename((char *)old_filename, (char *)new_filename); } /* @@ -118,16 +118,21 @@ int32 OS_rename(const char *old_filename, const char *new_filename) */ int32 OS_cp(const char *src, const char *dest) { - if (!src || !dest) return OS_FS_ERR_INVALID_POINTER; - if (strlen((char *)src) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; - if (strlen((char *)dest) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; - if (strlen(path_to_name((char *)src)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; - if (strlen(path_to_name((char *)dest)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; - int32 ret = chk_path(src); - if (ret) return ret; - ret = chk_path_new(dest); - if (ret) return ret; - return file_cp(src, dest); + char *src_path = (char *)src; + char *dest_path = (char *)dest; + + if (!src_path || !dest_path) return OS_FS_ERR_INVALID_POINTER; + if (strlen(src_path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + if (strlen(dest_path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + if (strlen(path_to_name(src_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; + if (strlen(path_to_name(dest_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; + + int32 ret = chk_path(src_path); + if (ret != OS_FS_SUCCESS) return ret; + ret = chk_path_new(dest_path); + if (ret != OS_FS_SUCCESS) return ret; + + return file_cp(src_path, dest_path); } /* @@ -135,16 +140,21 @@ int32 OS_cp(const char *src, const char *dest) */ int32 OS_mv(const char *src, const char *dest) { - if (!src || !dest) return OS_FS_ERR_INVALID_POINTER; - if (strlen((char *)src) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; - if (strlen((char *)dest) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; - if (strlen(path_to_name((char *)src)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; - if (strlen(path_to_name((char *)dest)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; + char *src_path = (char *)src; + char *dest_path = (char *)dest; + + if (!src_path || !dest_path) return OS_FS_ERR_INVALID_POINTER; + if (strlen(src_path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + if (strlen(dest_path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + if (strlen(path_to_name(src_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; + if (strlen(path_to_name(dest_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; + int32 ret = chk_path(src); - if (ret) return ret; + if (ret != OS_FS_SUCCESS) return ret; ret = chk_path_new(dest); - if (ret) return ret; - return file_mv(src, dest); + if (ret != OS_FS_SUCCESS) return ret; + + return file_mv(src_path, dest_path); } /* @@ -152,7 +162,7 @@ int32 OS_mv(const char *src, const char *dest) */ int32 OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) { - if (fd_prop == NULL) return OS_FS_ERR_INVALID_POINTER; + if (!fd_prop) return OS_FS_ERR_INVALID_POINTER; if (filedes <= 0 || filedes > MAX_NUM_FILES) return OS_FS_ERR_INVALID_FD; return file_FDGetInfo(filedes, fd_prop); @@ -164,11 +174,11 @@ int32 OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) int32 OS_FileOpenCheck(char *Filename) { int32 ret = chk_path(Filename); - if (ret) return OS_FS_ERR_INVALID_POINTER; + if (ret != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_POINTER; struct fsobj *file = file_find(Filename); - if (file == NULL) return OS_INVALID_POINTER; - if (file->refcnt == 0) return OS_FS_ERROR; + if (!file) return OS_INVALID_POINTER; + if (!file->refcnt) return OS_FS_ERROR; return OS_FS_SUCCESS; } @@ -191,10 +201,10 @@ int32 OS_CloseAllFiles(void) int32 OS_CloseFileByName(char *Filename) { int32 ret = chk_path(Filename); - if (ret) return OS_FS_ERR_INVALID_POINTER; + if (ret != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_POINTER; struct fsobj *file = file_find(Filename); - if (file == NULL || file->filedes == 0) return OS_FS_ERR_INVALID_POINTER; + if (!file || !file->filedes) return OS_FS_ERR_INVALID_POINTER; return OS_close(file->filedes); } @@ -209,20 +219,17 @@ int32 OS_CloseFileByName(char *Filename) int32 OS_mkdir(const char *path, uint32 access) { int32 ret = chk_path_new(path); - if (ret) return ret; - return file_mkdir(path, access); + if (ret != OS_FS_SUCCESS) return ret; + return dir_mkdir((char *)path); } /* * Opens a directory for searching - * TODO: Check for error codes conflicting with real values */ os_dirp_t OS_opendir(const char *path) { if(chk_path(path) != OS_FS_SUCCESS) return NULL; - int32 filedes = file_open(path); - if (filedes == OS_FS_ERROR) return NULL;; - return (os_dirp_t) file_open(path); + return (os_dirp_t) dir_open((char *)path); } /* @@ -230,8 +237,8 @@ os_dirp_t OS_opendir(const char *path) */ int32 OS_closedir(os_dirp_t directory) { - if (directory == NULL) return OS_FS_ERR_INVALID_POINTER; - return file_close((int32) directory); + if (!directory) return OS_FS_ERR_INVALID_POINTER; + return dir_close((os_dirent_t *) directory); } /* @@ -239,17 +246,19 @@ int32 OS_closedir(os_dirp_t directory) */ void OS_rewinddir(os_dirp_t directory) { - file_rewinddir(); + if (!directory) return; + dir_rewind((os_dirent_t *)directory); return; } /* * Reads the next object in the directory */ -os_dirent_t * OS_readdir(os_dirp_t directory) +os_dirent_t *OS_readdir(os_dirp_t directory) { - if (directory == NULL) return NULL; - return file_readdir( (int32) directory); + if (!directory) return NULL; + os_dirent_t *dir = dir_read((os_dirent_t *)directory); + return dir; } /* @@ -258,8 +267,8 @@ os_dirent_t * OS_readdir(os_dirp_t directory) int32 OS_rmdir(const char *path) { int32 ret = chk_path(path); - if (ret) return ret; - return file_rmdir(path); + if (ret != OS_FS_SUCCESS) return ret; + return dir_rmdir((char *)path); } /****************************************************************************** @@ -283,7 +292,7 @@ int32 OS_mkfs(char *address, char *devname, char *volname, int32 OS_mount(const char *devname, char *mountpoint) { if (!devname || !mountpoint) return OS_FS_ERR_INVALID_POINTER; - return fs_mount(devname, mountpoint); + return fs_mount((char *)devname, mountpoint); } /* @@ -303,7 +312,7 @@ int32 OS_initfs(char *address, char *devname, char *volname, uint32 blocksize, u */ int32 OS_rmfs(char *devname) { - if (devname == NULL) return OS_FS_ERR_INVALID_POINTER; + if (!devname) return OS_FS_ERR_INVALID_POINTER; return rmfs(devname); } @@ -313,7 +322,7 @@ int32 OS_rmfs(char *devname) int32 OS_unmount(const char *mountpoint) { if (!mountpoint) return OS_FS_ERR_INVALID_POINTER; - return fs_unmount(mountpoint); + return fs_unmount((char *)mountpoint); } /* @@ -321,11 +330,13 @@ int32 OS_unmount(const char *mountpoint) */ int32 OS_fsBlocksFree(const char *name) { - - int32 ret = chk_path(name); - if (ret) return ret; - - return 10; + /* + * I am open to discussion on how we want to handle this. + * We could impose an artificial limit on the size of the filesystem + * if we expect the filesystem to be used much, that is the right choice, but + * otherwise it is not worth actually doing + */ + return OS_ERR_NOT_IMPLEMENTED; } /* @@ -335,11 +346,8 @@ int32 OS_fsBlocksFree(const char *name) */ int32 OS_fsBytesFree(const char *name, uint64 *bytes_free) { - if (bytes_free == NULL) return OS_FS_ERR_INVALID_POINTER; - int32 ret = chk_path(name); - if (ret) return ret; - - return 10 * F_PART_DATA_SIZE; + // see comment in fsBlocksFree + return OS_ERR_NOT_IMPLEMENTED; } /* @@ -356,10 +364,10 @@ os_fshealth_t OS_chkfs(const char *name, boolean repair) */ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, char * MountPoint) { - if (PhysDriveName == NULL || MountPoint == NULL) return OS_FS_ERR_INVALID_POINTER; + if (!PhysDriveName || !MountPoint) return OS_FS_ERR_INVALID_POINTER; int32 ret = chk_path(MountPoint); - if (ret) return ret; - return Filesys_GetPhysDriveName(PhysDriveName, MountPoint); + if (ret != OS_FS_SUCCESS) return ret; + return filesys_GetPhysDriveName(PhysDriveName, MountPoint); } /* @@ -368,9 +376,9 @@ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, char * MountPoint) */ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) { - if (VirtualPath == NULL || LocalPath == NULL) return OS_FS_ERR_INVALID_POINTER; + if (!VirtualPath || !LocalPath) return OS_FS_ERR_INVALID_POINTER; int32 ret = chk_path(VirtualPath); - if (ret) return ret; + if (ret != OS_FS_SUCCESS) return ret; strcpy(LocalPath, VirtualPath); return OS_FS_SUCCESS; @@ -381,8 +389,8 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) */ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) { - if (filesys_info == NULL) return OS_FS_ERR_INVALID_POINTER; - return Filesys_GetFsInfo(filesys_info); + if (!filesys_info) return OS_FS_ERR_INVALID_POINTER; + return filesys_GetFsInfo(filesys_info); } /****************************************************************************** diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.c b/src/components/implementation/no_interface/cFE_booter/osfilesys.c index 42eccbb739..20d339ec07 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.c +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.c @@ -1,11 +1,33 @@ -#include "cFE_util.h" #include "osfilesys.h" -struct fs filesystem[MAX_NUM_FS]; +struct fs filesystems[MAX_NUM_FS]; struct fs *openfs; -struct fsobj *openfile; struct fsobj files[MAX_NUM_FILES]; struct cos_compinfo *ci; +os_dirent_t directories[MAX_NUM_DIRENT]; +/* + * Notes on this version: + * + * This version is a functional filesystem which complies to how NASA's + * cFE OSAL API uses a subset of the POSIX files and filesystem API + * + * Currently it does not support a file being opened concurrently + * by two processes, and fails an assertion if it is attempted + * + * The posix abstraction inode, filedes, dir streams (dirp), and + * dir entries (dirent) are not implemented independently of each other. + * For now filedes is an offset into record of files (DIR and FILE) where fsobj + * stores all of the information related to all of the above abstractions + * For this version we do not need more layers of abstractions. We will need to + * implement them in order to have a posix compatibility layer or concurrency + */ + +// ultimate order of sections +// FS level +// fsobj +// f_part +// dirent +// tar level /****************************************************************************** ** Tar Level Methods @@ -34,11 +56,11 @@ uint32 tar_load() } /* - * parses a loaded tar into filesystem[0] + * parses a loaded tar into filesystems[0] * precondition: tar has been loaded by tar_load, a filesystem has been initialized * with newfs with the devname of tar * Postcondition: A proper error code is returned OR the tar is represented in memory - * at filesystem 0 + * at filesystems 0 */ uint32 tar_parse() { @@ -46,8 +68,7 @@ uint32 tar_parse() assert(size < INT32_MAX); assert(end - start > 0); assert(size == (size_t) (end - start)); - uint32 i; - openfs = &filesystem[0]; + openfs = &filesystems[0]; uint32 offset = 0; struct fsobj *o; @@ -118,21 +139,6 @@ int32 chk_fd(int32 filedes) return OS_FS_SUCCESS; } -uint32 newpart_get(struct f_part **part) -{ - if (ci == NULL) { - struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); - ci = &(defci->ci); - } - *part = cos_page_bump_alloc(ci); - assert(part != NULL); - (*part)->next = NULL; - (*part)->prev = NULL; - (*part)->file = NULL; - (*part)->data = (char *) part + sizeof(part); - return OS_FS_SUCCESS; -} - //finds the next free file uint32 newfile_get(struct fsobj **o) { @@ -142,8 +148,12 @@ uint32 newfile_get(struct fsobj **o) } if (count == MAX_NUM_FILES) return OS_FS_ERROR; *o = &files[count]; - (*o)->filedes = count + 1; - //filedes needs to be unique and nonzero, so filedes is defined as index+1 + + **o = (struct fsobj) { + //filedes needs to be unique and nonzero, so filedes is defined as index+1 + .filedes = count +1 + }; + return OS_FS_SUCCESS; } @@ -153,11 +163,13 @@ uint32 file_insert(struct fsobj *o, char *path) if (path[0] != '/') return OS_FS_ERR_PATH_INVALID; path++; - if (openfs->root == NULL) { + assert(o && path && openfs); + + if (!openfs->root) { openfs->root = o; return OS_FS_SUCCESS; } - assert(o && path && openfs); + assert(openfs->root && openfs->root->filedes); if (openfs->root == o) return OS_FS_SUCCESS; @@ -170,21 +182,27 @@ uint32 file_insert(struct fsobj *o, char *path) if (!root->child) { o->parent = root; root->child = o; + o->next = NULL; + o->prev = NULL; return OS_FS_SUCCESS; } root = root->child; - do { + // move pointer until it is at start of next file/dir name + while (path[0]!= '/'){ path++; - } while (path[0]!= '/'); + } + path++; //precondition: root is the first in a non-empty list of children //postcondition: root is an ancestor of o or o has been inserted in list + // while root is not ancester of o while (strspn(path, root->name) < strlen(root->name)) { - if (!root->next) { + if (root->next == NULL) { root->next = o; o->prev = root; o->parent = root->parent; + o->next = NULL; return OS_FS_SUCCESS; } root = root->next; @@ -195,12 +213,12 @@ uint32 file_insert(struct fsobj *o, char *path) return 0; } -int32 file_open(const char *path) { +int32 file_open(char *path) +{ assert(openfs); - openfs = &(filesystem[0]); assert(openfs->root); struct fsobj *file = file_find(path); - if (file == NULL) return OS_FS_ERROR; + if (!file) return OS_FS_ERROR; assert(1 > file->refcnt); // we do not yet support concurrent file access file->refcnt++; file->position.open_part = file->file_part; @@ -210,10 +228,10 @@ int32 file_open(const char *path) { return file->filedes; } -int32 file_close(int32 filedes) { - +int32 file_close(int32 filedes) +{ int32 ret = chk_fd(filedes); - if (ret) return ret; + if (ret != OS_FS_SUCCESS) return ret; uint32 index = filedes + 1; if (files[index].refcnt < 1) return OS_FS_ERROR; @@ -221,11 +239,30 @@ int32 file_close(int32 filedes) { return OS_FS_SUCCESS; } +/****************************************************************************** +** f_part Level Methods +******************************************************************************/ + +uint32 newpart_get(struct f_part **part) +{ + if (!ci) { + struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); + ci = &defci->ci; + } + *part = cos_page_bump_alloc(ci); + assert(part != NULL); + (*part)->next = NULL; + (*part)->prev = NULL; + (*part)->file = NULL; + (*part)->data = (char *) part + sizeof(part); + return OS_FS_SUCCESS; +} + int32 file_read(int32 filedes, void *buffer, uint32 nbytes) { if (!buffer) return OS_FS_ERR_INVALID_POINTER; int32 ret = chk_fd(filedes); - if (ret) return ret; + if (ret != OS_FS_SUCCESS) return ret; struct fsobj *o = &files[filedes - 1]; struct f_part *part = o->position.open_part; @@ -248,34 +285,29 @@ int32 file_read(int32 filedes, void *buffer, uint32 nbytes) part = o->position.open_part; if (bytes_to_read > read_size) { - memcpy(buffer, &part->data[o->position.part_offset], read_size); buffer += read_size; bytes_to_read -= read_size; o->position.file_offset += read_size; - if (part->next == NULL) { + if (!part->next) { o->position.part_offset = F_PART_DATA_SIZE; return nbytes - bytes_to_read; } - o->position.open_part = part->next; o->position.part_offset = 0; o->position.addr = part->data; - } else if (bytes_to_read == read_size) { - memcpy(buffer, &part->data[o->position.part_offset], read_size); o->position.file_offset += read_size; o->position.addr += read_size; - if (part->next == NULL) { + if (!part->next) { o->position.part_offset = F_PART_DATA_SIZE; return nbytes; } - o->position.open_part = part->next; o->position.part_offset = 0; return nbytes; @@ -303,12 +335,13 @@ int32 file_read(int32 filedes, void *buffer, uint32 nbytes) int32 file_write(int32 filedes, void *buffer, uint32 nbytes) { - if (!buffer) return OS_FS_ERR_INVALID_POINTER; + if (!buffer) return OS_FS_ERR_INVALID_POINTER; int32 ret = chk_fd(filedes); - if (ret) return ret; + if (ret != OS_FS_SUCCESS) return ret; struct fsobj *o = &files[filedes - 1]; + if (o->filedes != filedes) return OS_FS_ERR_INVALID_FD; if (o->refcnt < 1) return OS_FS_ERROR; if (o->file_part->memtype == STATIC)return OS_FS_ERROR; if (o->type == FSOBJ_DIR) return OS_FS_ERROR; @@ -350,22 +383,13 @@ int32 file_write(int32 filedes, void *buffer, uint32 nbytes) return nbytes; } -void file_rewinddir() -{ - if (!openfile) return; - if (openfile->parent == NULL) return; - assert(openfile->parent->child); - openfile = openfile->parent->child; - return; -} - -struct fsobj *file_find(const char *path) +struct fsobj *file_find(char *path) { + assert(path); //paths should always begin with '/' dir names do not if (path[0] != '/') return NULL; path++; - assert(path); if(!openfs || !openfs->root) return NULL; struct fsobj *root = openfs->root; assert(root && root->name); @@ -382,7 +406,8 @@ struct fsobj *file_find(const char *path) //root must now be parent of final location if (!strcmp(root->name, path)) return root; - assert(strspn(path, root->name) >= strlen(root->name)); + // The entirety of root's name should be the initial substring of path + assert(strspn(path, root->name) == strlen(root->name)); if (!root->child) return NULL; root = root->child; @@ -396,56 +421,11 @@ struct fsobj *file_find(const char *path) return NULL; } -int32 file_mkdir(const char *path, uint32 access) -{ - assert(path); - struct fsobj *o; - if (newfile_get(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; - o->name = path_to_name((char *) path); - o->type = FSOBJ_DIR; - o->size = 0; - if (file_insert(o, (char *) path)) return OS_FS_ERR_PATH_INVALID; - - return OS_FS_SUCCESS; -} - -int32 file_rmdir(const char *path) -{ - assert(path); - struct fsobj *root = file_find(path); - if (root == NULL) return OS_FS_ERROR; - struct fsobj *cur; - - while (root->child) { - - // if cur is the last leaf in a list - if (cur->next == NULL && cur->child == NULL) { - if (cur->prev != NULL) { - assert(cur->prev->next == cur); - cur = cur->prev; - rm(cur->next); - } - else { - assert(cur->parent->child == cur); - cur = cur->parent; - rm(cur->child); - } - } else if (cur->child != NULL) { - cur = cur->child; - } else { //cur->next !=NULL - cur = cur->next; - } - } - - rm(root); - return OS_FS_SUCCESS; -} - -int32 file_creat(const char *path) +int32 file_create(char *path) { assert(path); struct fsobj *o; - if (newfile_get(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + if (newfile_get(&o) != OS_FS_SUCCESS) return OS_FS_ERR_DRIVE_NOT_CREATED; o->name = (char *) path; o->type = FSOBJ_FILE; o->size = 0; @@ -460,15 +440,15 @@ int32 file_creat(const char *path) return OS_FS_SUCCESS; } -int32 file_remove(const char *path) +int32 file_remove(char *path) { struct fsobj *file = file_find(path); if (!file) return OS_FS_ERR_PATH_INVALID; - rm(file); + file_rm(file); return OS_FS_SUCCESS; } -int32 file_rename(const char *old_filename, const char *new_filename) +int32 file_rename(char *old_filename, char *new_filename) { struct fsobj *file = file_find(old_filename); if (!file) return OS_FS_ERR_PATH_INVALID; @@ -478,10 +458,10 @@ int32 file_rename(const char *old_filename, const char *new_filename) // This is not a full implementation of all that is required by posix // but it is enough to pass UT and is all the info relevant to this FS -int32 file_stat(const char *path, os_fstat_t *filestats) +int32 file_stat(char *path, os_fstat_t *filestats) { struct fsobj *file = file_find(path); - if (file == NULL) return OS_FS_ERROR; + if (!file) return OS_FS_ERROR; filestats->st_dev = 0; filestats->st_ino = file->filedes; if (file->type == FSOBJ_FILE) { @@ -492,34 +472,29 @@ int32 file_stat(const char *path, os_fstat_t *filestats) } filestats->st_size = file->size; filestats->st_blksize = F_PART_DATA_SIZE; - filestats->st_blocks = 1 + file->size % F_PART_DATA_SIZE; return OS_FS_SUCCESS; } int32 file_lseek(int32 filedes, int32 offset, uint32 whence) { int32 ret = chk_fd(filedes); - if (ret) return ret; + if (ret != OS_FS_SUCCESS) return ret; struct fsobj *o = &files[filedes - 1]; uint32 target_offset = 0; // wasnt sure if it should be legal to pass negative offset, went with yes if (whence == SEEK_SET) { - if (offset < 0) return OS_FS_ERROR; target_offset = offset; } else if (whence == SEEK_CUR) { - if (offset + (int32) o->position.file_offset < 0) return OS_FS_ERROR; target_offset += o->position.file_offset; } else if (whence == SEEK_END) { - if (offset + (int32) o->position.file_offset < 0) return OS_FS_ERROR; target_offset += o->size; - } else { return OS_FS_ERROR; } @@ -532,7 +507,6 @@ int32 file_lseek(int32 filedes, int32 offset, uint32 whence) o->position.file_offset = 0; while ( target_offset - o->position.file_offset > F_PART_DATA_SIZE) { - // seeking past the end of a file writes zeros until that position if (o->position.open_part->next == NULL) { struct f_part *part; @@ -543,12 +517,9 @@ int32 file_lseek(int32 filedes, int32 offset, uint32 whence) part->prev = o->position.open_part; o->position.open_part->next = part; } - o->position.open_part = o->position.open_part->next; o->position.file_offset += F_PART_DATA_SIZE; - } - o->position.file_offset += target_offset % F_PART_DATA_SIZE; o->position.part_offset = target_offset % F_PART_DATA_SIZE; o->position.addr = o->position.open_part->data + target_offset % F_PART_DATA_SIZE; @@ -556,12 +527,11 @@ int32 file_lseek(int32 filedes, int32 offset, uint32 whence) if (o->position.file_offset > size) { size = o->position.file_offset; } - assert(o->position.file_offset == target_offset); return target_offset; } -int32 file_cp(const char *src, const char *dest) +int32 file_cp(char *src, char *dest) { struct fsobj *file_src, *file_dest; int32 src_desc = file_open(src); @@ -570,7 +540,7 @@ int32 file_cp(const char *src, const char *dest) newfile_get(&file_dest); - if(file_src == NULL || file_src->type == FSOBJ_DIR){ + if(!file_src || file_src->type == FSOBJ_DIR){ return OS_FS_ERR_INVALID_POINTER; } @@ -581,22 +551,21 @@ int32 file_cp(const char *src, const char *dest) file_dest->type = FSOBJ_FILE; /* - * yeah, this is sub-optimal - * but I don't expect this to be called at all, much less with large files + * this is not optimal for large files being moved, however + * I don't expect that to be a concern on this kind of system */ uint32 dest_desc = file_dest->filedes; char temp_buff[file_src->size]; - file_read(src_desc, temp_buff,file_src->size); + file_read(src_desc, temp_buff, file_src->size); file_write(file_dest->filedes, temp_buff, file_src->size); return OS_FS_SUCCESS; } -int32 file_mv(const char *src, const char *dest) +int32 file_mv(char *src, char *dest) { - struct fsobj *file; uint32 desc = file_open(src); if (desc <= 0 || desc > MAX_NUM_FILES) return OS_FS_ERROR; @@ -635,30 +604,163 @@ int32 file_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) } -struct dirent *file_readdir(int32 filedes) +/****************************************************************************** +** Dirent Level Methods +******************************************************************************/ + +//provides an unused dirent. Internally, dirents are considered unused when d_ino == 0 +uint32 newdirent_get(os_dirent_t **dir) +{ + /* + * there could be a problem here if two threads request dirents + * and the first does not set d_ino before the second is given the same dirent + */ + uint32 count = 0; + while (count < MAX_NUM_DIRENT && directories[count].d_ino != 0) { + count++; + } + if (count == MAX_NUM_DIRENT) return OS_FS_ERROR; + *dir = &directories[count]; + return OS_FS_SUCCESS; +} + +os_dirent_t *dir_open(char *path) +{ + os_dirent_t *dir; + struct fsobj *file; + + file = file_find(path); + if (!file) return NULL; + if (file->filedes == 0) return NULL; + + newdirent_get(&dir); + if (!dir) return NULL; + assert(dir->d_ino == 0 && strlen(dir->d_name) == 0); + + dir->d_ino = file->filedes; + dir->d_name[0] = 0; + return dir; +} + +uint32 dir_close(os_dirent_t *dir) +{ + dir->d_name[0] = 0; + dir->d_ino = 0; + return OS_FS_SUCCESS; +} + +void dir_rewind(os_dirent_t *dir) +{ + if (!dir) return; + if (dir->d_ino == 0) return; + + // in this implementation, ino is just filedes/files offset + struct fsobj *file = &files[dir->d_ino - 1]; + if ((uint32)file->filedes != dir->d_ino) return; + while(file->prev != NULL) { + file = file->prev; + } + dir->d_ino = file->filedes; + strcpy(dir->d_name, file->name); +} + +os_dirent_t *dir_read(os_dirent_t *dir) +{ + if (!dir) return NULL; + if (dir->d_ino == 0) return NULL; + + // A dir stream ends with '.' and '..' names. + if (dir->d_name[0] == '.') { + if (dir->d_name[1] == '.') { + return NULL; + } + strcpy(dir->d_name, ".."); + return dir; + } + + struct fsobj *file = &files[dir->d_ino]; + if (dir->d_name[0] == 0) { + strcpy(dir->d_name, file->name); + return dir; + } + + if (file->next != NULL) { + file = file->next; + dir->d_ino = file->filedes; + strcpy(dir->d_name, file->name); + } + else { + // last two dirs in stream are '.' and '..' + strcpy(dir->d_name, "."); + } + return dir; +} + +// I am really conflicted about this name. I want consistency and dislike redundancy +int32 dir_mkdir(char *path) { - if () - struct dirent *p = NULL;i - return p; + assert(path); + struct fsobj *o; + if (newfile_get(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + o->name = path_to_name((char *) path); + o->type = FSOBJ_DIR; + o->next = NULL; + o->prev = NULL; + o->parent = NULL; + o->child = NULL; + o->size = 0; + if (file_insert(o, (char *) path) != OS_FS_SUCCESS) return OS_FS_ERR_PATH_INVALID; + return OS_FS_SUCCESS; } +// same naming question as above +int32 dir_rmdir(char *path) +{ + assert(path); + struct fsobj *root = file_find(path); + if (!root) return OS_FS_ERROR; + struct fsobj *cur = root; + while (root->child) { + // if cur is the last leaf in a list + if (!cur->next && !cur->child) { + if (cur->prev != NULL) { + assert(cur->prev->next == cur); + cur = cur->prev; + file_rm(cur->next); + } + else { + assert(cur->parent->child == cur); + cur = cur->parent; + file_rm(cur->child); + } + } else if (cur->child != NULL) { + cur = cur->child; + } else { //cur->next !=NULL + cur = cur->next; + } + } + file_rm(root); + return OS_FS_SUCCESS; +} + + /****************************************************************************** ** fs Level Methods ******************************************************************************/ -uint32 fs_mount(const char *devname, char *mountpoint) +uint32 fs_mount(char *devname, char *mountpoint) { - uint32 i; assert(devname); - for (i=0 ; i < MAX_NUM_FS && filesystem[i].devname != NULL ; i++) { - if (!strcmp(filesystem[i].devname, devname)) { + uint32 i; + for (i=0 ; i < MAX_NUM_FS && filesystems[i].devname != NULL ; i++) { + if (!strcmp(filesystems[i].devname, devname)) { struct fsobj *o; if (newfile_get(&o)) return OS_FS_ERROR; - filesystem[i].mountpoint = mountpoint; - openfs = &filesystem[i]; - if (filesystem[i].root == NULL) { - file_mkdir(mountpoint, 0); + filesystems[i].mountpoint = mountpoint; + openfs = &filesystems[i]; + if (!filesystems[i].root) { + dir_mkdir(mountpoint); } return OS_FS_SUCCESS; } @@ -666,12 +768,12 @@ uint32 fs_mount(const char *devname, char *mountpoint) return OS_FS_ERROR; } -uint32 fs_unmount(const char *mountpoint) { +uint32 fs_unmount(char *mountpoint) { uint32 i; assert(mountpoint); - for (i = 0 ; i < MAX_NUM_FS && filesystem[i].mountpoint != NULL ; i++) { - if (mountpoint != NULL && !strcmp(filesystem[i].mountpoint, mountpoint)) { - filesystem[i].mountpoint = NULL; + for (i = 0 ; i < MAX_NUM_FS && filesystems[i].mountpoint != NULL ; i++) { + if (mountpoint != NULL && !strcmp(filesystems[i].mountpoint, mountpoint)) { + filesystems[i].mountpoint = NULL; return OS_FS_SUCCESS; } } @@ -702,26 +804,26 @@ uint32 newfs_init(char *devname, char *volname, uint32 blocksize, uint32 numbloc // the first filesystem is always the tar - if (filesystem[0].devname == NULL) { + if (!filesystems[0].devname) { ret = tar_load(); if (ret != OS_FS_SUCCESS) return ret; - ret = fs_init(&filesystem[0], devname, volname, blocksize, numblocks); + ret = fs_init(&filesystems[0], devname, volname, blocksize, numblocks); if (ret != OS_FS_SUCCESS) return ret; return OS_FS_SUCCESS; } // filesystem[0] is initialized during OS_FS_Init - if (strcmp(devname, filesystem[0].devname) == 0) return OS_SUCCESS; + if (strcmp(devname, filesystems[0].devname) == 0) return OS_SUCCESS; - while (count < MAX_NUM_FS && filesystem[count].devname) { + while (count < MAX_NUM_FS && filesystems[count].devname) { count++; } if (count == MAX_NUM_FS) return OS_FS_ERR_DRIVE_NOT_CREATED; - ret = fs_init(&filesystem[count], devname, volname, blocksize, numblocks); + ret = fs_init(&filesystems[count], devname, volname, blocksize, numblocks); if (ret !=OS_FS_SUCCESS) return ret; - openfs = &filesystem[count]; + openfs = &filesystems[count]; return OS_FS_SUCCESS; } @@ -730,14 +832,14 @@ int32 rmfs(char *devname) if (!devname) return OS_FS_ERR_INVALID_POINTER; uint32 i; - for (i = 0 ; i < MAX_NUM_FS && filesystem[i].devname != NULL ; i++) { - if (devname && filesystem[i].devname && !strcmp(filesystem[i].devname,devname)) { - filesystem[i].devname = NULL; - filesystem[i].volname = NULL; - filesystem[i].mountpoint = NULL; - filesystem[i].blocksize = 0; - filesystem[i].numblocks = 0; - filesystem[i].root = NULL; + for (i = 0 ; i < MAX_NUM_FS && filesystems[i].devname != NULL ; i++) { + if (devname && filesystems[i].devname && !strcmp(filesystems[i].devname,devname)) { + filesystems[i].devname = NULL; + filesystems[i].volname = NULL; + filesystems[i].mountpoint = NULL; + filesystems[i].blocksize = 0; + filesystems[i].numblocks = 0; + filesystems[i].root = NULL; return OS_FS_SUCCESS; } } @@ -745,11 +847,11 @@ int32 rmfs(char *devname) } -int32 Filesys_GetPhysDriveName(char * PhysDriveName, char * MountPoint) +int32 filesys_GetPhysDriveName(char *PhysDriveName, char *MountPoint) { uint32 i; - for (i = 0 ; i < MAX_NUM_FS && filesystem[i].devname != NULL ; i++) { - if (filesystem[i].mountpoint && !strcmp(filesystem[i].mountpoint,MountPoint)) { + for (i = 0 ; i < MAX_NUM_FS && filesystems[i].devname != NULL ; i++) { + if (filesystems[i].mountpoint && !strcmp(filesystems[i].mountpoint,MountPoint)) { memcpy(PhysDriveName, "RAM FS\n",7); return OS_FS_SUCCESS; } @@ -757,7 +859,7 @@ int32 Filesys_GetPhysDriveName(char * PhysDriveName, char * MountPoint) return OS_FS_ERROR; } -int32 Filesys_GetFsInfo(os_fsinfo_t *filesys_info) +int32 filesys_GetFsInfo(os_fsinfo_t *filesys_info) { filesys_info->MaxFds = MAX_NUM_FILES; uint32 i, count = 0; @@ -767,7 +869,7 @@ int32 Filesys_GetFsInfo(os_fsinfo_t *filesys_info) filesys_info->FreeFds = count; filesys_info->MaxVolumes = MAX_NUM_FS; for (i = 0, count = 0 ; i < MAX_NUM_FS ; i++){ - if (filesystem[i].devname == NULL) count++; + if (!filesystems[i].devname) count++; } filesys_info->FreeVolumes = count; return OS_FS_SUCCESS; diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.h b/src/components/implementation/no_interface/cFE_booter/osfilesys.h index 3059014774..229d934eb3 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.h +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.h @@ -1,25 +1,27 @@ -#include "cFE_util.h" +#include +#include #include "gen/common_types.h" #include "gen/osapi.h" #include "gen/osapi-os-filesys.h" -#include - #include #include #include +#include "cFE_util.h" + // Not to be confused with similar OSAL constants. // These are only to define size of statically allocated data #define MAX_NUM_FS 3 #define MAX_NUM_FILES 100 +#define MAX_NUM_DIRENT 10 #define TAR_BLOCKSIZE 512 #define INT32_MAX 0x7FFFFFF //2^31 - 1 // a page is 4096, size of f_part is 5 values * 4 bytes -#define F_PART_DATA_SIZE 4096-4*5 +#define F_PART_DATA_SIZE (4096-4*5) //should be overwritten by linking step in build process __attribute__((weak)) char _binary_cFEfs_tar_size=0; @@ -43,6 +45,12 @@ struct file_position { char *addr; }; +/* + * The structure of the filesystem is stored in the fsobj struct + * each non-leaf dir points to its first child, which then has a pointer + * to the next, etc. Each file has a linked list of f_parts to store blocks of data + */ + struct fsobj { char *name; int32 filedes; // 0 for free file, positive for tracked file @@ -81,13 +89,8 @@ struct fs { ** Tar Level Methods ******************************************************************************/ -uint32 FS_entrypoint(); -uint32 FS_posttest(); -uint32 BFT(struct fsobj *o); - uint32 tar_load(); - uint32 tar_parse(); int32 tar_read(uint32 offset, char *buf, uint32 req_sz); @@ -119,45 +122,59 @@ static inline uint32 round_to_blocksize(uint32 offset) return offset; } - -static inline char *path_to_name(char *path){ - +static inline char *path_to_name(char *path) +{ + assert(path); uint32 path_len = strlen(path), offset; - assert(path[path_len - 2] != '/' && path_len > 1); + assert(path_len > 1); - // offset is second to last char in path, because last char may be trailing / + //remove one or more '/' at the end of path + while(path[strlen(path) - 1] == '/'){ + path[strlen(path) - 1] = 0; + } + + // iterate from right to left through the path until you find a '/' + // everything you have iterated through is the name of the file for ( offset = path_len - 2 ; path[offset] != '/' && offset > 0 ; offset--) { //do nothing } - assert(0 < strlen(path + offset + 1)); - return path + offset + 1; + char *name = path + offset +1; + + assert(0 < strlen(name)); + return name; } /****************************************************************************** ** fsobj Level Methods ******************************************************************************/ -static inline int32 rm(struct fsobj *o) +static inline int32 file_rm(struct fsobj *o) { assert(o && o->child == NULL); - // if o is first in list of children + // if o is first in list of children, update parent link to it if (o->prev == NULL && o->parent) { assert(o->parent->child == o); // if next = null this still works o->parent->child = o->next; } - // these still work if next or prev = null - if (o->prev) o->prev->next = o->next; - if (o->next) o->next->prev = o->prev; - - //we do not do deallocate file data but we do reuse fsobj - o->name = NULL; - o->filedes = 0; - o->size = 0; - o->refcnt = 0; - o->mode = 0; - o->file_part = NULL; + // update link from prev still work if next or prev = null + if (o->prev) { + assert(o->prev->next == o); + o->prev->next = o->next; + } + // update link from next + if (o->next) { + assert(o->next->prev == o); + o->next->prev = o->prev; + } + // there should now be no links within the fs to o + + // we do not do deallocate file data but we do reuse fsobj + *o = (struct fsobj) { + .name = NULL + }; + return OS_FS_SUCCESS; } @@ -167,39 +184,51 @@ uint32 newfile_get(struct fsobj **o); uint32 file_insert(struct fsobj *o, char *path); -int32 file_open(const char *path); +int32 file_open(char *path); int32 file_close(int32 filedes); -void file_rewinddir(); - int32 file_read(int32 filedes, void *buffer, uint32 nbytes); int32 file_write(int32 filedes, void *buffer, uint32 nbytes); -struct fsobj *file_find(const char *path); - -int32 file_mkdir(const char *path, uint32 access); +struct fsobj *file_find(char *path); -int32 file_rmdir(const char *path); +int32 file_create(char *path); -int32 file_creat(const char *path); +int32 file_remove(char *path); -int32 file_remove(const char *path); +int32 file_rename(char *old_filename, char *new_filename); -int32 file_rename(const char *old_filename, const char *new_filename); +int32 file_cp(char *src, char *dest); -int32 file_cp(const char *src, const char *dest); +int32 file_mv(char *src, char *dest); -int32 file_mv(const char *src, const char *dest); +int32 chk_fd(int32 filedes); int32 file_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop); -int32 file_stat(const char *path, os_fstat_t *filestats); +int32 file_stat(char *path, os_fstat_t *filestats); int32 file_lseek(int32 filedes, int32 offset, uint32 whence); -struct dirent *file_readdir(int32 filedes); +/****************************************************************************** +** dirent Level Methods +******************************************************************************/ +uint32 newdirent_get(os_dirent_t **dir); + +os_dirent_t *dir_open(char *path); + +uint32 dir_close(os_dirent_t *dir); + +void dir_rewind(os_dirent_t *dir); + +os_dirent_t *dir_read(os_dirent_t *dir); + +int32 dir_mkdir(char *path); + +int32 dir_rmdir(char *path); + /****************************************************************************** ** fs Level Methods ******************************************************************************/ @@ -210,7 +239,7 @@ static inline int32 chk_path(const char *path) if (path == NULL) return OS_FS_ERR_INVALID_POINTER; if (strlen(path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; if (path[0] != '/') return OS_FS_ERR_PATH_INVALID; - if (file_find(path) == NULL) return OS_FS_ERR_PATH_INVALID; + if (file_find((char *)path) == NULL) return OS_FS_ERR_PATH_INVALID; return 0; } @@ -222,9 +251,9 @@ static inline int32 chk_path_new(const char *path) return OS_FS_SUCCESS; } -uint32 fs_mount(const char *devname, char *mountpoint); +uint32 fs_mount(char *devname, char *mountpoint); -uint32 fs_unmount(const char *mountpoint); +uint32 fs_unmount(char *mountpoint); uint32 fs_init(struct fs *filesys, char *devname, char *volname, uint32 blocksize, uint32 numblocks); @@ -232,6 +261,6 @@ uint32 newfs_init(char *defilvname, char *volname, uint32 blocksize, uint32 numb int32 rmfs(char *devname); -int32 Filesys_GetPhysDriveName(char * PhysDriveName, char * MountPoint); +int32 filesys_GetPhysDriveName(char *PhysDriveName, char *MountPoint); -int32 Filesys_GetFsInfo(os_fsinfo_t *finesys_info); +int32 filesys_GetFsInfo(os_fsinfo_t *finesys_info); From 01a70efca9559869a0289bb2494224ec84f5bc2a Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 25 Jul 2017 16:58:06 -0400 Subject: [PATCH 070/122] Update cFE_booter to use sl as a library, and deleted the copied version --- .../no_interface/cFE_booter/Makefile | 2 +- .../no_interface/cFE_booter/ostask.c | 26 +- .../no_interface/cFE_booter/sl.c | 491 ------------------ .../no_interface/cFE_booter/sl.h | 435 ---------------- .../no_interface/cFE_booter/sl_consts.h | 7 - .../no_interface/cFE_booter/sl_lock.c | 36 -- .../no_interface/cFE_booter/sl_lock.h | 39 -- .../no_interface/cFE_booter/sl_mod_fprr.c | 3 - .../no_interface/cFE_booter/sl_plugins.h | 47 -- .../no_interface/cFE_booter/sl_thd.h | 42 -- .../cFE_booter/sl_thd_static_backend.c | 44 -- .../cFE_booter/sl_timer_mod_periodic.c | 21 - src/components/lib/sl/sl.c | 11 +- 13 files changed, 14 insertions(+), 1190 deletions(-) delete mode 100644 src/components/implementation/no_interface/cFE_booter/sl.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/sl.h delete mode 100644 src/components/implementation/no_interface/cFE_booter/sl_consts.h delete mode 100644 src/components/implementation/no_interface/cFE_booter/sl_lock.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/sl_lock.h delete mode 100644 src/components/implementation/no_interface/cFE_booter/sl_plugins.h delete mode 100644 src/components/implementation/no_interface/cFE_booter/sl_thd.h delete mode 100644 src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c delete mode 100644 src/components/implementation/no_interface/cFE_booter/sl_timer_mod_periodic.c diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index 428deee4f9..804cb18680 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -4,7 +4,7 @@ COMPONENT=cFE_booter.o INTERFACES= DEPENDENCIES= IF_LIB:=./composite_cFE.o $(wildcard test/*.o) -ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api -lcos_defkernel_api -lheap +ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api -lcos_defkernel_api -lsl -lheap -lsl_thd_static_backend -lsl_lock include ../../Makefile.subsubdir CFLAGS += -I./gen -I ./test/shared $(CPPFLAGS) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 22d1842ece..b59dd94b11 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -66,30 +66,24 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, uint32 stack_size, uint32 priority, uint32 flags) { - int32 result = OS_SUCCESS; - - sl_cs_enter(); + // TODO: Verify that we don't need to take the cs here // Stack pointers can sometimes be null and that's ok for us if(task_id == NULL || task_name == NULL || function_pointer == NULL){ - result = OS_INVALID_POINTER; - goto exit; + return OS_INVALID_POINTER; } // Validate the name if(!is_valid_name(task_name)) { - result = OS_ERR_NAME_TOO_LONG; - goto exit; + return OS_ERR_NAME_TOO_LONG; } if(is_thread_name_taken(task_name)) { - result = OS_ERR_NAME_TAKEN; - goto exit; + return OS_ERR_NAME_TAKEN; } if(priority > 255 || priority < 1) { - result = OS_ERR_INVALID_PRIORITY; - goto exit; + return OS_ERR_INVALID_PRIORITY; } struct sl_thd* thd = sl_thd_alloc(osal_task_entry_wrapper, function_pointer); @@ -106,9 +100,7 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, *task_id = (uint32) thd->thdid; -exit: - sl_cs_exit(); - return result; + return OS_SUCCESS; } int32 OS_TaskDelete(uint32 task_id) @@ -139,12 +131,6 @@ uint32 OS_TaskGetId(void) void OS_TaskExit(void) { sl_thd_free(sl_thd_curr()); - - // TODO: Fix yield so that I can yield here, not do this weird hack - // Have to use this hack, since we can't yield from a free thread - sl_cs_enter(); - sl_cs_exit_schedule(); - PANIC("Should be unreachable!"); } diff --git a/src/components/implementation/no_interface/cFE_booter/sl.c b/src/components/implementation/no_interface/cFE_booter/sl.c deleted file mode 100644 index 8e6b38c266..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/sl.c +++ /dev/null @@ -1,491 +0,0 @@ -/** - * Redistribution of this file is permitted under the BSD two clause license. - * - * Copyright 2017, The George Washington University - * Author: Gabriel Parmer, gparmer@gwu.edu - */ - -#include -#include -#include -#include -#include - -#include "cFE_util.h" - -struct sl_global sl_global_data; - -/* - * These functions are removed from the inlined fast-paths of the - * critical section (cs) code to save on code size/locality - */ -int -sl_cs_enter_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, thdcap_t curr, sched_tok_t tok) -{ - struct sl_thd *t = sl_thd_curr(); - struct sl_global *g = sl__globals(); - int ret; - - /* recursive locks are not allowed */ - assert(csi->s.owner != t->thdcap); - if (!csi->s.contention) { - csi->s.contention = 1; - if (!ps_cas(&g->lock.u.v, cached->v, csi->v)) return 1; - } - /* Switch to the owner of the critical section, with inheritance using our tcap/priority */ - if ((ret = cos_defswitch(csi->s.owner, t->prio, g->timeout_next, tok))) return ret; - /* if we have an outdated token, then we want to use the same repeat loop, so return to that */ - - return 1; -} - -/* Return 1 if we need a retry, 0 otherwise */ -int -sl_cs_exit_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, sched_tok_t tok) -{ - struct sl_thd *t = sl_thd_curr(); - struct sl_global *g = sl__globals(); - - if (!ps_cas(&g->lock.u.v, cached->v, 0)) return 1; - /* let the scheduler thread decide which thread to run next, inheriting our budget/priority */ - cos_defswitch(g->sched_thdcap, t->prio, g->timeout_next, tok); - - return 0; -} - -/* Timeout and wakeup functionality */ -/* - * TODO: - * (comments from Gabe) - * We likely want to replace all of this with rb-tree with nodes internal to the threads. - * This heap is fast, but the static memory allocation is not great. - */ -struct timeout_heap { - struct heap h; - void *data[SL_MAX_NUM_THDS]; -}; - -static struct timeout_heap timeout_heap; - -struct heap * -sl_timeout_heap(void) -{ return &timeout_heap.h; } - -static inline void -sl_timeout_block(struct sl_thd *t, cycles_t timeout) -{ - assert(t && t->timeout_idx == -1); /* not already in heap */ - assert(heap_size(sl_timeout_heap()) < SL_MAX_NUM_THDS); - - if (!timeout) { - cycles_t tmp = t->periodic_cycs; - - assert(t->period); - t->periodic_cycs += t->period; /* implicit timeout = task period */ - assert(tmp < t->periodic_cycs); /* wraparound check */ - t->timeout_cycs = t->periodic_cycs; - } else { - t->timeout_cycs = timeout; - } - - t->wakeup_cycs = 0; - heap_add(sl_timeout_heap(), t); -} - -static inline void -sl_timeout_remove(struct sl_thd *t) -{ - assert(t && t->timeout_idx > 0); - assert(heap_size(sl_timeout_heap())); - - heap_remove(sl_timeout_heap(), t->timeout_idx); - t->timeout_idx = -1; -} - -static int -__sl_timeout_compare_min(void *a, void *b) -{ - /* FIXME: logic for wraparound in either timeout_cycs */ - return ((struct sl_thd *)a)->timeout_cycs <= ((struct sl_thd *)b)->timeout_cycs; -} - -static void -__sl_timeout_update_idx(void *e, int pos) -{ ((struct sl_thd *)e)->timeout_idx = pos; } - -static void -sl_timeout_init(void) -{ - sl_timeout_period(SL_PERIOD_US); - heap_init(sl_timeout_heap(), SL_MAX_NUM_THDS, __sl_timeout_compare_min, __sl_timeout_update_idx); -} - -/* - * @return: 1 if it's already WOKEN. - * 0 if it successfully blocked in this call. - */ -int -sl_thd_block_no_cs(struct sl_thd *t, sl_thd_state block_type) -{ - assert(t); - assert(block_type == SL_THD_BLOCKED_TIMEOUT || block_type == SL_THD_BLOCKED); - - if (unlikely(t->state == SL_THD_WOKEN)) { - t->state = SL_THD_RUNNABLE; - return 1; - } - - assert(t->state == SL_THD_RUNNABLE); - t->state = block_type; - sl_mod_block(sl_mod_thd_policy_get(t)); - - return 0; -} - -void -sl_thd_block(thdid_t tid) -{ - struct sl_thd *t; - - /* TODO: dependencies not yet supported */ - assert(!tid); - - sl_cs_enter(); - t = sl_thd_curr(); - - if (sl_thd_block_no_cs(t, SL_THD_BLOCKED)) { - sl_cs_exit(); - return; - } - - sl_cs_exit_schedule(); - - return; -} - -/* - * if timeout == 0, blocks on timeout = last periodic wakeup + task period - * @return: 0 if blocked in this call. 1 if already WOKEN! - */ -static inline int -sl_thd_block_timeout_intern(thdid_t tid, cycles_t timeout) -{ - struct sl_thd *t; - - sl_cs_enter(); - t = sl_thd_curr(); - - if (sl_thd_block_no_cs(t, SL_THD_BLOCKED_TIMEOUT)) { - sl_cs_exit(); - return 1; - } - - - assert(timeout || t->period); - sl_timeout_block(t, timeout); - - sl_cs_exit_schedule(); - - return 0; -} - -cycles_t -sl_thd_block_timeout(thdid_t tid, cycles_t abs_timeout) -{ - cycles_t jitter = 0, wcycs, tcycs; - struct sl_thd *t = sl_thd_curr(); - - /* TODO: dependencies not yet supported */ - assert(!tid); - - if (unlikely(!abs_timeout)) { - sl_thd_block(tid); - goto done; - } - - if (sl_thd_block_timeout_intern(tid, abs_timeout)) goto done; - wcycs = t->wakeup_cycs; - tcycs = t->timeout_cycs; - if (wcycs > tcycs) jitter = wcycs - tcycs; - -done: - return jitter; -} - -unsigned int -sl_thd_block_periodic(thdid_t tid) -{ - cycles_t wcycs, pcycs; - unsigned int jitter = 0; - struct sl_thd *t = sl_thd_curr(); - - /* TODO: dependencies not yet supported */ - assert(!tid); - - if (sl_thd_block_timeout_intern(tid, 0)) goto done; - wcycs = t->wakeup_cycs; - pcycs = t->periodic_cycs; - if (wcycs > pcycs) jitter = ((unsigned int)((wcycs - pcycs) / t->period)) + 1; - -done: - return jitter; -} - -/* - * @return: 1 if it's already RUNNABLE. - * 0 if it was woken up in this call - */ -int -sl_thd_wakeup_no_cs(struct sl_thd *t) -{ - assert(t); - - if (unlikely(t->state == SL_THD_RUNNABLE)) { - t->state = SL_THD_WOKEN; - return 1; - } - - /* TODO: for AEP threads, wakeup events from kernel could be level-triggered. */ - assert(t->state == SL_THD_BLOCKED || t->state == SL_THD_BLOCKED_TIMEOUT); - t->state = SL_THD_RUNNABLE; - sl_mod_wakeup(sl_mod_thd_policy_get(t)); - - return 0; -} - -void -sl_thd_wakeup(thdid_t tid) -{ - struct sl_thd *t; - tcap_t tcap; - tcap_prio_t prio; - - sl_cs_enter(); - t = sl_thd_lkup(tid); - if (unlikely(!t)) goto done; - - if (t->state == SL_THD_BLOCKED_TIMEOUT) sl_timeout_remove(t); - if(sl_thd_wakeup_no_cs(t)) goto done; - sl_cs_exit_schedule(); - - return; -done: - sl_cs_exit(); - return; -} - -void -sl_thd_yield_cs_exit(thdid_t tid) -{ - struct sl_thd *t = sl_thd_curr(); - - if (tid) { - struct sl_thd *to = sl_thd_lkup(tid); - - assert(to); - assert(to->state == SL_THD_RUNNABLE); - sl_cs_exit_switchto(to); - } else { - sl_mod_yield(sl_mod_thd_policy_get(t), NULL); - sl_cs_exit_schedule(); - } -} - -void -sl_thd_yield(thdid_t tid) -{ - sl_cs_enter(); - sl_thd_yield_cs_exit(tid); -} - -static struct sl_thd * -sl_thd_alloc_init(thdid_t tid, thdcap_t thdcap) -{ - struct sl_thd_policy *tp = NULL; - struct sl_thd *t = NULL; - - tp = sl_thd_alloc_backend(tid); - if (!tp) goto done; - t = sl_mod_thd_get(tp); - - t->thdid = tid; - t->thdcap = thdcap; - t->state = SL_THD_RUNNABLE; - sl_thd_index_add_backend(sl_mod_thd_policy_get(t)); - - t->period = t->timeout_cycs = t->periodic_cycs = 0; - t->wakeup_cycs = 0; - t->timeout_idx = -1; - t->prio = TCAP_PRIO_MIN; - -done: - return t; -} - -/* boot_thd = 1 if you want to create a boot-up thread in a separate component */ -static struct sl_thd * -sl_thd_alloc_intern(cos_thd_fn_t fn, void *data, struct cos_defcompinfo *comp, int boot_thd) -{ - struct cos_defcompinfo *dci = cos_defcompinfo_curr_get(); - struct cos_compinfo *ci = &dci->ci; - struct sl_thd *t = NULL; - thdcap_t thdcap; - thdid_t tid; - - if (!boot_thd) thdcap = cos_thd_alloc(ci, ci->comp_cap, fn, data); - else thdcap = cos_initthd_alloc(ci, comp->ci.comp_cap); - if (!thdcap) goto done; - - tid = cos_introspect(ci, thdcap, THD_GET_TID); - assert(tid); - t = sl_thd_alloc_init(tid, thdcap); - sl_mod_thd_create(sl_mod_thd_policy_get(t)); -done: - return t; -} - -struct sl_thd * -sl_thd_alloc(cos_thd_fn_t fn, void *data) -{ return sl_thd_alloc_intern(fn, data, NULL, 0); } - -/* Allocate a thread that executes in the specified component */ -struct sl_thd * -sl_thd_comp_alloc(struct cos_defcompinfo *comp) -{ return sl_thd_alloc_intern(NULL, NULL, comp, 1); } - -void -sl_thd_free(struct sl_thd *t) -{ - struct sl_thd *ct = sl_thd_curr(); - - sl_cs_enter(); - /* remove the thread from the timeout queue before freeing it */ - if (t->state == SL_THD_BLOCKED_TIMEOUT) { - assert(t != ct); - sl_timeout_remove(t); - } - - sl_mod_thd_delete(sl_mod_thd_policy_get(t)); - - sl_thd_index_rem_backend(sl_mod_thd_policy_get(t)); - t->state = SL_THD_FREE; - /* TODO: add logic for the graveyard to delay this deallocation if t == current */ - sl_thd_free_backend(sl_mod_thd_policy_get(t)); - - if (unlikely(t == ct)) { - sl_cs_exit_schedule(); - /* should never get here */ - assert(0); - } - - sl_cs_exit(); -} - -void -sl_thd_param_set(struct sl_thd *t, sched_param_t sp) -{ - sched_param_type_t type; - unsigned int value; - - sched_param_get(sp, &type, &value); - - switch (type) { - case SCHEDP_WINDOW: - { - t->period = sl_usec2cyc(value); - t->periodic_cycs = sl_now(); /* TODO: synchronize for all tasks */ - break; - } - default: break; - } - - sl_mod_thd_param_set(sl_mod_thd_policy_get(t), type, value); -} - -void -sl_timeout_period(microsec_t period) -{ - cycles_t p = sl_usec2cyc(period); - - sl__globals()->period = p; - sl_timeout_relative(p); -} - -/* engage space heater mode */ -void -sl_idle(void *d) -{ while (1) sl_thd_yield(0); } - -void -sl_init(void) -{ - struct sl_global *g = sl__globals(); - struct cos_defcompinfo *ci = cos_defcompinfo_curr_get(); - - /* must fit in a word */ - assert(sizeof(struct sl_cs) <= sizeof(unsigned long)); - - g->cyc_per_usec = cos_hw_cycles_per_usec(BOOT_CAPTBL_SELF_INITHW_BASE); - g->lock.u.v = 0; - - sl_thd_init_backend(); - sl_mod_init(); - sl_timeout_init(); - - /* Create the scheduler thread for us */ - g->sched_thd = sl_thd_alloc_init(cos_thdid(), BOOT_CAPTBL_SELF_INITTHD_BASE); - assert(g->sched_thd); - g->sched_thdcap = BOOT_CAPTBL_SELF_INITTHD_BASE; - - g->idle_thd = sl_thd_alloc(sl_idle, NULL); - assert(g->idle_thd); - - return; -} - -void -sl_sched_loop(void) -{ - while (1) { - int pending; - - do { - thdid_t tid; - int blocked, rcvd; - cycles_t cycles; - struct sl_thd *t; - - /* - * a child scheduler may receive both scheduling notifications (block/unblock - * states of it's child threads) and normal notifications (mainly activations from - * it's parent scheduler). - */ - pending = cos_sched_rcv(BOOT_CAPTBL_SELF_INITRCV_BASE, RCV_ALL_PENDING, - &rcvd, &tid, &blocked, &cycles); - if (!tid) continue; - - t = sl_thd_lkup(tid); - assert(t); - /* don't report the idle thread */ - if (unlikely(t == sl__globals()->idle_thd)) continue; - - /* - * receiving scheduler notifications is not in critical section mainly for - * 1. scheduler thread can often be blocked in rcv, which can add to - * interrupt execution or even AEP thread execution overheads. - * 2. scheduler events are not acting on the sl_thd or the policy structures, so - * having finer grained locks around the code that modifies sl_thd states is better. - */ - if (sl_cs_enter_sched()) continue; - sl_mod_execution(sl_mod_thd_policy_get(t), cycles); - if (blocked) sl_mod_block(sl_mod_thd_policy_get(t)); - else sl_mod_wakeup(sl_mod_thd_policy_get(t)); - - sl_cs_exit(); - } while (pending); - - if (sl_cs_enter_sched()) continue; - /* If switch returns an inconsistency, we retry anyway */ - sl_cs_exit_schedule_nospin(); - } -} diff --git a/src/components/implementation/no_interface/cFE_booter/sl.h b/src/components/implementation/no_interface/cFE_booter/sl.h deleted file mode 100644 index f1189d2451..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/sl.h +++ /dev/null @@ -1,435 +0,0 @@ -/** - * Redistribution of this file is permitted under the BSD two clause license. - * - * Copyright 2017, The George Washington University - * Author: Gabriel Parmer, gparmer@gwu.edu - */ - -/* - * Scheduler library (sl) abstractions and functions. - * - * This library does a few things: - * 1. hide the esoteric nature of the cos_kernel_api's dispatch - * methods, and the scheduler event notifications + scheduler - * thread, - * 2. provide synchronization around scheduler data-strutures, and - * 3. abstract shared details about thread blocking/wakeup, lookup, - * and inter-thread dependency management. - * - * This library interacts with a number of other libraries/modules. - * - * - uses: dispatching functions in the cos_kernel_api (which uses, - * the kernel system call layer) - * - uses: parsec (ps) for atomic instructions and synchronization - * - uses: memory allocation functions provided by a run-time (either - * management of static memory, or something like parsec) - * - uses: scheduler modules that implement the scheduling policy - * - */ - -#ifndef SL_H -#define SL_H - -#include -#include -#include -#include -#include -#include -#include - -/* Critical section (cs) API to protect scheduler data-structures */ -struct sl_cs { - union sl_cs_intern { - struct { - thdcap_t owner :31; - u32_t contention :1; - } PS_PACKED s; - unsigned long v; - } u; -}; - -struct sl_global { - struct sl_cs lock; - - thdcap_t sched_thdcap; - struct sl_thd *sched_thd; - struct sl_thd *idle_thd; - - int cyc_per_usec; - cycles_t period; - cycles_t timer_next; - tcap_time_t timeout_next; -}; - -extern struct sl_global sl_global_data; - -static inline struct sl_global * -sl__globals(void) -{ return &sl_global_data; } - -static inline void -sl_thd_setprio(struct sl_thd *t, tcap_prio_t p) -{ t->prio = p; } - -static inline struct sl_thd * -sl_thd_lkup(thdid_t tid) -{ - assert(tid != 0); - if (unlikely(tid > MAX_NUM_THREADS)) return NULL; - return sl_mod_thd_get(sl_thd_lookup_backend(tid)); -} - -static inline thdid_t -sl_thdid(void) -{ - thdid_t tid = cos_thdid(); - - assert(tid != 0); - assert(tid < MAX_NUM_THREADS); - - return tid; -} - - -static inline struct sl_thd * -sl_thd_curr(void) -{ return sl_thd_lkup(sl_thdid()); } - -/* are we the owner of the critical section? */ -static inline int -sl_cs_owner(void) -{ return sl__globals()->lock.u.s.owner == sl_thd_curr()->thdcap; } - -/* ...not part of the public API */ -/* - * @csi: current critical section value - * @cached: a cached copy of @csi - * @curr: currently executing thread - * @tok: scheduler synchronization token for cos_defswitch - * - * @ret: - * (Caller of this function should retry for a non-zero return value.) - * 1 for cas failure or after successful thread switch to thread that owns the lock. - * -ve from cos_defswitch failure, allowing caller for ex: the scheduler thread to - * check if it was -EBUSY to first recieve pending notifications before retrying lock. - */ -int sl_cs_enter_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, thdcap_t curr, sched_tok_t tok); -/* - * @csi: current critical section value - * @cached: a cached copy of @csi - * @tok: scheduler synchronization token for cos_defswitch - * - * @ret: returns 1 if we need a retry, 0 otherwise - */ -int sl_cs_exit_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, sched_tok_t tok); - -/* Enter into the scheduler critical section */ -static inline int -sl_cs_enter_nospin(void) -{ - union sl_cs_intern csi, cached; - struct sl_thd *t = sl_thd_curr(); - sched_tok_t tok; - - assert(t); - tok = cos_sched_sync(); - csi.v = sl__globals()->lock.u.v; - cached.v = csi.v; - - if (unlikely(csi.s.owner)) { - return sl_cs_enter_contention(&csi, &cached, t->thdcap, tok); - } - - csi.s.owner = t->thdcap; - if (!ps_cas(&sl__globals()->lock.u.v, cached.v, csi.v)) return 1; - - return 0; -} - -/* Enter into scheduler cs from a non-sched thread context */ -static inline void -sl_cs_enter(void) -{ while (sl_cs_enter_nospin()) ; } - -/* - * Enter into scheduler cs from scheduler thread context - * @ret: returns -EBUSY if sched thread has events to process and cannot switch threads, 0 otherwise. - */ -static inline int -sl_cs_enter_sched(void) -{ - int ret; - - while ((ret = sl_cs_enter_nospin())) { - if (ret == -EBUSY) break; - } - - return ret; -} - -/* - * Release the scheduler critical section, switch to the scheduler - * thread if there is pending contention - */ -static inline void -sl_cs_exit(void) -{ - union sl_cs_intern csi, cached; - sched_tok_t tok; - - assert(sl_cs_owner()); - -retry: - tok = cos_sched_sync(); - csi.v = sl__globals()->lock.u.v; - cached.v = csi.v; - - if (unlikely(csi.s.contention)) { - if (sl_cs_exit_contention(&csi, &cached, tok)) goto retry; - return; - } - - if (!ps_cas(&sl__globals()->lock.u.v, cached.v, 0)) goto retry; -} - -/* - * if tid == 0, just block the current thread; otherwise, create a - * dependency from this thread on the target tid (i.e. when the - * scheduler chooses to run this thread, we will run the dependency - * instead (note that "dependency" is transitive). - */ -void sl_thd_block(thdid_t tid); -/* - * @abs_timeout: absolute timeout at which thread should be woken-up. - * if abs_timeout == 0, block forever = sl_thd_block() - * - * @returns: 0 if the thread is woken up by external events before timeout. - * +ve - number of cycles elapsed from abs_timeout before the thread - * was woken up by Timeout module. - */ -cycles_t sl_thd_block_timeout(thdid_t tid, cycles_t abs_timeout); -/* - * blocks for a timeout = next replenishment period of the task. - * Note: care should be taken to not interleave this with sl_thd_block_timeout(). - * It may be required to interleave, in such cases, timeout values in - * sl_thd_block_timeout() should not be greater than or equal to - * the task's next replenishment period. - * - * @returns: 0 if the thread is woken up by external events before timeout. - * +ve - number of periods elapsed. (1 if it wokeup exactly at timeout = next period) - */ -unsigned int sl_thd_block_periodic(thdid_t tid); -int sl_thd_block_no_cs(struct sl_thd *t, sl_thd_state block_type); - -/* wakeup a thread that has (or soon will) block */ -void sl_thd_wakeup(thdid_t tid); -int sl_thd_wakeup_no_cs(struct sl_thd *t); - -void sl_thd_yield(thdid_t tid); -void sl_thd_yield_cs_exit(thdid_t tid); - -/* The entire thread allocation and free API */ -struct sl_thd *sl_thd_alloc(cos_thd_fn_t fn, void *data); -struct sl_thd *sl_thd_comp_alloc(struct cos_defcompinfo *comp); -void sl_thd_free(struct sl_thd *t); - -void sl_thd_param_set(struct sl_thd *t, sched_param_t sp); - -static inline microsec_t -sl_cyc2usec(cycles_t cyc) -{ return cyc / sl__globals()->cyc_per_usec; } - -static inline microsec_t -sl_usec2cyc(microsec_t usec) -{ return usec * sl__globals()->cyc_per_usec; } - -static inline cycles_t -sl_now(void) -{ return ps_tsc(); } - -static inline microsec_t -sl_now_usec(void) -{ return sl_cyc2usec(sl_now()); } - -/* - * Time and timeout API. - * - * This can be used by the scheduler policy module *and* by the - * surrounding component code. To avoid race conditions between - * reading the time, and setting a timeout, we avoid relative time - * measurements. sl_now gives the current cycle count that is on an - * absolute timeline. The periodic function sets a period that can be - * used when a timeout has happened, the relative function sets a - * timeout relative to now, and the oneshot timeout sets a timeout on - * the same absolute timeline as returned by sl_now. - */ -void sl_timeout_period(cycles_t period); - -static inline cycles_t -sl_timeout_period_get(void) -{ return sl__globals()->period; } - -static inline void -sl_timeout_oneshot(cycles_t absolute_us) -{ - sl__globals()->timer_next = absolute_us; - sl__globals()->timeout_next = tcap_cyc2time(absolute_us); -} - -static inline void -sl_timeout_relative(cycles_t offset) -{ sl_timeout_oneshot(sl_now() + offset); } - -static inline void -sl_timeout_expended(microsec_t now, microsec_t oldtimeout) -{ - cycles_t offset; - - assert(now >= oldtimeout); - - /* in virtual environments, or with very small periods, we might miss more than one period */ - offset = (now - oldtimeout) % sl_timeout_period_get(); - sl_timeout_oneshot(now + sl_timeout_period_get() - offset); -} - -/* to get timeout heap. not a public api */ -struct heap *sl_timeout_heap(void); - -/* wakeup any blocked threads! */ -static inline void -sl_timeout_wakeup_expired(cycles_t now) -{ - if (!heap_size(sl_timeout_heap())) return; - - do { - struct sl_thd *tp, *th; - - tp = heap_peek(sl_timeout_heap()); - assert(tp); - - /* FIXME: logic for wraparound in current tsc */ - if (likely(tp->timeout_cycs > now)) break; - - th = heap_highest(sl_timeout_heap()); - assert(th && th == tp); - th->timeout_idx = -1; - - assert(th->wakeup_cycs == 0); - th->wakeup_cycs = now; - sl_thd_wakeup_no_cs(th); - } while (heap_size(sl_timeout_heap())); -} - -/* - * Do a few things: 1. take the critical section if it isn't already - * taken, 2. call schedule to find the next thread to run, 3. release - * the critical section (note this will cause visual asymmetries in - * your code if you call sl_cs_enter before this function), and - * 4. switch to the given thread. It hides some races, and details - * that would make this difficult to write repetitively. - * - * Preconditions: if synchronization is required with code before - * calling this, you must call sl_cs_enter before-hand (this is likely - * a typical case). - * - * Return: the return value from cos_switch. The caller must handle - * this value correctly. - * - * A common use-case is: - * - * sl_cs_enter(); - * scheduling_stuff() - * sl_cs_exit_schedule(); - * - * ...which correctly handles any race-conditions on thread selection and - * dispatch. - */ -static inline int -sl_cs_exit_schedule_nospin_arg(struct sl_thd *to) -{ - struct sl_thd_policy *pt; - struct sl_thd *t; - struct sl_global *globals = sl__globals(); - thdcap_t thdcap; - tcap_prio_t prio; - sched_tok_t tok; - cycles_t now; - s64_t offset; - - /* Don't abuse this, it is only to enable the tight loop around this function for races... */ - if (unlikely(!sl_cs_owner())) sl_cs_enter(); - - tok = cos_sched_sync(); - now = sl_now(); - offset = (s64_t)(globals->timer_next - now); - if (globals->timer_next && offset <= 0) sl_timeout_expended(now, globals->timer_next); - sl_timeout_wakeup_expired(now); - - /* - * Once we exit, we can't trust t's memory as it could be - * deallocated/modified, so cache it locally. If these values - * are out of date, the scheduler synchronization tok will - * catch it. This is a little twitchy and subtle, so lets put - * it in a function, here. - */ - if (unlikely(to)) { - t = to; - if (t->state != SL_THD_RUNNABLE) to = NULL; - } - if (likely(!to)) { - pt = sl_mod_schedule(); - - if (unlikely(!pt)) { - t = sl__globals()->idle_thd; - } - else t = sl_mod_thd_get(pt); - } - thdcap = t->thdcap; - prio = t->prio; - - - assert(t->state != SL_THD_FREE); - - sl_cs_exit(); - - /* TODO: enable per-thread tcaps for interrupt threads */ - return cos_defswitch(thdcap, prio, sl__globals()->timeout_next, tok); -} - -static inline int -sl_cs_exit_schedule_nospin(void) -{ return sl_cs_exit_schedule_nospin_arg(NULL); } - -static inline void -sl_cs_exit_schedule(void) -{ while (sl_cs_exit_schedule_nospin()) ; } - -static inline void -sl_cs_exit_switchto(struct sl_thd *to) -{ - /* - * We only try once, so it is possible that we don't end up - * switching to the desired thread. However, this is always a - * case that the caller has to consider if the current thread - * has a higher priority than the "to" thread. - */ - if (sl_cs_exit_schedule_nospin_arg(to)) { - sl_cs_exit_schedule(); - } -} - -/* - * Initialization protocol in cos_init: initialization of - * library-internal data-structures, and then the ability for the - * scheduler thread to start its scheduling loop. - * - * sl_init(); - * sl_*; <- use the sl_api here - * ... - * sl_sched_loop(); <- loop here - */ -void sl_init(void); -void sl_sched_loop(void); - -#endif /* SL_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_consts.h b/src/components/implementation/no_interface/cFE_booter/sl_consts.h deleted file mode 100644 index 7990910dc0..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/sl_consts.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef SL_CONSTS -#define SL_CONSTS - -#define SL_PERIOD_US 1000 -#define SL_MAX_NUM_THDS MAX_NUM_THREADS - -#endif /* SL_CONSTS */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_lock.c b/src/components/implementation/no_interface/cFE_booter/sl_lock.c deleted file mode 100644 index 7ac5793603..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/sl_lock.c +++ /dev/null @@ -1,36 +0,0 @@ -#include "sl.h" -#include "sl_lock.h" - -void -sl_lock_init(struct sl_lock *lock) -{ - *lock = SL_LOCK_STATIC_INIT(); -} - -thdid_t -sl_lock_holder(struct sl_lock *lock) -{ - return lock->holder; -} - -int -sl_lock_timed_take(struct sl_lock *lock, microsec_t max_wait_time) -{ - int result; - cycles_t deadline = sl_now() + sl_usec2cyc(max_wait_time); - - sl_cs_enter(); - while (lock->holder != 0 && sl_now() < deadline) { - sl_thd_yield_cs_exit(lock->holder); - sl_cs_enter(); - } - - if (lock->holder == 0) { - lock->holder = sl_thdid(); - result = 1; - } else { - result = 0; - } - sl_cs_exit(); - return result; -} diff --git a/src/components/implementation/no_interface/cFE_booter/sl_lock.h b/src/components/implementation/no_interface/cFE_booter/sl_lock.h deleted file mode 100644 index 7611432ef1..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/sl_lock.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef SL_LOCK_H -#define SL_LOCK_H - -#include - -struct sl_lock { - // will be 0 if no one holds the lock - volatile thdid_t holder; -}; - -#define SL_LOCK_STATIC_INIT() (struct sl_lock){ .holder = 0 } - -void sl_lock_init(struct sl_lock *lock); - -thdid_t sl_lock_holder(struct sl_lock *lock); - -static inline void sl_lock_take(struct sl_lock *lock) -{ - sl_cs_enter(); - while (lock->holder != 0) { - sl_thd_yield_cs_exit(lock->holder); - sl_cs_enter(); - } - lock->holder = sl_thdid(); - sl_cs_exit(); -} - -int sl_lock_timed_take(struct sl_lock *lock, microsec_t max_wait_time); - -static inline void sl_lock_release(struct sl_lock *lock) -{ - sl_cs_enter(); - assert(lock->holder == sl_thdid()); - lock->holder = 0; - sl_cs_exit(); -} - - -#endif diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c index b0bc120033..4720528ca1 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c +++ b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c @@ -3,8 +3,6 @@ #include #include -#include "cFE_util.h" - #define SL_FPRR_NPRIOS 257 #define SL_FPRR_PRIO_HIGHEST 0 #define SL_FPRR_PRIO_LOWEST (SL_FPRR_NPRIOS-1) @@ -31,7 +29,6 @@ sl_mod_schedule(void) return t; } - printc("Found nothing to schedule...\n"); return NULL; } diff --git a/src/components/implementation/no_interface/cFE_booter/sl_plugins.h b/src/components/implementation/no_interface/cFE_booter/sl_plugins.h deleted file mode 100644 index a2972e57f9..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/sl_plugins.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef SL_PLUGINS_H -#define SL_PLUGINS_H - -#include -#include - -/* - * The build system has to add in the appropriate backends for the - * system. We rely on the linker to hook up all of these function - * call instead of function pointers so that we can statically analyze - * stack consumption and execution paths (e.g. for WCET) which are - * prohibited by function pointers. Additionally, significant work - * (by Daniel Lohmann's group) has shown that a statically configured - * system is more naturally fault resilient. A minor benefit is the - * performance of not using function pointers, but that is secondary. - */ -struct sl_thd_policy *sl_thd_alloc_backend(thdid_t tid); -void sl_thd_free_backend(struct sl_thd_policy *t); - -void sl_thd_index_add_backend(struct sl_thd_policy *); -void sl_thd_index_rem_backend(struct sl_thd_policy *); -struct sl_thd_policy *sl_thd_lookup_backend(thdid_t); -void sl_thd_init_backend(void); - -/* - * Each scheduler policy must implement the following API. See above - * for why this is not a function-pointer-based API. - * - * Scheduler modules (policies) should define the following - */ -struct sl_thd_policy; -static inline struct sl_thd *sl_mod_thd_get(struct sl_thd_policy *tp); -static inline struct sl_thd_policy *sl_mod_thd_policy_get(struct sl_thd *t); - -void sl_mod_execution(struct sl_thd_policy *t, cycles_t cycles); -struct sl_thd_policy *sl_mod_schedule(void); - -void sl_mod_block(struct sl_thd_policy *t); -void sl_mod_wakeup(struct sl_thd_policy *t); -void sl_mod_yield(struct sl_thd_policy *t, struct sl_thd_policy *tp); - -void sl_mod_thd_create(struct sl_thd_policy *t); -void sl_mod_thd_delete(struct sl_thd_policy *t); -void sl_mod_thd_param_set(struct sl_thd_policy *t, sched_param_type_t type, unsigned int val); -void sl_mod_init(void); - -#endif /* SL_PLUGINS_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_thd.h b/src/components/implementation/no_interface/cFE_booter/sl_thd.h deleted file mode 100644 index 0d09403624..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/sl_thd.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Redistribution of this file is permitted under the BSD two clause license. - * - * Copyright 2017, The George Washington University - * Author: Gabriel Parmer, gparmer@gwu.edu - */ - -#ifndef SL_THD_H -#define SL_THD_H - -typedef enum { - SL_THD_FREE = 0, - SL_THD_BLOCKED, - SL_THD_BLOCKED_TIMEOUT, - SL_THD_WOKEN, /* if a race causes a wakeup before the inevitable block */ - SL_THD_RUNNABLE, - SL_THD_DYING, -} sl_thd_state; - -struct sl_thd { - sl_thd_state state; - thdid_t thdid; - thdcap_t thdcap; - tcap_prio_t prio; - struct sl_thd *dependency; - - cycles_t period; - cycles_t periodic_cycs; /* for implicit periodic timeouts */ - cycles_t timeout_cycs; /* next timeout - used in timeout API */ - cycles_t wakeup_cycs; /* actual last wakeup - used in timeout API for jitter information, etc */ - int timeout_idx; /* timeout heap index, used in timeout API */ -}; - -#ifndef assert -#define assert(node) do { if (unlikely(!(node))) { debug_print("assert error in @ "); *((int *)0) = 0; } } while (0) -#define PRINT_FN prints -#define debug_print(str) (PRINT_FN(str __FILE__ ":" STR(__LINE__) ".\n")) -#define BUG() do { debug_print("BUG @ "); *((int *)0) = 0; } while (0); -#define SPIN() do { while (1) ; } while (0) -#endif - -#endif /* SL_THD_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c b/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c deleted file mode 100644 index 14ee6df337..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Redistribution of this file is permitted under the BSD two clause license. - * - * Copyright 2017, The George Washington University - * Author: Gabriel Parmer, gparmer@gwu.edu - */ - -#include -#include -#include -#include - -static struct sl_thd_policy sl_threads[SL_MAX_NUM_THDS]; - -/* Default implementations of backend functions */ -struct sl_thd_policy * -sl_thd_alloc_backend(thdid_t tid) -{ - assert(tid < SL_MAX_NUM_THDS); - return &sl_threads[tid]; -} - -void -sl_thd_free_backend(struct sl_thd_policy *t) -{ } - -void -sl_thd_index_add_backend(struct sl_thd_policy *t) -{ } - -void -sl_thd_index_rem_backend(struct sl_thd_policy *t) -{ } - -struct sl_thd_policy * -sl_thd_lookup_backend(thdid_t tid) -{ - assert(tid < SL_MAX_NUM_THDS); - return &sl_threads[tid]; -} - -void -sl_thd_init_backend(void) -{ assert(SL_MAX_NUM_THDS <= MAX_NUM_THREADS); } diff --git a/src/components/implementation/no_interface/cFE_booter/sl_timer_mod_periodic.c b/src/components/implementation/no_interface/cFE_booter/sl_timer_mod_periodic.c deleted file mode 100644 index b7b815bc91..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/sl_timer_mod_periodic.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include -#include - -void -sl_timeout_mod_expended(microsec_t now, microsec_t oldtimeout) -{ - cycles_t offset; - - assert(now >= oldtimeout); - - /* in virtual environments, or with very small periods, we might miss more than one period */ - offset = (now - oldtimeout) % sl_timeout_period_get(); - sl_timeout_oneshot(now + sl_timeout_period_get() - offset); -} - -void -sl_timeout_mod_init(void) -{ - sl_timeout_period(SL_PERIOD_US); -} diff --git a/src/components/lib/sl/sl.c b/src/components/lib/sl/sl.c index a97afed231..aaa606ef73 100644 --- a/src/components/lib/sl/sl.c +++ b/src/components/lib/sl/sl.c @@ -53,7 +53,7 @@ sl_cs_exit_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, sched /* Timeout and wakeup functionality */ /* - * TODO: + * TODO: * (comments from Gabe) * We likely want to replace all of this with rb-tree with nodes internal to the threads. * This heap is fast, but the static memory allocation is not great. @@ -94,7 +94,7 @@ static inline void sl_timeout_remove(struct sl_thd *t) { assert(t && t->timeout_idx > 0); - assert(heap_size(sl_timeout_heap())); + assert(heap_size(sl_timeout_heap())); heap_remove(sl_timeout_heap(), t->timeout_idx); t->timeout_idx = -1; @@ -163,7 +163,7 @@ sl_thd_block(thdid_t tid) * if timeout == 0, blocks on timeout = last periodic wakeup + task period * @return: 0 if blocked in this call. 1 if already WOKEN! */ -static inline int +static inline int sl_thd_block_timeout_intern(thdid_t tid, cycles_t timeout) { struct sl_thd *t; @@ -367,9 +367,12 @@ sl_thd_free(struct sl_thd *t) { struct sl_thd *ct = sl_thd_curr(); + if (t->state == SL_THD_FREE) { + return; + } + sl_cs_enter(); - assert(t->state != SL_THD_FREE); if (t->state == SL_THD_BLOCKED_TIMEOUT) sl_timeout_remove(t); sl_thd_index_rem_backend(sl_mod_thd_policy_get(t)); sl_mod_thd_delete(sl_mod_thd_policy_get(t)); From 232627d1901d3d7a9d0d6da17d4cbc14b0284010 Mon Sep 17 00:00:00 2001 From: Joseph Espy Date: Mon, 7 Aug 2017 23:02:49 -0400 Subject: [PATCH 071/122] Update filesystem including good filedescripters, permissions, and file commands The filesystem passes all of the cFE unit tests, it provides all of the functionality that is required by the cFE_booter and that will be needed by the linking and loading. It is much closer to POSIX in the way that is uses FDs. It is still not threadsafe or modularized enough to create a seperate library. --- .../no_interface/cFE_booter/osfiles.c | 99 +- .../no_interface/cFE_booter/osfilesys.c | 862 ++++++++++-------- .../no_interface/cFE_booter/osfilesys.h | 238 +++-- .../no_interface/cFE_booter/tar.c | 128 +++ .../no_interface/cFE_booter/tar.h | 13 + 5 files changed, 783 insertions(+), 557 deletions(-) create mode 100644 src/components/implementation/no_interface/cFE_booter/tar.c create mode 100644 src/components/implementation/no_interface/cFE_booter/tar.h diff --git a/src/components/implementation/no_interface/cFE_booter/osfiles.c b/src/components/implementation/no_interface/cFE_booter/osfiles.c index 01b5f9a9bf..6666c98ed9 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfiles.c +++ b/src/components/implementation/no_interface/cFE_booter/osfiles.c @@ -1,4 +1,5 @@ #include "osfilesys.h" +#include "tar.h" /****************************************************************************** ** Standard File system API @@ -22,20 +23,24 @@ int32 OS_FS_Init(void) */ int32 OS_creat(const char *path, int32 access) { - int32 ret = chk_path_new(path); + int32 ret = path_chk_isvalid(path); + if (access != OS_READ_WRITE && access != OS_WRITE_ONLY) return OS_FS_ERROR; if (ret != OS_FS_SUCCESS) return ret; - file_create((char *)path); - return 0; + ret = file_create((char *) path, access); + return ret; } /* - * Opend a file for reading/writing. Returns file descriptor + * Open a file for reading/writing. Returns file descriptor */ int32 OS_open(const char *path, int32 access, uint32 mode) { - int32 ret = chk_path(path); + if (access != OS_READ_WRITE && access != OS_WRITE_ONLY && access != OS_READ_ONLY) { + return OS_FS_ERROR; + } + int32 ret = path_chk_exists(path); if (ret != OS_FS_SUCCESS) return ret; - return file_open((char *)path); + return file_open((char *)path, access); } /* @@ -43,6 +48,7 @@ int32 OS_open(const char *path, int32 access, uint32 mode) */ int32 OS_close(int32 filedes) { + if (chk_fd(filedes) != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_FD; return file_close(filedes); } @@ -51,7 +57,9 @@ int32 OS_close(int32 filedes) */ int32 OS_read(int32 filedes, void *buffer, uint32 nbytes) { - return file_read(filedes, buffer, nbytes); + if (chk_fd(filedes) != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_FD; + int32 ret = file_read(filedes, buffer, nbytes); + return ret; } /* @@ -76,10 +84,10 @@ int32 OS_chmod(const char *path, uint32 access) */ int32 OS_stat(const char *path, os_fstat_t *filestats) { - if (!filestats) return OS_FS_ERR_INVALID_POINTER; - int32 ret = chk_path(path); + if (!filestats || !path) return OS_FS_ERR_INVALID_POINTER; + int32 ret = path_chk_exists(path); if (ret != OS_FS_SUCCESS) return ret; - return file_stat((char *)path, filestats); + return file_stat((char *) path, (struct hack_stat *) filestats); } /* @@ -95,20 +103,20 @@ int32 OS_lseek(int32 filedes, int32 offset, uint32 whence) */ int32 OS_remove(const char *path) { - int32 ret = chk_path(path); + int32 ret = path_chk_exists(path); if (ret != OS_FS_SUCCESS) return ret; - file_remove((char *)path); - return 0; + ret = file_remove((char *)path); + return ret; } /* * Renames a file in the file system */ -int32 OS_rename(const char *old_filename, const char *new_filename) -{ - int32 ret = chk_path(old_filename); +int32 OS_rename(const char *old_filename, const char *new_filename) { + if (!old_filename || !new_filename) return OS_FS_ERR_INVALID_POINTER; + int32 ret = path_chk_exists(old_filename); if (ret != OS_FS_SUCCESS) return ret; - ret = chk_path(new_filename); + ret = path_chk_isvalid(new_filename); if (ret != OS_FS_SUCCESS) return ret; return file_rename((char *)old_filename, (char *)new_filename); } @@ -118,18 +126,18 @@ int32 OS_rename(const char *old_filename, const char *new_filename) */ int32 OS_cp(const char *src, const char *dest) { + if (!src || !dest) return OS_FS_ERR_INVALID_POINTER; char *src_path = (char *)src; char *dest_path = (char *)dest; - if (!src_path || !dest_path) return OS_FS_ERR_INVALID_POINTER; if (strlen(src_path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; if (strlen(dest_path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; if (strlen(path_to_name(src_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; if (strlen(path_to_name(dest_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; - int32 ret = chk_path(src_path); + int32 ret = path_chk_exists(src_path); if (ret != OS_FS_SUCCESS) return ret; - ret = chk_path_new(dest_path); + ret = path_chk_isvalid(dest_path); if (ret != OS_FS_SUCCESS) return ret; return file_cp(src_path, dest_path); @@ -149,12 +157,13 @@ int32 OS_mv(const char *src, const char *dest) if (strlen(path_to_name(src_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; if (strlen(path_to_name(dest_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; - int32 ret = chk_path(src); + int32 ret = path_chk_exists(src); if (ret != OS_FS_SUCCESS) return ret; - ret = chk_path_new(dest); + ret = path_chk_isvalid(dest); if (ret != OS_FS_SUCCESS) return ret; + ret = file_mv(src_path, dest_path); - return file_mv(src_path, dest_path); + return ret; } /* @@ -173,12 +182,12 @@ int32 OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) */ int32 OS_FileOpenCheck(char *Filename) { - int32 ret = chk_path(Filename); + int32 ret = path_chk_exists(Filename); if (ret != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_POINTER; struct fsobj *file = file_find(Filename); if (!file) return OS_INVALID_POINTER; - if (!file->refcnt) return OS_FS_ERROR; + if (file->refcnt == 0) return OS_FS_ERROR; return OS_FS_SUCCESS; } @@ -200,12 +209,9 @@ int32 OS_CloseAllFiles(void) */ int32 OS_CloseFileByName(char *Filename) { - int32 ret = chk_path(Filename); - if (ret != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_POINTER; - - struct fsobj *file = file_find(Filename); - if (!file || !file->filedes) return OS_FS_ERR_INVALID_POINTER; - return OS_close(file->filedes); + int32 ret = path_chk_exists(Filename); + if (ret != OS_FS_SUCCESS) return ret; + return file_close_by_name(Filename); } /****************************************************************************** @@ -218,9 +224,9 @@ int32 OS_CloseFileByName(char *Filename) */ int32 OS_mkdir(const char *path, uint32 access) { - int32 ret = chk_path_new(path); + int32 ret = path_chk_isvalid(path); if (ret != OS_FS_SUCCESS) return ret; - return dir_mkdir((char *)path); + return file_mkdir((char *)path); } /* @@ -228,8 +234,10 @@ int32 OS_mkdir(const char *path, uint32 access) */ os_dirp_t OS_opendir(const char *path) { - if(chk_path(path) != OS_FS_SUCCESS) return NULL; - return (os_dirp_t) dir_open((char *)path); + if(path_chk_exists(path) != OS_FS_SUCCESS) return NULL; + int32 FD = dir_open((char *)path); + if (FD == 0) return NULL; + return (os_dirp_t) FD; } /* @@ -238,7 +246,7 @@ os_dirp_t OS_opendir(const char *path) int32 OS_closedir(os_dirp_t directory) { if (!directory) return OS_FS_ERR_INVALID_POINTER; - return dir_close((os_dirent_t *) directory); + return dir_close((int32) directory); } /* @@ -247,7 +255,7 @@ int32 OS_closedir(os_dirp_t directory) void OS_rewinddir(os_dirp_t directory) { if (!directory) return; - dir_rewind((os_dirent_t *)directory); + dir_rewind((int32) directory); return; } @@ -257,7 +265,7 @@ void OS_rewinddir(os_dirp_t directory) os_dirent_t *OS_readdir(os_dirp_t directory) { if (!directory) return NULL; - os_dirent_t *dir = dir_read((os_dirent_t *)directory); + os_dirent_t *dir = dir_read((int32) directory); return dir; } @@ -266,9 +274,9 @@ os_dirent_t *OS_readdir(os_dirp_t directory) */ int32 OS_rmdir(const char *path) { - int32 ret = chk_path(path); + int32 ret = path_chk_exists(path); if (ret != OS_FS_SUCCESS) return ret; - return dir_rmdir((char *)path); + return file_rmdir((char *)path); } /****************************************************************************** @@ -322,6 +330,8 @@ int32 OS_rmfs(char *devname) int32 OS_unmount(const char *mountpoint) { if (!mountpoint) return OS_FS_ERR_INVALID_POINTER; + int32 ret = path_chk_exists(mountpoint); + if (ret != OS_FS_SUCCESS) return ret; return fs_unmount((char *)mountpoint); } @@ -365,7 +375,7 @@ os_fshealth_t OS_chkfs(const char *name, boolean repair) int32 OS_FS_GetPhysDriveName(char * PhysDriveName, char * MountPoint) { if (!PhysDriveName || !MountPoint) return OS_FS_ERR_INVALID_POINTER; - int32 ret = chk_path(MountPoint); + int32 ret = path_chk_exists(MountPoint); if (ret != OS_FS_SUCCESS) return ret; return filesys_GetPhysDriveName(PhysDriveName, MountPoint); } @@ -376,12 +386,7 @@ int32 OS_FS_GetPhysDriveName(char * PhysDriveName, char * MountPoint) */ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) { - if (!VirtualPath || !LocalPath) return OS_FS_ERR_INVALID_POINTER; - int32 ret = chk_path(VirtualPath); - if (ret != OS_FS_SUCCESS) return ret; - - strcpy(LocalPath, VirtualPath); - return OS_FS_SUCCESS; + return path_translate((char *) VirtualPath, LocalPath); } /* diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.c b/src/components/implementation/no_interface/cFE_booter/osfilesys.c index 20d339ec07..01888f7533 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.c +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.c @@ -1,141 +1,42 @@ #include "osfilesys.h" +#include "tar.h" struct fs filesystems[MAX_NUM_FS]; -struct fs *openfs; +struct fs *openfs = &filesystems[0];; struct fsobj files[MAX_NUM_FILES]; struct cos_compinfo *ci; -os_dirent_t directories[MAX_NUM_DIRENT]; + +struct fd fd_tbl[OS_MAX_NUM_OPEN_FILES + 1]; +char copy_buffer[F_PART_DATA_SIZE]; + /* * Notes on this version: + * It provides all of the functionality required by the cFE and more. It does + * not fully satisfy all of the requirements for posix in general. It passes all + * of cFE's unit tests, and all of the testing and debugging I have thrown at it * - * This version is a functional filesystem which complies to how NASA's - * cFE OSAL API uses a subset of the POSIX files and filesystem API + * Beware when using struct dirent and struct stat. As a temporary measure, + * they are currently generated to comply with glibc rather than musl. * - * Currently it does not support a file being opened concurrently - * by two processes, and fails an assertion if it is attempted + * Future plans: + * - Compile cFE with musl and fix stat and dirent structures + * - modularize into a bare bones filesystem library + * - Refactor rest of code into posix compatible filesystem built on bare bones fs * - * The posix abstraction inode, filedes, dir streams (dirp), and - * dir entries (dirent) are not implemented independently of each other. - * For now filedes is an offset into record of files (DIR and FILE) where fsobj - * stores all of the information related to all of the above abstractions - * For this version we do not need more layers of abstractions. We will need to - * implement them in order to have a posix compatibility layer or concurrency - */ - -// ultimate order of sections -// FS level -// fsobj -// f_part -// dirent -// tar level - -/****************************************************************************** -** Tar Level Methods -******************************************************************************/ - -/* - * Loads the position in memory of linked tar file system - * Checks for badly linked or no linked tar file. The names given by - * the linker are non-intuitive so a description of error checking is given: - * First checks to make sure that symbols have been overwritten by linking - * process. Next checks that the size is greater than 0. Finally checks that - * the end of the tar is after the start - */ -uint32 tar_load() -{ - if (!_binary_cFEfs_tar_start) - return OS_FS_ERR_DRIVE_NOT_CREATED; - if (! &_binary_cFEfs_tar_size) - return OS_FS_ERR_DRIVE_NOT_CREATED; - if (&_binary_cFEfs_tar_end < &_binary_cFEfs_tar_start) - return OS_FS_ERR_DRIVE_NOT_CREATED; - size = (size_t) &_binary_cFEfs_tar_size; - start = &_binary_cFEfs_tar_start; - end = &_binary_cFEfs_tar_end; - return OS_FS_SUCCESS; -} - -/* - * parses a loaded tar into filesystems[0] - * precondition: tar has been loaded by tar_load, a filesystem has been initialized - * with newfs with the devname of tar - * Postcondition: A proper error code is returned OR the tar is represented in memory - * at filesystems 0 - */ -uint32 tar_parse() -{ - assert(start && end); - assert(size < INT32_MAX); - assert(end - start > 0); - assert(size == (size_t) (end - start)); - openfs = &filesystems[0]; - uint32 offset = 0; - struct fsobj *o; - - while (offset + start < end) { - if (newfile_get(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; - - //tar ends after two empty records - if ( !(offset + start)[0] && !(offset + start)[TAR_BLOCKSIZE]) { - o->filedes = 0; - return OS_FS_SUCCESS; - } - - if (tar_cphdr(offset, o)) return OS_FS_ERR_DRIVE_NOT_CREATED; - if (file_insert(o, offset + start)) return OS_FS_ERR_DRIVE_NOT_CREATED; - - /* - * data is aligned to 512 byte blocks. a header is 500 bytes, and - * the file's data begins exactly after the header - * therefor the next header is 500 + o->size rounded up to a mult of 512 - */ - offset += round_to_blocksize(o->size + 500); - } - - //tar ends before two empty records are found - return OS_FS_ERROR; -} - -/* - * Copies information from a tar file header to a fsobj */ -uint32 tar_cphdr(uint32 tar_offset, struct fsobj *file) -{ - assert(tar_offset < size); - assert(file->filedes > 0); - struct f_part *part; - newpart_get(&part); - part->memtype = STATIC; - char *location = start; - location += tar_offset; - memmove(location + 1, location, strlen(location)); - location[0] = '/'; - file->name = path_to_name(location); - if (*(location + strlen(location) - 1) == '/') { - file->type = FSOBJ_DIR; - file->size = 0; - } - else{ - file->type = FSOBJ_FILE; - file->size = oct_to_dec(location + 124); - file->file_part = part; - file->file_part->data = location + 500; - } - return OS_FS_SUCCESS; -} /****************************************************************************** ** fsobj Level Methods ******************************************************************************/ -int32 chk_fd(int32 filedes) +int32 chk_fd(int32 FD) { - if (filedes > OS_MAX_NUM_OPEN_FILES)return OS_FS_ERR_INVALID_FD; - if (filedes == 0) return OS_FS_ERR_INVALID_FD; - - struct fsobj *o = &files[filedes - 1]; + if (FD > OS_MAX_NUM_OPEN_FILES) return OS_FS_ERR_INVALID_FD; + if (FD <= 0) return OS_FS_ERR_INVALID_FD; - if (o->filedes != filedes) return OS_FS_ERR_INVALID_FD; + struct fd *filedes = &fd_tbl[FD]; + if (!filedes->file) return OS_FS_ERR_INVALID_FD; + if (filedes->ino != filedes->file->ino) return OS_FS_ERR_INVALID_FD; return OS_FS_SUCCESS; } @@ -143,17 +44,16 @@ int32 chk_fd(int32 filedes) uint32 newfile_get(struct fsobj **o) { uint32 count = 0; - while (count < MAX_NUM_FILES && files[count].filedes) { + while (count < MAX_NUM_FILES && files[count].ino) { count++; } if (count == MAX_NUM_FILES) return OS_FS_ERROR; *o = &files[count]; **o = (struct fsobj) { - //filedes needs to be unique and nonzero, so filedes is defined as index+1 - .filedes = count +1 + //ino needs to be unique and nonzero, so ino is defined as index+1 + .ino = count +1 }; - return OS_FS_SUCCESS; } @@ -166,76 +66,195 @@ uint32 file_insert(struct fsobj *o, char *path) assert(o && path && openfs); if (!openfs->root) { + if (strcmp(o->name, path) != 0) return OS_FS_ERR_PATH_INVALID; openfs->root = o; return OS_FS_SUCCESS; } - assert(openfs->root && openfs->root->filedes); - if (openfs->root == o) return OS_FS_SUCCESS; + assert(openfs->root->ino); + struct fsobj *cur = openfs->root; + + // token is the current directory in path + char path_temp[OS_MAX_PATH_LEN * 2]; + strcpy(path_temp, path); + const char delim[2] = "/"; + char *token = strtok(path_temp, delim); + + if (strcmp(token, cur->name) != 0) return OS_FS_ERR_PATH_INVALID; + //loop terminates when it finds a place to put o or determines path is invalid - struct fsobj *root = openfs->root; - assert(root->name); - //loop terminates when it finds a place to put o, either at the end of a - //list of children or as the first in an empty children list while (1) { + if (token == NULL) { + return OS_FS_ERR_PATH_INVALID; + } + assert(cur->name); + //if there is no child, then insert as child - if (!root->child) { - o->parent = root; - root->child = o; + if (!cur->child) { + // if the next part of the path is not o->name or there is a part after it, bad path + token = strtok(NULL, delim); + if (strcmp(token, o->name) != 0 || strtok(NULL, delim) != NULL) { + return OS_FS_ERR_PATH_INVALID; + } + + o->parent = cur; + cur->child = o; o->next = NULL; o->prev = NULL; return OS_FS_SUCCESS; } - root = root->child; - - // move pointer until it is at start of next file/dir name - while (path[0]!= '/'){ - path++; - } - path++; - - //precondition: root is the first in a non-empty list of children - //postcondition: root is an ancestor of o or o has been inserted in list - // while root is not ancester of o - while (strspn(path, root->name) < strlen(root->name)) { - if (root->next == NULL) { - root->next = o; - o->prev = root; - o->parent = root->parent; + cur = cur->child; + token = strtok(NULL, delim); + + //precondition: cur is the first in a non-empty list of children + //postcondition: cur is an ancestor of o or o has been inserted in list + // while cur is not ancestor of o + while (strcmp(token, cur->name) != 0) { + if (cur->next == NULL) { + // if the next part of the path is o->name or there is a part after it, bad path + if (strcmp(token, o->name) != 0 || strtok(NULL, delim) != NULL) { + return OS_FS_ERR_PATH_INVALID; + } + // insert o as the last child in a linked list of children + cur->next = o; + o->prev = cur; + o->parent = cur->parent; o->next = NULL; return OS_FS_SUCCESS; } - root = root->next; + cur = cur->next; } - } PANIC("Unreachable Statement"); return 0; } -int32 file_open(char *path) +int32 file_open(char *path, permission_t permission) { assert(openfs); - assert(openfs->root); + if (!openfs->root) return OS_FS_ERR_PATH_TOO_LONG; + if (!path) return OS_FS_ERR_INVALID_POINTER; + + // find the file struct fsobj *file = file_find(path); - if (!file) return OS_FS_ERROR; - assert(1 > file->refcnt); // we do not yet support concurrent file access + if (!file) return OS_FS_ERR_PATH_INVALID; + if (file->type != FSOBJ_FILE) return OS_FS_ERROR; + + // get a new fd + int32 FD = newfd_get(file->ino); + if (FD == OS_FS_ERROR) { + return OS_FS_ERR_NO_FREE_FDS; + } + + struct fd *filedes = &fd_tbl[FD]; + + filedes->access = permission; + filedes->file = file; + filedes->position.file_pos.open_part = file->file_part; + filedes->position.file_pos.file_offset = 0; + filedes->position.file_pos.part_offset = 0; file->refcnt++; - file->position.open_part = file->file_part; - file->position.addr = file->position.open_part->data; - file->position.file_offset = 0; - file->position.part_offset = 0; - return file->filedes; + return FD; } -int32 file_close(int32 filedes) +int32 file_close(int32 FD) { - int32 ret = chk_fd(filedes); - if (ret != OS_FS_SUCCESS) return ret; + int32 ret = chk_fd(FD); + if (ret != OS_FS_SUCCESS) return OS_FS_ERROR; + + struct fd *filedes = &fd_tbl[FD]; + if (filedes->ino == 0) return OS_FS_ERROR; - uint32 index = filedes + 1; - if (files[index].refcnt < 1) return OS_FS_ERROR; + uint32 index = filedes->ino - 1; + assert(files[index].refcnt > 0); files[index].refcnt--; + filedes->ino = 0; + return OS_FS_SUCCESS; +} + +int32 file_close_by_name(char *path) +{ + struct fsobj *file = file_find(path); + int i; + + for (i = 0 ; i < OS_MAX_NUM_OPEN_FILES + 1 ; i++) { + if (fd_tbl[i].file == file){ + assert(fd_tbl[i].ino = file->ino); + file_close(i); + return OS_FS_SUCCESS; + } + } + return OS_FS_ERROR; +} + +// converts from the cFE defined permission constants to internal permission type +// unknown permissions return NONE, cFE should treat none as an error +permission_t permission_cFE_to_COS(uint32 permission) { + switch (permission) { + case OS_READ_WRITE : + return READ_WRITE; + case OS_WRITE_ONLY : + return WRITE; + case OS_READ_ONLY : + return READ; + default : + return NONE; + } + PANIC("unreachable statement"); + return 0; +} + +uint32 permission_cos_to_cFE(permission_t permission) { + switch (permission) { + case READ_WRITE : + return OS_READ_WRITE; + case WRITE : + return OS_WRITE_ONLY; + case READ : + return OS_READ_ONLY; + default : + PANIC("Invalid permission in existing file"); + } + PANIC("unreachable statement"); + return 0; +} + +// checks if a path is the right format for a path, and if it exists +int32 path_chk_exists(const char *path) +{ + int32 ret = path_chk_isvalid(path); + if (ret != OS_FS_SUCCESS) return ret; + if (file_find((char *)path) == NULL) return OS_FS_ERROR; + return 0; +} + +// checks if a path is the correct format, for example to be inserted +int32 path_chk_isvalid(const char *path) +{ + if (path == NULL) return OS_FS_ERR_INVALID_POINTER; + if (strlen(path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + if (strlen(path_to_name((char *)path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; + if (path[0] != '/') return OS_FS_ERR_PATH_INVALID; + assert(openfs); + + if (openfs->root) { + assert(openfs->root->name); + if (memcmp(openfs->root->name, path + 1, strlen(openfs->root->name))) { + return OS_FS_ERR_PATH_INVALID; + } + } + return OS_FS_SUCCESS; +} + +int32 path_translate(char *virt, char *local) +{ + if (!virt || !local) return OS_FS_ERR_INVALID_POINTER; + int32 ret = path_chk_isvalid(virt); + if (ret != OS_FS_SUCCESS) return ret; + if (!openfs->root) return OS_FS_ERR_PATH_INVALID; + ret = path_chk_exists(virt); + if (ret != OS_FS_SUCCESS) return ret; + strcpy(local, virt); return OS_FS_SUCCESS; } @@ -249,136 +268,135 @@ uint32 newpart_get(struct f_part **part) struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); ci = &defci->ci; } + *part = cos_page_bump_alloc(ci); + assert(part != NULL); (*part)->next = NULL; (*part)->prev = NULL; (*part)->file = NULL; - (*part)->data = (char *) part + sizeof(part); + (*part)->data = (char *) *part + sizeof(struct f_part); return OS_FS_SUCCESS; } -int32 file_read(int32 filedes, void *buffer, uint32 nbytes) +int32 file_read(int32 FD, void *buffer, uint32 nbytes) { if (!buffer) return OS_FS_ERR_INVALID_POINTER; - int32 ret = chk_fd(filedes); + int32 ret = chk_fd(FD); if (ret != OS_FS_SUCCESS) return ret; - struct fsobj *o = &files[filedes - 1]; - struct f_part *part = o->position.open_part; + struct fd *filedes = &fd_tbl[FD]; + struct fsobj *o = filedes->file; + if (o->type != FSOBJ_FILE) return OS_FS_ERR_INVALID_FD; + struct file_position *position = &filedes->position.file_pos; + struct f_part *part = position->open_part; if (o->refcnt < 1) return OS_FS_ERROR; if (o->type == FSOBJ_DIR) return OS_FS_ERROR; // nbytes > number of bytes left in file, only number left are read - if (nbytes > o->size - o->position.file_offset) { - nbytes = o->size - o->position.file_offset; + if (nbytes > o->size - position->file_offset) { + nbytes = o->size - position->file_offset; } if (nbytes == 0) return 0; uint32 bytes_to_read = nbytes; - if (o->file_part->memtype == DYNAMIC){ + if (o->memtype == DYNAMIC){ uint32 read_size; //the length of a continuous segment to be read from while (1) { - read_size = F_PART_DATA_SIZE - o->position.file_offset; - part = o->position.open_part; + read_size = F_PART_DATA_SIZE - position->file_offset; + part = position->open_part; + assert(part); if (bytes_to_read > read_size) { - memcpy(buffer, &part->data[o->position.part_offset], read_size); + memcpy(buffer, &part->data[position->part_offset], read_size); buffer += read_size; bytes_to_read -= read_size; - o->position.file_offset += read_size; + position->file_offset += read_size; if (!part->next) { - o->position.part_offset = F_PART_DATA_SIZE; + position->part_offset = F_PART_DATA_SIZE; return nbytes - bytes_to_read; } - o->position.open_part = part->next; - o->position.part_offset = 0; - o->position.addr = part->data; + position->open_part = part->next; + position->part_offset = 0; } else if (bytes_to_read == read_size) { - memcpy(buffer, &part->data[o->position.part_offset], read_size); - - o->position.file_offset += read_size; - o->position.addr += read_size; - + memcpy(buffer, &part->data[position->part_offset], read_size); + position->file_offset += read_size; if (!part->next) { - o->position.part_offset = F_PART_DATA_SIZE; + position->part_offset = F_PART_DATA_SIZE; return nbytes; } - o->position.open_part = part->next; - o->position.part_offset = 0; + position->open_part = part->next; + position->part_offset = 0; return nbytes; // bytes_to_read < the continuous space left on f_part } else { - memcpy(buffer, &part->data[o->position.part_offset], bytes_to_read); - o->position.part_offset += bytes_to_read; - o->position.file_offset += bytes_to_read; - o->position.addr += bytes_to_read; - return OS_FS_SUCCESS; + memcpy(buffer, position->open_part->data + position->part_offset, bytes_to_read); + position->part_offset += bytes_to_read; + position->file_offset += bytes_to_read; + return nbytes; } } - } else { - memcpy(buffer, &part->data[o->position.file_offset], bytes_to_read); - o->position.part_offset += bytes_to_read; - o->position.file_offset += bytes_to_read; - o->position.addr += bytes_to_read; + } else if (o->memtype == STATIC) { + memcpy(buffer, &part->data[position->file_offset], bytes_to_read); + position->part_offset += bytes_to_read; + position->file_offset += bytes_to_read; return nbytes; + } else { + PANIC("Memtype is neither static nor dynamic"); } PANIC("Unreachable Statement"); return 0; } -int32 file_write(int32 filedes, void *buffer, uint32 nbytes) +int32 file_write(int32 FD, void *buffer, uint32 nbytes) { if (!buffer) return OS_FS_ERR_INVALID_POINTER; - int32 ret = chk_fd(filedes); + int32 ret = chk_fd(FD); if (ret != OS_FS_SUCCESS) return ret; - struct fsobj *o = &files[filedes - 1]; + struct fd *filedes = &fd_tbl[FD]; + struct fsobj *o = filedes->file; + struct file_position *position = &filedes->position.file_pos; - if (o->filedes != filedes) return OS_FS_ERR_INVALID_FD; if (o->refcnt < 1) return OS_FS_ERROR; - if (o->file_part->memtype == STATIC)return OS_FS_ERROR; + if (o->memtype == STATIC) return OS_FS_ERROR; if (o->type == FSOBJ_DIR) return OS_FS_ERROR; if (nbytes == 0) return 0; uint32 bytes_to_write = nbytes; - uint32 bytes_remaining = F_PART_DATA_SIZE - o->position.part_offset; + uint32 bytes_remaining = F_PART_DATA_SIZE - position->part_offset; //while there are enough bytes to be written to fill a f_part while (bytes_to_write > bytes_remaining) { - memcpy(o->position.addr, buffer, bytes_remaining); - o->position.file_offset += bytes_remaining; + memcpy(position->open_part->data + position->part_offset, buffer, bytes_remaining); + position->file_offset += bytes_remaining; buffer += bytes_remaining; bytes_to_write -= bytes_remaining; - o->position.part_offset = 0; - if (o->position.open_part->next == NULL) { + position->part_offset = 0; + if (position->open_part->next == NULL) { struct f_part *part; newpart_get(&part); - part->memtype = DYNAMIC; part->file = o; part->next = NULL; - part->prev = o->position.open_part; - o->position.open_part->next = part; + part->prev = position->open_part; + position->open_part->next = part; } - o->position.open_part = o->position.open_part->next; - o->position.addr = o->position.open_part->data; - bytes_remaining = F_PART_DATA_SIZE - o->position.part_offset; + position->open_part = position->open_part->next; + bytes_remaining = F_PART_DATA_SIZE - position->part_offset; } - //bytes_to_write < bytes_remaining - memcpy(o->position.addr, buffer, bytes_to_write); - o->position.addr += bytes_to_write; - o->position.part_offset += bytes_to_write; - o->position.file_offset += bytes_to_write; - if (o->size < o->position.file_offset) { - o->size = o->position.file_offset; + memcpy(position->open_part->data, buffer, bytes_to_write); + position->part_offset += bytes_to_write; + position->file_offset += bytes_to_write; + if (o->size < position->file_offset) { + o->size = position->file_offset; } return nbytes; } @@ -390,54 +408,57 @@ struct fsobj *file_find(char *path) if (path[0] != '/') return NULL; path++; + // token is the current directory in path + char path_temp[OS_MAX_PATH_LEN * 2]; + strcpy(path_temp, path); + const char delim[2] = "/"; + char *token = strtok(path_temp, delim); + if(!openfs || !openfs->root) return NULL; - struct fsobj *root = openfs->root; - assert(root && root->name); - if (strlen(root->name) > strlen(path)) return NULL; + struct fsobj *cur = openfs->root; + assert(cur && cur->name); + if (strcmp(token, cur->name) != 0) return NULL; while (1) { - - // iterate through linked list of children - while (strspn(path, root->name) < strlen(root->name)) { - if (!strcmp(root->name, path)) return root; - if (!root->next) return NULL; - root = root->next; - } - - //root must now be parent of final location - if (!strcmp(root->name, path)) return root; - // The entirety of root's name should be the initial substring of path - assert(strspn(path, root->name) == strlen(root->name)); - if (!root->child) return NULL; - - root = root->child; - while (path[0] != '/') { - path++; + // iterate through linked list of children until ancestor is found + while (strcmp(token, cur->name) != 0) { + if (!cur->next) return NULL; + cur = cur->next; } - path++; - + token = strtok(NULL, delim); + if (token == NULL) return cur; + if (!cur->child) return NULL; + cur = cur->child; } PANIC("Unreachable Statement"); return NULL; } -int32 file_create(char *path) +int32 file_create(char *path, permission_t permission) { assert(path); + struct fsobj *o; - if (newfile_get(&o) != OS_FS_SUCCESS) return OS_FS_ERR_DRIVE_NOT_CREATED; - o->name = (char *) path; + if (newfile_get(&o) != OS_FS_SUCCESS) return OS_FS_ERROR; + + o->name = path_to_name(path); o->type = FSOBJ_FILE; o->size = 0; + o->permission = permission; + struct f_part *part; newpart_get(&part); - part->memtype = DYNAMIC; + assert(part); + + o->memtype = DYNAMIC; o->file_part = part; part->file = o; - part->data = (char *) part + sizeof(part); - if (file_insert(o, (char *) path)) return OS_FS_ERR_DRIVE_NOT_CREATED; - - return OS_FS_SUCCESS; + part->data = (char *) part + sizeof(struct f_part); + if (file_insert(o, path) != OS_FS_SUCCESS){ + o->ino = 0; + return OS_FS_ERR_PATH_INVALID; + } + return file_open(path, permission); } int32 file_remove(char *path) @@ -452,18 +473,19 @@ int32 file_rename(char *old_filename, char *new_filename) { struct fsobj *file = file_find(old_filename); if (!file) return OS_FS_ERR_PATH_INVALID; - file->name = path_to_name((char *)new_filename); + file->name = path_to_name(new_filename); return OS_FS_SUCCESS; } -// This is not a full implementation of all that is required by posix -// but it is enough to pass UT and is all the info relevant to this FS -int32 file_stat(char *path, os_fstat_t *filestats) +// This is part of but not a full posix implementation +// also because we are compiling with musl in cos and glibc in cFE +// I needed to introduce a struct that has the data layout of cFE's stat struct +int32 file_stat(char *path, struct hack_stat *filestats) { struct fsobj *file = file_find(path); if (!file) return OS_FS_ERROR; filestats->st_dev = 0; - filestats->st_ino = file->filedes; + filestats->st_ino = file->ino; if (file->type == FSOBJ_FILE) { filestats->st_mode = S_IFREG; } @@ -475,12 +497,15 @@ int32 file_stat(char *path, os_fstat_t *filestats) return OS_FS_SUCCESS; } -int32 file_lseek(int32 filedes, int32 offset, uint32 whence) +int32 file_lseek(int32 FD, int32 offset, uint32 whence) { - int32 ret = chk_fd(filedes); + int32 ret = chk_fd(FD); if (ret != OS_FS_SUCCESS) return ret; - struct fsobj *o = &files[filedes - 1]; + struct fd *filedes = &fd_tbl[FD]; + struct fsobj *o = filedes->file; + struct file_position *position = &filedes->position.file_pos; + uint32 target_offset = 0; // wasnt sure if it should be legal to pass negative offset, went with yes @@ -489,87 +514,81 @@ int32 file_lseek(int32 filedes, int32 offset, uint32 whence) target_offset = offset; } else if (whence == SEEK_CUR) { - if (offset + (int32) o->position.file_offset < 0) return OS_FS_ERROR; - target_offset += o->position.file_offset; + if (offset + (int32) position->file_offset < 0) return OS_FS_ERROR; + target_offset = offset + position->file_offset; } else if (whence == SEEK_END) { - if (offset + (int32) o->position.file_offset < 0) return OS_FS_ERROR; - target_offset += o->size; + if (offset + (int32) position->file_offset < 0) return OS_FS_ERROR; + target_offset = offset + o->size; } else { return OS_FS_ERROR; } // you cannot write past the end of a static file - if ( target_offset > o->size && o->file_part->memtype == STATIC) { + if ( target_offset > o->size && o->memtype == STATIC) { return OS_FS_ERROR; } - o->position.open_part = o->file_part; - o->position.file_offset = 0; + position->open_part = o->file_part; + position->file_offset = 0; - while ( target_offset - o->position.file_offset > F_PART_DATA_SIZE) { + while ( target_offset - position->file_offset > F_PART_DATA_SIZE) { // seeking past the end of a file writes zeros until that position - if (o->position.open_part->next == NULL) { + if (position->open_part->next == NULL) { struct f_part *part; newpart_get(&part); - part->memtype = DYNAMIC; part->file = o; part->next = NULL; - part->prev = o->position.open_part; - o->position.open_part->next = part; + part->prev = position->open_part; + position->open_part->next = part; } - o->position.open_part = o->position.open_part->next; - o->position.file_offset += F_PART_DATA_SIZE; + position->open_part = position->open_part->next; + position->file_offset += F_PART_DATA_SIZE; } - o->position.file_offset += target_offset % F_PART_DATA_SIZE; - o->position.part_offset = target_offset % F_PART_DATA_SIZE; - o->position.addr = o->position.open_part->data + target_offset % F_PART_DATA_SIZE; + position->file_offset += target_offset % F_PART_DATA_SIZE; + position->part_offset = target_offset % F_PART_DATA_SIZE; - if (o->position.file_offset > size) { - size = o->position.file_offset; + if (position->file_offset > o->size) { + o->size = position->file_offset; } - assert(o->position.file_offset == target_offset); + assert(position->file_offset == target_offset); return target_offset; } int32 file_cp(char *src, char *dest) { - struct fsobj *file_src, *file_dest; - int32 src_desc = file_open(src); - if (src_desc <= 0 || src_desc > MAX_NUM_FILES) return OS_FS_ERROR; - file_src = &files[src_desc - 1]; - - newfile_get(&file_dest); - - if(!file_src || file_src->type == FSOBJ_DIR){ - return OS_FS_ERR_INVALID_POINTER; - } + int32 fd_src = file_open(src, READ); + if (chk_fd(fd_src) != OS_FS_SUCCESS) return fd_src; - file_insert(file_dest, (char *) dest); - file_dest->name = path_to_name( (char *) dest); - file_dest->size = 0; - file_dest->mode = file_src->mode; - file_dest->type = FSOBJ_FILE; + int32 fd_dest = file_create(dest, fd_tbl[fd_src].file->permission); + if (chk_fd(fd_dest) != OS_FS_SUCCESS) return fd_dest; - /* - * this is not optimal for large files being moved, however - * I don't expect that to be a concern on this kind of system - */ + int32 to_copy = fd_tbl[fd_src].file->size; + int32 read_size = 0, write_size = 0; - uint32 dest_desc = file_dest->filedes; + // TODO: copy buffer is aggressively not thread safe, take a lock + while(to_copy > 0) { + if (to_copy > (int32) F_PART_DATA_SIZE) { + read_size = F_PART_DATA_SIZE; + } else { + read_size = to_copy; + } + read_size = file_read(fd_src, copy_buffer, read_size); + write_size = file_write(fd_dest, copy_buffer, read_size); + if (read_size == 0 || write_size != read_size) return OS_FS_ERROR; + to_copy -= write_size; + } - char temp_buff[file_src->size]; - file_read(src_desc, temp_buff, file_src->size); - file_write(file_dest->filedes, temp_buff, file_src->size); + file_close(fd_src); + file_close(fd_dest); return OS_FS_SUCCESS; } int32 file_mv(char *src, char *dest) { - struct fsobj *file; - uint32 desc = file_open(src); - if (desc <= 0 || desc > MAX_NUM_FILES) return OS_FS_ERROR; - file = &files[desc - 1]; + struct fsobj *file = file_find(src); + + if (!file) return OS_FS_ERROR; if (file->next) { file->next->prev = file->prev; @@ -581,23 +600,28 @@ int32 file_mv(char *src, char *dest) file->parent->child = file->next; } - file_insert(file, (char *) dest); - file->name = path_to_name((char *) dest); + file->name = path_to_name(dest); + file_insert(file, dest); + file = file_find(dest); return OS_FS_SUCCESS; } /* - * currently conflates name and path. + * currently returns name and in path field * perhaps it would be a good idea to track path in fsobj + * but it looks like cFE uses this only to check is fd is valid */ -int32 file_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) +int32 file_FDGetInfo(int32 FD, OS_FDTableEntry *fd_prop) { - struct fsobj *o = &files[filedes - 1]; - if (o->filedes != filedes) return OS_FS_ERR_INVALID_FD; - if (o->refcnt > 0) return OS_FS_ERROR; - fd_prop->OSfd = o->filedes; - memcpy(&fd_prop->Path,o->name, strlen(o->name)); + int32 ret = chk_fd(FD); + if (ret != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_FD; + + struct fd *filedes = &fd_tbl[FD]; + if (filedes->ino == 0) return OS_FS_ERR_INVALID_FD; + + fd_prop->OSfd = FD; + memcpy(&fd_prop->Path, filedes->file->name, strlen(filedes->file->name)); fd_prop->User = 0; fd_prop->IsValid = 1; return OS_FS_SUCCESS; @@ -608,113 +632,133 @@ int32 file_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) ** Dirent Level Methods ******************************************************************************/ -//provides an unused dirent. Internally, dirents are considered unused when d_ino == 0 -uint32 newdirent_get(os_dirent_t **dir) +// Internally, FDs are considered unused when ino == 0 +int32 newfd_get(int32 ino) { - /* - * there could be a problem here if two threads request dirents - * and the first does not set d_ino before the second is given the same dirent - */ - uint32 count = 0; - while (count < MAX_NUM_DIRENT && directories[count].d_ino != 0) { + uint32 count = 1; + struct fd *filedes; + + while (count <= OS_MAX_NUM_OPEN_FILES + 1 && fd_tbl[count].ino != 0) { count++; } - if (count == MAX_NUM_DIRENT) return OS_FS_ERROR; - *dir = &directories[count]; - return OS_FS_SUCCESS; + if (count == OS_MAX_NUM_OPEN_FILES + 1) return OS_FS_ERROR; + + filedes = &fd_tbl[count]; + filedes->ino = ino; + filedes->access = NONE; + return count; } -os_dirent_t *dir_open(char *path) +int32 dir_open(char *path) { - os_dirent_t *dir; struct fsobj *file; - file = file_find(path); - if (!file) return NULL; - if (file->filedes == 0) return NULL; + if (!file) return 0; + if (file->ino == 0) return 0; + if (file->type != FSOBJ_DIR) return 0; + + int32 FD = newfd_get(file->ino); + if (FD > OS_MAX_NUM_OPEN_FILES + 1 || FD <= 0) return 0; + file->refcnt++; - newdirent_get(&dir); - if (!dir) return NULL; - assert(dir->d_ino == 0 && strlen(dir->d_name) == 0); + struct fd *filedes = &fd_tbl[FD]; + filedes->access = READ; + filedes->file = file; - dir->d_ino = file->filedes; - dir->d_name[0] = 0; - return dir; + struct dir_position *position = &filedes->position.dir_pos; + position->open_dir = file; + position->cur = file; + position->status = NORMAL; + + return FD; } -uint32 dir_close(os_dirent_t *dir) +uint32 dir_close(int32 FD) { - dir->d_name[0] = 0; - dir->d_ino = 0; + if (FD > OS_MAX_NUM_OPEN_FILES + 1 || FD <= 0) return OS_FS_ERROR; + struct fd *filedes = &fd_tbl[FD]; + + filedes->ino = 0; return OS_FS_SUCCESS; } -void dir_rewind(os_dirent_t *dir) +void dir_rewind(int32 FD) { - if (!dir) return; - if (dir->d_ino == 0) return; + if (FD > OS_MAX_NUM_OPEN_FILES + 1 || FD <= 0) return; + struct fd *filedes = &fd_tbl[FD]; - // in this implementation, ino is just filedes/files offset - struct fsobj *file = &files[dir->d_ino - 1]; - if ((uint32)file->filedes != dir->d_ino) return; - while(file->prev != NULL) { - file = file->prev; - } - dir->d_ino = file->filedes; - strcpy(dir->d_name, file->name); + if (filedes->ino == 0) return; + if (filedes->file->type != FSOBJ_DIR) return; + + // cur == open_dir indicates that stream is in initial position, prior to first read + filedes->position.dir_pos.cur = filedes->position.dir_pos.open_dir; + filedes->position.dir_pos.status = NORMAL; } -os_dirent_t *dir_read(os_dirent_t *dir) +os_dirent_t *dir_read(int32 FD) { - if (!dir) return NULL; - if (dir->d_ino == 0) return NULL; + if (FD > OS_MAX_NUM_OPEN_FILES + 1 || FD <= 0) return NULL; + struct fd *filedes = &fd_tbl[FD]; + + if (filedes->ino == 0) return NULL; + if (filedes->file->type != FSOBJ_DIR) return NULL; + + struct hack_dirent *dir = &filedes->position.dir_pos.dirent; + + switch (filedes->position.dir_pos.status) { + case NORMAL : + break; - // A dir stream ends with '.' and '..' names. - if (dir->d_name[0] == '.') { - if (dir->d_name[1] == '.') { + case END_OF_STREAM : return NULL; - } - strcpy(dir->d_name, ".."); - return dir; - } - struct fsobj *file = &files[dir->d_ino]; - if (dir->d_name[0] == 0) { - strcpy(dir->d_name, file->name); - return dir; + case PARENT_DIR_LINK : + filedes->position.dir_pos.cur = NULL; + filedes->position.dir_pos.status = END_OF_STREAM; + return NULL; + + case CUR_DIR_LINK : + strcpy(dir->d_name, ".."); + dir->d_ino = 0; + filedes->position.dir_pos.status = PARENT_DIR_LINK; + return (os_dirent_t *)dir; } - if (file->next != NULL) { - file = file->next; - dir->d_ino = file->filedes; - strcpy(dir->d_name, file->name); + if (filedes->position.dir_pos.cur == filedes->position.dir_pos.open_dir) { + filedes->position.dir_pos.cur = filedes->position.dir_pos.open_dir->child; + } else { + filedes->position.dir_pos.cur = filedes->position.dir_pos.cur->next; } - else { - // last two dirs in stream are '.' and '..' + + if (!filedes->position.dir_pos.cur) { + filedes->position.dir_pos.status = CUR_DIR_LINK; strcpy(dir->d_name, "."); + dir->d_ino = 0; + } else { + strcpy(dir->d_name, filedes->position.dir_pos.cur->name); + dir->d_ino = filedes->position.dir_pos.cur->ino; } - return dir; + + return (os_dirent_t *) dir; } -// I am really conflicted about this name. I want consistency and dislike redundancy -int32 dir_mkdir(char *path) +int32 file_mkdir(char *path) { assert(path); struct fsobj *o; if (newfile_get(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; - o->name = path_to_name((char *) path); + o->name = path_to_name(path); o->type = FSOBJ_DIR; o->next = NULL; o->prev = NULL; o->parent = NULL; o->child = NULL; o->size = 0; - if (file_insert(o, (char *) path) != OS_FS_SUCCESS) return OS_FS_ERR_PATH_INVALID; + if (file_insert(o, path) != OS_FS_SUCCESS) return OS_FS_ERR_PATH_INVALID; return OS_FS_SUCCESS; } -// same naming question as above -int32 dir_rmdir(char *path) +int32 file_rmdir(char *path) { assert(path); struct fsobj *root = file_find(path); @@ -743,6 +787,48 @@ int32 dir_rmdir(char *path) return OS_FS_SUCCESS; } +int32 file_rm(struct fsobj *o) +{ + // I think I should keep a file from being deleted if it is open, rather than closing it + //file_close_by_ino(o->ino); + assert(o && o->child == NULL); + // if o is first in list of children, update parent link to it + if (o->prev == NULL && o->parent) { + assert(o->parent->child == o); + // if next = null this still works + o->parent->child = o->next; + } + + // update link from prev still work if next or prev = null + if (o->prev) { + assert(o->prev->next == o); + o->prev->next = o->next; + } + // update link from next + if (o->next) { + assert(o->next->prev == o); + o->next->prev = o->prev; + } + // there should now be no links within the fs to o + // we do not do deallocate file data but we do reuse fsobj + *o = (struct fsobj) { + .name = NULL + }; + + return OS_FS_SUCCESS; +} + +// close all of the open FDs associated with file +int32 file_close_by_ino(int32 ino) +{ + int i; + for(i = 1 ; i <= OS_MAX_NUM_OPEN_FILES ; i++) { + if(fd_tbl[i].ino == ino) { + file_close(i); + } + } + return OS_FS_SUCCESS; +} /****************************************************************************** ** fs Level Methods @@ -754,14 +840,18 @@ uint32 fs_mount(char *devname, char *mountpoint) uint32 i; for (i=0 ; i < MAX_NUM_FS && filesystems[i].devname != NULL ; i++) { if (!strcmp(filesystems[i].devname, devname)) { - + // This is a bad hack that I have not found a solution to + // basically mount should fail if already mounted + // but to load tar I need to pre-mount the first filesystem + if (strcmp(mountpoint, "/ram") && filesystems[i].root) return OS_FS_ERROR; struct fsobj *o; if (newfile_get(&o)) return OS_FS_ERROR; - filesystems[i].mountpoint = mountpoint; + filesystems[i].mountpoint = mountpoint; openfs = &filesystems[i]; if (!filesystems[i].root) { - dir_mkdir(mountpoint); + file_mkdir(mountpoint); } + assert(strcmp(openfs->mountpoint, mountpoint) == 0); return OS_FS_SUCCESS; } } @@ -781,7 +871,7 @@ uint32 fs_unmount(char *mountpoint) { } /* - * Given a pointer to an FS, inits values and fsobj for root + * Given a pointer to an FS, initializes values and fsobj for root */ uint32 fs_init(struct fs *filesys, char *devname, char *volname, uint32 blocksize, uint32 numblocks) { @@ -818,9 +908,7 @@ uint32 newfs_init(char *devname, char *volname, uint32 blocksize, uint32 numbloc while (count < MAX_NUM_FS && filesystems[count].devname) { count++; } - if (count == MAX_NUM_FS) - return OS_FS_ERR_DRIVE_NOT_CREATED; - + if (count == MAX_NUM_FS) return OS_FS_ERR_DEVICE_NOT_FREE; ret = fs_init(&filesystems[count], devname, volname, blocksize, numblocks); if (ret !=OS_FS_SUCCESS) return ret; openfs = &filesystems[count]; @@ -864,7 +952,7 @@ int32 filesys_GetFsInfo(os_fsinfo_t *filesys_info) filesys_info->MaxFds = MAX_NUM_FILES; uint32 i, count = 0; for (i = 0 ; i < MAX_NUM_FILES ; i++) { - if (files[i].filedes == 0) count++; + if (files[i].ino == 0) count++; } filesys_info->FreeFds = count; filesys_info->MaxVolumes = MAX_NUM_FS; diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.h b/src/components/implementation/no_interface/cFE_booter/osfilesys.h index 229d934eb3..7ac8df6d65 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.h +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.h @@ -13,38 +13,70 @@ // Not to be confused with similar OSAL constants. // These are only to define size of statically allocated data -#define MAX_NUM_FS 3 +#define MAX_NUM_FS NUM_TABLE_ENTRIES #define MAX_NUM_FILES 100 #define MAX_NUM_DIRENT 10 -#define TAR_BLOCKSIZE 512 -#define INT32_MAX 0x7FFFFFF //2^31 - 1 - // a page is 4096, size of f_part is 5 values * 4 bytes -#define F_PART_DATA_SIZE (4096-4*5) +#define F_PART_DATA_SIZE (4096-sizeof(struct f_part)) -//should be overwritten by linking step in build process -__attribute__((weak)) char _binary_cFEfs_tar_size=0; -__attribute__((weak)) char _binary_cFEfs_tar_start=0; -__attribute__((weak)) char _binary_cFEfs_tar_end=0; +// currently we compile composite and cFE with different libc +// muslc for cos and whatever ubuntu32 14 use for cFE +// these have different structs so I need to implement a dirent struct in cos +// with the same layout as cFE's dirent +struct hack_dirent +{ + ino_t d_ino; + // off_t d_off; these are the 8 bytes that I am removing + unsigned short d_reclen; + unsigned char d_type; + char d_name[256]; +}; -//locations and size of tar -char *start; -char *end; -size_t size; +// for exactly the same reason as above, we need to declare a stat structure to pass +// back to the cFE that it will recoginize +struct hack_stat +{ + int64 st_dev; + uint32 padding1; // here to keep the offset consistant + int32 st_ino; + int32 st_mode; + int32 st_nlink; + int32 st_gid; + int32 st_uid; + int64 st_rdev; + uint32 padding2; // also here to keep offset consistant with cFE + int32 st_size; + int32 st_blksize; + int32 st_blocks; + int32 st_hack_atime; // st_time field are defined elsewhere + int32 st_hack_mtime; + int32 st_hack_ctime; +}; typedef enum { FSOBJ_FILE, FSOBJ_DIR, -} fsobj_type_t; +} fsobj_type; //TODO: what is the preferred naming convention for this + +typedef enum { + READ, + WRITE, + READ_WRITE, + NONE, +} permission_t; struct file_position { struct f_part *open_part; //part of file being read/written to uint32 part_offset; //offset into part's data uint32 file_offset; //position within file as a whole - char *addr; }; +typedef enum { + STATIC, + DYNAMIC, +} fpart_alloc_t; + /* * The structure of the filesystem is stored in the fsobj struct * each non-leaf dir points to its first child, which then has a pointer @@ -53,29 +85,60 @@ struct file_position { struct fsobj { char *name; - int32 filedes; // 0 for free file, positive for tracked file - fsobj_type_t type; + int32 ino; // 0 for free file + fsobj_type type; /* dir vs file, determines the type of FD position */ size_t size; - struct file_position position; - uint32 refcnt; //number of threads which have opened it - uint32 mode; + uint32 refcnt; //number of filedes which have it opened + permission_t permission; // most permissive possible status it may be opened with + fpart_alloc_t memtype; struct f_part *file_part; struct fsobj *next, *prev; struct fsobj *child, *parent; // child != NULL iff type = dir }; -typedef enum { - STATIC, - DYNAMIC, -} fpart_type; - struct f_part { struct fsobj *file; struct f_part *next, *prev; - fpart_type memtype; char *data; }; +/* + * The state of a directory stream is either iterating through list of files, + * at one of two special paths, or at the end of the stream. The two special + * paths are '.' and '..' and the occur at the end of the list of files + */ +typedef enum { + NORMAL, + CUR_DIR_LINK, + PARENT_DIR_LINK, + END_OF_STREAM, +} dir_stream_status_t; + +// offset into linked list of children +struct dir_position { + struct fsobj *open_dir; /* Stream is children of open_dir */ + struct fsobj *cur; /* refers to current (last returned) file in dir stream */ + dir_stream_status_t status; /* indicates if special file or end of stream */ + struct hack_dirent dirent; /* I really don't like storing this here. */ +}; + +/* + * The type being used must be consistent with fsobj->type + */ +union fd_position { + struct dir_position dir_pos; + struct file_position file_pos; +}; + +// Currently this filedes is used only for dir streams, and not real filedes +// TODO: Switch non-dir to table based filedes +struct fd { + int32 ino; + permission_t access; /* must be < or == permissive as file->permission */ + union fd_position position; /* the type of position is determined by file->type */ + struct fsobj *file; +}; + struct fs { char *devname; char *volname; @@ -85,44 +148,7 @@ struct fs { struct fsobj *root; }; -/****************************************************************************** -** Tar Level Methods -******************************************************************************/ - -uint32 tar_load(); - -uint32 tar_parse(); - -int32 tar_read(uint32 offset, char *buf, uint32 req_sz); - -uint32 tar_cphdr(uint32 tar_offset, struct fsobj *file); - -static inline uint32 oct_to_dec(char *oct) -{ - int32 i, base; - int32 tot; - - i = strlen(oct) - 1; - - for (base = 1, tot = 0 ; i >= 0 ; i--, base *= 8) { - char val = oct[i]; - - assert(val <= '7' && val >= '0'); - val = val - '0'; - tot = tot + (val * base); - } - - return tot; -} - -//this could be more performant bithack -static inline uint32 round_to_blocksize(uint32 offset) -{ - if (offset % TAR_BLOCKSIZE) return offset + (TAR_BLOCKSIZE - (offset % TAR_BLOCKSIZE)); - return offset; -} - -static inline char *path_to_name(char *path) +static char *path_to_name(char *path) { assert(path); uint32 path_len = strlen(path), offset; @@ -147,36 +173,11 @@ static inline char *path_to_name(char *path) /****************************************************************************** ** fsobj Level Methods ******************************************************************************/ -static inline int32 file_rm(struct fsobj *o) -{ - assert(o && o->child == NULL); - - // if o is first in list of children, update parent link to it - if (o->prev == NULL && o->parent) { - assert(o->parent->child == o); - // if next = null this still works - o->parent->child = o->next; - } - - // update link from prev still work if next or prev = null - if (o->prev) { - assert(o->prev->next == o); - o->prev->next = o->next; - } - // update link from next - if (o->next) { - assert(o->next->prev == o); - o->next->prev = o->prev; - } - // there should now be no links within the fs to o +int32 file_rm(struct fsobj *o); - // we do not do deallocate file data but we do reuse fsobj - *o = (struct fsobj) { - .name = NULL - }; +int32 file_close_by_ino(int32 ino); - return OS_FS_SUCCESS; -} +int32 file_close_by_name(char *path); uint32 newpart_get(struct f_part **part); @@ -184,17 +185,17 @@ uint32 newfile_get(struct fsobj **o); uint32 file_insert(struct fsobj *o, char *path); -int32 file_open(char *path); +int32 file_open(char *path, permission_t permission); int32 file_close(int32 filedes); -int32 file_read(int32 filedes, void *buffer, uint32 nbytes); +int32 file_read(int32 FD, void *buffer, uint32 nbytes); -int32 file_write(int32 filedes, void *buffer, uint32 nbytes); +int32 file_write(int32 FD, void *buffer, uint32 nbytes); struct fsobj *file_find(char *path); -int32 file_create(char *path); +int32 file_create(char *path, permission_t permission); int32 file_remove(char *path); @@ -204,52 +205,43 @@ int32 file_cp(char *src, char *dest); int32 file_mv(char *src, char *dest); -int32 chk_fd(int32 filedes); +int32 chk_fd(int32 FD); + +int32 file_FDGetInfo(int32 FD, OS_FDTableEntry *fd_prop); -int32 file_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop); +int32 file_stat(char *path, struct hack_stat *filestats); -int32 file_stat(char *path, os_fstat_t *filestats); +int32 file_lseek(int32 FD, int32 offset, uint32 whence); -int32 file_lseek(int32 filedes, int32 offset, uint32 whence); +permission_t permission_cFE_to_COS(uint32 permission); + +uint32 permission_COS_to_cFE(permission_t permission); /****************************************************************************** ** dirent Level Methods ******************************************************************************/ -uint32 newdirent_get(os_dirent_t **dir); +int32 newfd_get(int32 ino); -os_dirent_t *dir_open(char *path); +int32 dir_open(char *path); -uint32 dir_close(os_dirent_t *dir); +uint32 dir_close(int32 FD); -void dir_rewind(os_dirent_t *dir); +void dir_rewind(int32 FD); -os_dirent_t *dir_read(os_dirent_t *dir); +os_dirent_t *dir_read(int32 FD); -int32 dir_mkdir(char *path); +int32 file_mkdir(char *path); -int32 dir_rmdir(char *path); +int32 file_rmdir(char *path); /****************************************************************************** ** fs Level Methods ******************************************************************************/ +int32 path_chk_isvalid(const char *path); -// chk_path checks if a path is the right format for a path, and if it exits -static inline int32 chk_path(const char *path) -{ - if (path == NULL) return OS_FS_ERR_INVALID_POINTER; - if (strlen(path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; - if (path[0] != '/') return OS_FS_ERR_PATH_INVALID; - if (file_find((char *)path) == NULL) return OS_FS_ERR_PATH_INVALID; - return 0; -} +int32 path_chk_exists(const char *path); -// chk_path_new is for files that should not already be in the filesystem -static inline int32 chk_path_new(const char *path) -{ - if (path == NULL) return OS_FS_ERR_INVALID_POINTER; - if (strlen(path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; - return OS_FS_SUCCESS; -} +int32 path_translate(char *virt, char *local); uint32 fs_mount(char *devname, char *mountpoint); diff --git a/src/components/implementation/no_interface/cFE_booter/tar.c b/src/components/implementation/no_interface/cFE_booter/tar.c new file mode 100644 index 0000000000..ea342d243f --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/tar.c @@ -0,0 +1,128 @@ +#include "osfilesys.h" +#include "tar.h" +#include + +//should be overwritten by linking step in build process +__attribute__((weak)) char _binary_cFEfs_tar_size=0; +__attribute__((weak)) char _binary_cFEfs_tar_start=0; +__attribute__((weak)) char _binary_cFEfs_tar_end=0; + +//locations and size of tar +char *tar_start; +char *tar_end; +size_t tar_size; + +uint32 round_to_blocksize(uint32 offset) +{ + if (offset % TAR_BLOCKSIZE) return offset + (TAR_BLOCKSIZE - (offset % TAR_BLOCKSIZE)); + return offset; +} + +//used to convert filesize in oct to dec +uint32 oct_to_dec(char *oct) +{ + int32 i, base; + int32 tot; + i = strlen(oct) - 1; + for (base = 1, tot = 0 ; i >= 0 ; i--, base *= 8) { + char val = oct[i]; + assert(val <= '7' && val >= '0'); + val = val - '0'; + tot = tot + (val * base); + } + return tot; +} + + +/* + * Loads the position in memory of linked tar file system + * Checks for badly linked or no linked tar file. The names given by + * the linker are non-intuitive so a description of error checking is given: + * First checks to make sure that symbols have been overwritten by linking + * process. Next checks that the size is greater than 0. Finally checks that + * the end of the tar is after the start + */ +uint32 tar_load() +{ + if (!_binary_cFEfs_tar_start) + return OS_FS_ERR_DRIVE_NOT_CREATED; + if (! &_binary_cFEfs_tar_size) + return OS_FS_ERR_DRIVE_NOT_CREATED; + if (&_binary_cFEfs_tar_end < &_binary_cFEfs_tar_start) + return OS_FS_ERR_DRIVE_NOT_CREATED; + + tar_size = (size_t) &_binary_cFEfs_tar_size; + tar_start = &_binary_cFEfs_tar_start; + tar_end = &_binary_cFEfs_tar_end; + + return OS_FS_SUCCESS; +} + + +/* + * parses a loaded tar into whichever filesystem is mounted + * precondition: tar has been loaded by tar_load and init by newfs_init + * Postcondition: A proper error code is returned OR the tar is represented in memory + * at the currently open filesystem + */ +uint32 tar_parse() +{ + assert(tar_start && tar_end); + assert(tar_size < INT32_MAX); + assert(tar_end - tar_start > 0); + assert(tar_size == (size_t) (tar_end - tar_start)); + uint32 offset = 0; + struct fsobj *o; + + + while (offset + tar_start < tar_end) { + if (newfile_get(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + + //tar ends after two empty records + if ( !(offset + tar_start)[0] && !(offset + tar_start)[TAR_BLOCKSIZE]) { + o->ino = 0; + return OS_FS_SUCCESS; + } + if (tar_cphdr(offset, o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + if (file_insert(o, offset + tar_start)) return OS_FS_ERR_DRIVE_NOT_CREATED; + + /* + * data is aligned to 512 byte blocks. a header is 500 bytes, and + * the file's data begins exactly after the header + * therefor the next header is 500 + o->size rounded up to a mult of 512 + */ + offset += round_to_blocksize(o->size + 500); + } + //tar ends before two empty records are found + return OS_FS_ERROR; +} + +/* + * Copies information from a tar file header to a fsobj + * TODO: change name of this function and make it cast to tar hdr struct + */ +uint32 tar_cphdr(uint32 tar_offset, struct fsobj *file) +{ + assert(tar_offset < tar_size); + assert(file->ino > 0); + struct f_part *part; + newpart_get(&part); + file->memtype = STATIC; + char *location = tar_start; + location += tar_offset; + memmove(location + 1, location, strlen(location)); + location[0] = '/'; + file->name = path_to_name(location); + if (*(location + strlen(location) - 1) == '/') { + file->type = FSOBJ_DIR; + file->size = 0; + } + else{ + file->type = FSOBJ_FILE; + file->size = oct_to_dec(location + 124); + file->file_part = part; + file->file_part->data = location + 500; + } + return OS_FS_SUCCESS; +} + diff --git a/src/components/implementation/no_interface/cFE_booter/tar.h b/src/components/implementation/no_interface/cFE_booter/tar.h new file mode 100644 index 0000000000..656b40824e --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/tar.h @@ -0,0 +1,13 @@ +#define TAR_BLOCKSIZE 512 +#define INT32_MAX 0x7FFFFFF //2^31 - 1 + +uint32 round_to_blocksize(uint32 offset); + +uint32 oct_to_dec(char *oct); + +uint32 tar_load(); + +uint32 tar_parse(); + +uint32 tar_cphdr(uint32 tar_offset, struct fsobj *file); + From 437088d035c3ac741095118a4dad2df1ea887cfd Mon Sep 17 00:00:00 2001 From: Joseph Espy Date: Mon, 7 Aug 2017 23:57:45 -0400 Subject: [PATCH 072/122] Update name of tar function to read header Old name of tar_cphdr was incorrect as there was no copying. New name tar_hdr_read describes what the function does --- .../no_interface/cFE_booter/tar.c | 4 +-- .../no_interface/cFE_booter/tar.h | 25 +++++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/tar.c b/src/components/implementation/no_interface/cFE_booter/tar.c index ea342d243f..9c9e63cd32 100644 --- a/src/components/implementation/no_interface/cFE_booter/tar.c +++ b/src/components/implementation/no_interface/cFE_booter/tar.c @@ -83,7 +83,7 @@ uint32 tar_parse() o->ino = 0; return OS_FS_SUCCESS; } - if (tar_cphdr(offset, o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + if (tar_hdr_read(offset, o)) return OS_FS_ERR_DRIVE_NOT_CREATED; if (file_insert(o, offset + tar_start)) return OS_FS_ERR_DRIVE_NOT_CREATED; /* @@ -101,7 +101,7 @@ uint32 tar_parse() * Copies information from a tar file header to a fsobj * TODO: change name of this function and make it cast to tar hdr struct */ -uint32 tar_cphdr(uint32 tar_offset, struct fsobj *file) +uint32 tar_hdr_read(uint32 tar_offset, struct fsobj *file) { assert(tar_offset < tar_size); assert(file->ino > 0); diff --git a/src/components/implementation/no_interface/cFE_booter/tar.h b/src/components/implementation/no_interface/cFE_booter/tar.h index 656b40824e..feb08d1929 100644 --- a/src/components/implementation/no_interface/cFE_booter/tar.h +++ b/src/components/implementation/no_interface/cFE_booter/tar.h @@ -1,6 +1,28 @@ #define TAR_BLOCKSIZE 512 #define INT32_MAX 0x7FFFFFF //2^31 - 1 +// from GNU +struct posix_header +{ /* byte offset */ + char name[100]; /* 0 */ + char mode[8]; /* 100 */ + char uid[8]; /* 108 */ + char gid[8]; /* 116 */ + char size[12]; /* 124 */ + char mtime[12]; /* 136 */ + char chksum[8]; /* 148 */ + char typeflag; /* 156 */ + char linkname[100]; /* 157 */ + char magic[6]; /* 257 */ + char version[2]; /* 263 */ + char uname[32]; /* 265 */ + char gname[32]; /* 297 */ + char devmajor[8]; /* 329 */ + char devminor[8]; /* 337 */ + char prefix[155]; /* 345 */ + /* 500 */ +}; + uint32 round_to_blocksize(uint32 offset); uint32 oct_to_dec(char *oct); @@ -9,5 +31,4 @@ uint32 tar_load(); uint32 tar_parse(); -uint32 tar_cphdr(uint32 tar_offset, struct fsobj *file); - +uint32 tar_hdr_read(uint32 tar_offset, struct fsobj *file); From f330c268c349400de2c63c647b24bdca6f6fee42 Mon Sep 17 00:00:00 2001 From: Zach Day Date: Tue, 15 Aug 2017 02:07:50 -0400 Subject: [PATCH 073/122] Store undefined symbols in `ST_user_caps` Utilizing the new `name` field in the `cobj_symb` structure, the linker now stores references to undefined symbols in the `ST_user_caps` array, which itself is now inserted into the object as a kernel export. Furthermore, the linker now also outputs the memory image of the `cobj` header during the image output step and writes it seperately to a file ending in `.co`. The `pong` interface and `ping` implementation have been pulled out of the `archive` directory for the purpose of testing this. Likewise, additional logging information has been added to `micro_booter`. Finally, there are a few helper comments labeled `TODO:ZD` in the `llbooter` component in order to help guide the next step of the dynamic loader implementation, which is mapping the object into memory. --- .../no_interface/cFE_booter/osapi.c | 6 +++ .../no_interface/llbooter/boot_deps.h | 4 ++ .../no_interface/llbooter/llbooter.c | 36 +++++++++----- .../implementation/no_interface/ping/Makefile | 9 ++++ .../implementation/no_interface/ping/ping.c | 48 +++++++++++++++++++ .../tests/micro_booter/Makefile | 2 +- .../tests/micro_booter/micro_booter.c | 39 +++++++++++++++ src/components/include/cobj_format.h | 16 ++++--- .../cos_asm_server_stub_simple_stack.h | 2 + src/components/interface/pong/Makefile | 5 ++ src/components/interface/pong/pong.h | 6 +++ src/components/interface/pong/stubs/c_stub.c | 38 +++++++++++++++ src/components/interface/pong/stubs/s_stub.S | 13 +++++ src/components/lib/cobj_format.c | 3 +- src/platform/linker/cl_globals.h | 1 + src/platform/linker/cl_inline.h | 1 + src/platform/linker/gen_client_stub.c | 7 ++- src/platform/linker/globals.c | 6 ++- src/platform/linker/loadall.c | 30 +++++++----- src/platform/linker/output.c | 25 +++++++++- src/platform/linker/prepsymbs.c | 1 + 21 files changed, 260 insertions(+), 38 deletions(-) create mode 100644 src/components/implementation/no_interface/ping/Makefile create mode 100644 src/components/implementation/no_interface/ping/ping.c create mode 100644 src/components/interface/pong/Makefile create mode 100644 src/components/interface/pong/pong.h create mode 100644 src/components/interface/pong/stubs/c_stub.c create mode 100644 src/components/interface/pong/stubs/s_stub.S diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index dc68320676..218ff829b6 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -430,3 +430,9 @@ void OS_ApplicationExit(int32 Status) { PANIC("Application exit invoked!"); } + +/* TODO: Linker test, delete me. */ +void call_inv(void) { } + +/* TODO: Linker test, delete me. */ +void call(void) { } diff --git a/src/components/implementation/no_interface/llbooter/boot_deps.h b/src/components/implementation/no_interface/llbooter/boot_deps.h index a0ab5402b4..43065cebe8 100644 --- a/src/components/implementation/no_interface/llbooter/boot_deps.h +++ b/src/components/implementation/no_interface/llbooter/boot_deps.h @@ -36,6 +36,8 @@ boot_deps_map_sect(int spdid, vaddr_t dest_daddr) vaddr_t addr = (vaddr_t) cos_page_bump_alloc(&boot_info); assert(addr); + /* TODO:ZD cos_mem_alias_at with our current boot-info rather than the new component */ + /* Set compinfo pointer to point at boot_info */ if (cos_mem_alias_at(new_comp_cap_info[spdid].compinfo, dest_daddr, &boot_info, addr)) BUG(); return addr; @@ -71,6 +73,7 @@ boot_compinfo_init(int spdid, captblcap_t *ct, pgtblcap_t *pt, u32_t vaddr) assert(*pt); new_comp_cap_info[spdid].compinfo = &new_compinfo[spdid]; + /* TODO:ZD new_comp_cap_info: metadata structure for this specific component */ cos_compinfo_init(new_comp_cap_info[spdid].compinfo, *pt, *ct, 0, (vaddr_t)vaddr, 4, &boot_info); } @@ -107,6 +110,7 @@ boot_newcomp_create(int spdid, struct cos_compinfo *comp_info) static void boot_bootcomp_init(void) { + /* TODO:ZD Create memory for component and create "component" */ cos_meminfo_init(&boot_info.mi, BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); cos_compinfo_init(&boot_info, BOOT_CAPTBL_SELF_PT, BOOT_CAPTBL_SELF_CT, BOOT_CAPTBL_SELF_COMP, diff --git a/src/components/implementation/no_interface/llbooter/llbooter.c b/src/components/implementation/no_interface/llbooter/llbooter.c index d6eddb42c3..8b439c33e0 100644 --- a/src/components/implementation/no_interface/llbooter/llbooter.c +++ b/src/components/implementation/no_interface/llbooter/llbooter.c @@ -38,7 +38,7 @@ boot_find_cobjs(struct cobj_header *h, int n) tot += cobj_sect_size(h, j); } printc("cobj %s:%d found at %p:%x, size %x -> %x\n", - h->name, h->id, hs[i-1], size, tot, cobj_sect_get(hs[i-1], 0)->vaddr); + h->name, h->id, hs[i-1], size, tot, cobj_sect_get(hs[i-1], 0)->vaddr); end = start + round_up_to_cacheline(size); hs[i] = h = (struct cobj_header*)end; @@ -47,7 +47,7 @@ boot_find_cobjs(struct cobj_header *h, int n) hs[n] = NULL; printc("cobj %s:%d found at %p -> %x\n", - hs[n-1]->name, hs[n-1]->id, hs[n-1], cobj_sect_get(hs[n-1], 0)->vaddr); + hs[n-1]->name, hs[n-1]->id, hs[n-1], cobj_sect_get(hs[n-1], 0)->vaddr); } static int @@ -110,19 +110,32 @@ boot_spd_end(struct cobj_header *h) int boot_spd_symbs(struct cobj_header *h, spdid_t spdid, vaddr_t *comp_info) { - int i = 0; + unsigned int i; - for (i = 0 ; i < (int)h->nsymb ; i++) { + printc("cobj: getting spd symbs for header %s, nsymbs %d.\n", h->name, h->nsymb); + for (i = 0 ; i < h->nsymb ; i++) { struct cobj_symb *symb; symb = cobj_symb_get(h, i); assert(symb); - if (COBJ_SYMB_UNDEF == symb->type) break; + + if (symb->type == COBJ_SYMB_UNDEF) { + printc("cobj: undefined symbol %s: nsymb %d, usercap offset %d\n", symb->name, i, symb->user_caps_offset); + continue; + } else if (symb->type == COBJ_SYMB_EXPORTED) { + printc("cobj: exported symbol %s: nsymb %d, addr %x\n", symb->name, i, symb->vaddr); + continue; + } switch (symb->type) { case COBJ_SYMB_COMP_INFO: + printc("cobj: comp info %s: addr %x\n", symb->name, symb->vaddr); *comp_info = symb->vaddr; break; + case COBJ_SYMB_COMP_PLT: + /* Otherwise known as ST_user_caps. */ + printc("cobj: capability array %s: addr %x\n", symb->name, symb->vaddr); + break; default: printc("boot: Unknown symbol type %d\n", symb->type); break; @@ -183,19 +196,19 @@ boot_comp_map_populate(struct cobj_header *h, spdid_t spdid, vaddr_t comp_info, char *lsrc, *dsrc; int left, dest_doff; - sect = cobj_sect_get(h, i); + sect = cobj_sect_get(h, i); /* virtual address in the destination address space */ dest_daddr = sect->vaddr; /* where we're copying from in the cobj */ - lsrc = cobj_sect_contents(h, i); + lsrc = cobj_sect_contents(h, i); /* how much is left to copy? */ - left = cobj_sect_size(h, i); + left = cobj_sect_size(h, i); /* Initialize memory. */ if (!(sect->flags & COBJ_SECT_KMEM) && - (first_time || !(sect->flags & COBJ_SECT_INITONCE))) { + (first_time || !(sect->flags & COBJ_SECT_INITONCE))) { if (sect->flags & COBJ_SECT_ZEROS) { - memset(start_addr + (dest_daddr - init_daddr), 0, left); + memset(start_addr + (dest_daddr - init_daddr), 0, left); } else { memcpy(start_addr + (dest_daddr - init_daddr), lsrc, left); } @@ -218,6 +231,7 @@ boot_comp_map_populate(struct cobj_header *h, spdid_t spdid, vaddr_t comp_info, int boot_comp_map(struct cobj_header *h, spdid_t spdid, vaddr_t comp_info, pgtblcap_t pt) { + /* Allocating memory and mapping it to the booter's address space */ boot_comp_map_memory(h, spdid, pt); boot_comp_map_populate(h, spdid, comp_info, 1); return 0; @@ -285,7 +299,7 @@ cos_init(void) h = (struct cobj_header *)cos_comp_info.cos_poly[0]; num_cobj = (int)cos_comp_info.cos_poly[1]; - deps = (struct deps *)cos_comp_info.cos_poly[2]; + deps = (struct deps *)cos_comp_info.cos_poly[2]; boot_init_ndeps(); init_args = (struct component_init_str *)cos_comp_info.cos_poly[3]; diff --git a/src/components/implementation/no_interface/ping/Makefile b/src/components/implementation/no_interface/ping/Makefile new file mode 100644 index 0000000000..8a51059f42 --- /dev/null +++ b/src/components/implementation/no_interface/ping/Makefile @@ -0,0 +1,9 @@ +C_OBJS=ping.o +ASM_OBJS= +COMPONENT=pingp.o +INTERFACES= +DEPENDENCIES=pong +IF_LIB= + +include ../../Makefile.subsubdir +MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/ping/ping.c b/src/components/implementation/no_interface/ping/ping.c new file mode 100644 index 0000000000..6a2ec6da8d --- /dev/null +++ b/src/components/implementation/no_interface/ping/ping.c @@ -0,0 +1,48 @@ +#include +#include + +#include + +#define ITER (1024) +u64_t meas[ITER]; + +void cos_init(void) +{ + u64_t start, end, avg, tot = 0, dev = 0; + int i, j; + + call(); /* get stack */ + printc("cpu %ld, thd %d from ping\n",cos_cpuid(), cos_get_thd_id()); + printc("Starting %d Invocations.\n", ITER); + + for (i = 0 ; i < ITER ; i++) { + rdtscll(start); +// cos_send_ipi(i, 0, 0, 0); + call(); + rdtscll(end); + meas[i] = end-start; + } + + for (i = 0 ; i < ITER ; i++) tot += meas[i]; + avg = tot/ITER; + printc("avg %lld\n", avg); + for (tot = 0, i = 0, j = 0 ; i < ITER ; i++) { + if (meas[i] < avg*2) { + tot += meas[i]; + j++; + } + } + printc("avg w/o %d outliers %lld\n", ITER-j, tot/j); + + for (i = 0 ; i < ITER ; i++) { + u64_t diff = (meas[i] > avg) ? + meas[i] - avg : + avg - meas[i]; + dev += (diff*diff); + } + dev /= ITER; + printc("deviation^2 = %lld\n", dev); + +// printc("%d invocations took %lld\n", ITER, end-start); + return; +} diff --git a/src/components/implementation/tests/micro_booter/Makefile b/src/components/implementation/tests/micro_booter/Makefile index b09f79e464..a143223a1a 100644 --- a/src/components/implementation/tests/micro_booter/Makefile +++ b/src/components/implementation/tests/micro_booter/Makefile @@ -1,7 +1,7 @@ C_OBJS=micro_booter.o mb_tests.o ASM_OBJS=cos_asm_scheduler.o inv.o COMPONENT=micro_boot.o -INTERFACES= +INTERFACES=pong DEPENDENCIES= IF_LIB= ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api diff --git a/src/components/implementation/tests/micro_booter/micro_booter.c b/src/components/implementation/tests/micro_booter/micro_booter.c index 5025424e9e..4b203ab3dd 100644 --- a/src/components/implementation/tests/micro_booter/micro_booter.c +++ b/src/components/implementation/tests/micro_booter/micro_booter.c @@ -4,8 +4,12 @@ struct cos_compinfo booter_info; thdcap_t termthd; /* switch to this to shutdown */ unsigned long tls_test[TEST_NTHDS]; +struct cobj_header *h; + #include +void call(void) { } + /* For Div-by-zero test */ int num = 1, den = 0; @@ -13,6 +17,38 @@ void term_fn(void *d) { SPIN(); } +void +print_symbs(void) +{ + unsigned int i; + + for (i = 0 ; i < h->nsymb ; i++) { + struct cobj_symb *symb; + + symb = cobj_symb_get(h, i); + assert(symb); + + switch (symb->type) { + case COBJ_SYMB_COMP_INFO: + printc("cobj: comp info %s: addr %x\n", symb->name, symb->vaddr); + break; + case COBJ_SYMB_COMP_PLT: + /* Otherwise known as ST_user_caps. */ + printc("cobj: capability array %s: addr %x\n", symb->name, symb->vaddr); + break; + case COBJ_SYMB_EXPORTED: + printc("cobj: exported symbol %s: nsymb %d, addr %x\n", symb->name, i, symb->vaddr); + break; + case COBJ_SYMB_UNDEF: + printc("cobj: undefined symbol %s: nsymb %d, usercap offset %d\n", symb->name, i, symb->user_caps_offset); + break; + default: + printc("boot: Unknown symbol type %d\n", symb->type); + break; + } + } +} + void cos_init(void) { @@ -25,6 +61,9 @@ cos_init(void) termthd = cos_thd_alloc(&booter_info, booter_info.comp_cap, term_fn, NULL); assert(termthd); + h = (struct cobj_header *)cos_comp_info.cos_poly[0]; + print_symbs(); + cycs = cos_hw_cycles_per_usec(BOOT_CAPTBL_SELF_INITHW_BASE); printc("\t%d cycles per microsecond\n", cycs); diff --git a/src/components/include/cobj_format.h b/src/components/include/cobj_format.h index fabd9f2655..63d650dd60 100644 --- a/src/components/include/cobj_format.h +++ b/src/components/include/cobj_format.h @@ -64,16 +64,18 @@ struct cobj_sect { } __attribute__((packed)); enum { - COBJ_SYMB_UNDEF = 0, + COBJ_SYMB_UNDEF = 0, COBJ_SYMB_COMP_INFO, - COBJ_SYMB_EXPORTED + COBJ_SYMB_EXPORTED, + COBJ_SYMB_COMP_PLT }; struct cobj_symb { - /* TODO: this is a big ol' waste of space */ - char name[64]; - u32_t type; - u32_t vaddr; + /* TODO: this is a big ol' waste of space */ + char name[64]; + u32_t type; + u32_t vaddr; + u32_t user_caps_offset; } __attribute__((packed)); struct cobj_cap { @@ -90,7 +92,7 @@ struct cobj_header *cobj_create(u32_t id, char *name, u32_t nsect, char *space, unsigned int sz, u32_t flags); int cobj_sect_init(struct cobj_header *h, unsigned int sect_idx, u32_t flags, u32_t vaddr, u32_t size); -int cobj_symb_init(struct cobj_header *h, unsigned int symb_idx, const char *name, u32_t type, u32_t vaddr); +int cobj_symb_init(struct cobj_header *h, unsigned int symb_idx, const char *name, u32_t type, u32_t vaddr, u32_t user_caps_offset); int cobj_cap_init(struct cobj_header *h, unsigned int cap_idx, u32_t cap_off, u32_t dest_id, u32_t sfn, u32_t cstub, u32_t sstub, u32_t fault_num); diff --git a/src/components/include/cos_asm_server_stub_simple_stack.h b/src/components/include/cos_asm_server_stub_simple_stack.h index e8ae14ea62..a100e4d05a 100644 --- a/src/components/include/cos_asm_server_stub_simple_stack.h +++ b/src/components/include/cos_asm_server_stub_simple_stack.h @@ -9,7 +9,9 @@ #ifndef COS_ASM_SERVER_STUB_SIMPLE_STACK_H #define COS_ASM_SERVER_STUB_SIMPLE_STACK_H +#define __ASM__ #include "../../kernel/include/asm_ipc_defs.h" +#include #include diff --git a/src/components/interface/pong/Makefile b/src/components/interface/pong/Makefile new file mode 100644 index 0000000000..f55b30401e --- /dev/null +++ b/src/components/interface/pong/Makefile @@ -0,0 +1,5 @@ +LIB_OBJS= +LIBS=$(LIB_OBJS:%.o=%.a) +ASM_STUBS=s_stubpg.o + +include ../Makefile.subdir diff --git a/src/components/interface/pong/pong.h b/src/components/interface/pong/pong.h new file mode 100644 index 0000000000..71f42709ae --- /dev/null +++ b/src/components/interface/pong/pong.h @@ -0,0 +1,6 @@ +#ifndef PONG_H +#define PONG_H + +void call(void); + +#endif /* !PONG_H */ diff --git a/src/components/interface/pong/stubs/c_stub.c b/src/components/interface/pong/stubs/c_stub.c new file mode 100644 index 0000000000..88b28f1011 --- /dev/null +++ b/src/components/interface/pong/stubs/c_stub.c @@ -0,0 +1,38 @@ +#include + +#include + +__attribute__((regparm(1))) void call_call(struct usr_inv_cap *uc) +{ + int ret, fault = 0; + + /* + * cap# -> eax + * sp -> ebp + * 1st arg -> ebx + * 2nd arg -> esi + * 3rd arg -> edi + * 4th arg -> edx + */ + __asm__ __volatile__( + "pushl %%ebp\n\t" + "movl %%esp, %%ebp\n\t" + "movl $1f, %%ecx\n\t" + "sysenter\n\t" + ".align 8\n\t" + "jmp 2f\n\t" + ".align 8\n\t" + "1:\n\t" + "popl %%ebp\n\t" + "movl $0, %%ecx\n\t" + "jmp 3f\n\t" + "2:\n\t" + "popl %%ebp\n\t" + "movl $1, %%ecx\n\t" + "3:" + : "=a" (ret), "=c" (fault) + : "a" (uc->cap_no) + : "ebx", "edx", "esi", "edi", "memory", "cc"); + + return; +} diff --git a/src/components/interface/pong/stubs/s_stub.S b/src/components/interface/pong/stubs/s_stub.S new file mode 100644 index 0000000000..5649c1136b --- /dev/null +++ b/src/components/interface/pong/stubs/s_stub.S @@ -0,0 +1,13 @@ +/** + * Copyright 2009 by Gabriel Parmer, gabep1@cs.bu.edu + * + * Redistribution of this file is permitted under the GNU General + * Public License v2. + */ + +//#include +#include + +.text + +cos_asm_server_stub(call) diff --git a/src/components/lib/cobj_format.c b/src/components/lib/cobj_format.c index 27e9b72572..eb84f56a43 100644 --- a/src/components/lib/cobj_format.c +++ b/src/components/lib/cobj_format.c @@ -193,7 +193,7 @@ cobj_sect_init(struct cobj_header *h, unsigned int sect_idx, u32_t flags, u32_t } int -cobj_symb_init(struct cobj_header *h, unsigned int symb_idx, const char *name, u32_t type, u32_t vaddr) +cobj_symb_init(struct cobj_header *h, unsigned int symb_idx, const char *name, u32_t type, u32_t vaddr, u32_t user_caps_offset) { struct cobj_symb *s; @@ -202,6 +202,7 @@ cobj_symb_init(struct cobj_header *h, unsigned int symb_idx, const char *name, u strcpy(s->name, name); s->type = type; s->vaddr = vaddr; + s->user_caps_offset = user_caps_offset; return 0; } diff --git a/src/platform/linker/cl_globals.h b/src/platform/linker/cl_globals.h index 33b000af32..415bbffc4b 100644 --- a/src/platform/linker/cl_globals.h +++ b/src/platform/linker/cl_globals.h @@ -29,6 +29,7 @@ extern enum {PRINT_NONE = 0, PRINT_HIGH, PRINT_NORMAL, PRINT_DEBUG} print_lvl; extern const char *COMP_INFO; +extern const char *COMP_PLT; extern const char *SCHED_NOTIF; extern const char *INIT_COMP; extern char *ROOT_SCHED; diff --git a/src/platform/linker/cl_inline.h b/src/platform/linker/cl_inline.h index 728d330d41..31d926c0d0 100644 --- a/src/platform/linker/cl_inline.h +++ b/src/platform/linker/cl_inline.h @@ -6,6 +6,7 @@ #include #include #include +#include static inline int is_booter_loaded(struct service_symbs *s) diff --git a/src/platform/linker/gen_client_stub.c b/src/platform/linker/gen_client_stub.c index f16f44615f..7c10fc6fb4 100644 --- a/src/platform/linker/gen_client_stub.c +++ b/src/platform/linker/gen_client_stub.c @@ -34,9 +34,11 @@ char *fn_string = ".text\n" -".globl %s\n" ".align 16\n" -"%s:\n\t" +".globl %s\n" +"%s:\n" +".globl %s__cos_undef_%d\n" +"%s__cos_undef_%d:\n\t" /* get the cap table */ /* "movl $ST_user_caps, %%eax\n\t" */ /* "/\* eax now holds the **usr_inv_cap *\/\n\t" */ @@ -132,6 +134,7 @@ static inline void create_stanza(char *output, int len, char *fn_name, int cap_n sprintf(ucap_name, "%s"UCAP_EXT, fn_name); ret = snprintf(output, len, fn_string, fn_name, fn_name, + fn_name, cap_num, fn_name, cap_num, ucap_name/*cap_num*SIZEOFUSERCAP*/, /* INVOCATIONCNT, INVOCATIONCNT, */ /*ENTRYFN,*/ INVFN); if (ret == len) { diff --git a/src/platform/linker/globals.c b/src/platform/linker/globals.c index 2471ddd467..09842e6af3 100644 --- a/src/platform/linker/globals.c +++ b/src/platform/linker/globals.c @@ -11,9 +11,10 @@ #include "cl_types.h" #include "cl_macros.h" -enum {PRINT_NONE = 0, PRINT_HIGH, PRINT_NORMAL, PRINT_DEBUG} print_lvl = PRINT_HIGH; +enum {PRINT_NONE = 0, PRINT_HIGH, PRINT_NORMAL, PRINT_DEBUG} print_lvl = PRINT_DEBUG; const char *COMP_INFO = "cos_comp_info"; +const char *COMP_PLT = "ST_user_caps"; const char *SCHED_NOTIF = "cos_sched_notifications"; const char *INIT_COMP = "c0.o"; char *ROOT_SCHED = NULL; // this is set to the first listed scheduler (*) @@ -53,7 +54,8 @@ cos_flt_handlers[COS_FLT_MAX] = { "fault_gen_prot_handler", "fault_linux_handler", "fault_save_regs_handler", - "fault_flt_notif_handler" + "fault_flt_notif_handler", + "fault_flt_quarantine", }; struct cos_sections section_info[MAXSEC_S+1] = { diff --git a/src/platform/linker/loadall.c b/src/platform/linker/loadall.c index cce5c23c1d..6e3dc44c77 100644 --- a/src/platform/linker/loadall.c +++ b/src/platform/linker/loadall.c @@ -79,32 +79,36 @@ int make_cobj_symbols(struct service_symbs *s, struct cobj_header *h) const char *name; u32_t type; }; + struct name_type_map map[] = { {.name = COMP_INFO, .type = COBJ_SYMB_COMP_INFO}, + {.name = COMP_PLT, .type = COBJ_SYMB_COMP_PLT}, {.name = NULL, .type = 0} }; - /* Create the sumbols */ + /* Create the symbols */ printl(PRINT_DEBUG, "%s loaded by Composite\n", s->obj); printl(PRINT_DEBUG, "\tMap symbols:\n"); for (i = 0 ; map[i].name != NULL ; i++) { addr = (u32_t)get_symb_address(&s->exported, map[i].name); - printl(PRINT_DEBUG, "\tname %s, addr %x, nsymb %d\n", map[i].name, addr, i); - if (addr && cobj_symb_init(h, symb_offset++, map[i].name, map[i].type, addr)) { - printl(PRINT_HIGH, "boot component: couldn't create cobj symb for %s (%d).\n", map[i].name, i); + printl(PRINT_DEBUG, "\tsymb %s, addr %x, nsymb %d\n", map[i].name, addr, i); + + /* ST_user_caps offset is 0 when not relevant. */ + if (addr && cobj_symb_init(h, symb_offset++, map[i].name, map[i].type, addr, 0)) { + printl(PRINT_HIGH, "boot component: couldn't create map cobj symb for %s (%d).\n", map[i].name, i); return -1; } } - /* Begin to write all symbols */ printl(PRINT_DEBUG, "\tExported symbols:\n"); - while (s) { - struct symb_type exports = s->exported; - for (i = 0; i < exports.num_symbs; i++) { - printl(PRINT_DEBUG, "\tname %s, addr %x, nsymb %d\n", exports.symbs[i].name, exports.symbs[i].addr, i); - cobj_symb_init(h, symb_offset++, exports.symbs[i].name, COBJ_SYMB_EXPORTED, i); + for (i = 0 ; i < s->exported.num_symbs ; i++) { + printl(PRINT_DEBUG, "\tsymb %s, nsymb %d\n", s->exported.symbs[i].name, i); + + /* ST_user_caps offset is 0 when not relevant. */ + if (cobj_symb_init(h, symb_offset++, s->exported.symbs[i].name, COBJ_SYMB_EXPORTED, s->exported.symbs[i].addr, 0)) { + printl(PRINT_HIGH, "boot component: couldn't create exported cobj symb for %s (%d).\n", s->exported.symbs[i].name, i); + return -1; } - s = s->next; } return 0; @@ -384,8 +388,10 @@ load_service(struct service_symbs *ret_data, unsigned long lower_addr, unsigned if (csg(i)->cobj_flags & COBJ_SECT_ZEROS) continue; size += csg(i)->len; } - nsymbs = ret_data->exported.num_symbs; + + nsymbs = ret_data->exported.num_symbs + 2; /* +2 is for COMP_INFO and COMP_PLT */ ncaps = ret_data->undef.num_symbs; + nsymbs += ncaps; /* We must track undefined symbols in addition to exports */ nsects = MAXSEC_S; obj_size = cobj_size_req(nsects, size, nsymbs, ncaps); diff --git a/src/platform/linker/output.c b/src/platform/linker/output.c index a2791ce3f8..d6761d3ffc 100644 --- a/src/platform/linker/output.c +++ b/src/platform/linker/output.c @@ -418,6 +418,12 @@ make_cobj_caps(struct service_symbs *s, struct cobj_header *h) struct symb *symb = &undef_symbs->symbs[i]; struct cap_ret_info cri; + /* + * Before creating the cobj, we add ncap to nsymb because we want to track both undefined and exports. + * In order to get the actual symbol index of the current undefined symbol, we need to undo that operation. + */ + int symbol_idx = h->nsymb - h->ncap + i; + if (cap_get_info(s, &cri, symb)) return -1; cap_off = i; @@ -433,6 +439,12 @@ make_cobj_caps(struct service_symbs *s, struct cobj_header *h) if (cobj_cap_init(h, cap_off, cap_off, dest_id, sfn, cstub, sstub, fault)) return -1; printl(PRINT_DEBUG, "capability from %s:%d to %s:%d\n", s->obj, s->cobj->id, cri.serv->obj, dest_id); + + printl(PRINT_DEBUG, "\tInserting undefined symbol %s at offset %d into user caps array.\n", cri.csymb->name, cap_off + 1); + if (cobj_symb_init(h, symbol_idx, cri.csymb->name, COBJ_SYMB_UNDEF, sfn, cap_off + 1)) { + printl(PRINT_HIGH, "Couldn't create undefined symbol %s.\n", cri.csymb->name); + return -1; + } } return 0; @@ -742,7 +754,18 @@ make_spd_llboot(struct service_symbs *boot, struct service_symbs *all) all->obj, service_get_spdid(all), heap_ptr_val, h, obj_size); memcpy(heap_ptr_val, h, h->size); *heap_ptr = (void*)(((int)heap_ptr_val) + obj_size); + + /* Output cobject file. */ + char filename[32]; + sprintf(filename, "%s.co", &all->obj[5]); + printl(PRINT_HIGH, "Outputting co to file %s\n", filename); + int co_fd = open(filename, O_WRONLY | O_CREAT); + if (write(co_fd, h, h->size) == -1) { + printl(PRINT_HIGH, "Error outputting co.\n"); + } + close(co_fd); } + all = first; *heap_ptr = (int*)(round_up_to_page((int)*heap_ptr)); ci->cos_poly[1] = (vaddr_t)n; @@ -756,8 +779,6 @@ make_spd_llboot(struct service_symbs *boot, struct service_symbs *all) boot->heap_top = (unsigned int)*heap_ptr; /* ensure that we copy all of the meta-data as well */ } - - struct service_symbs * find_obj_by_name(struct service_symbs *s, const char *n) { diff --git a/src/platform/linker/prepsymbs.c b/src/platform/linker/prepsymbs.c index cada4d4481..a8524ab62d 100644 --- a/src/platform/linker/prepsymbs.c +++ b/src/platform/linker/prepsymbs.c @@ -35,6 +35,7 @@ inline void add_kexport(struct service_symbs *ss, const char *name) void add_kernel_exports(struct service_symbs *service) { add_kexport(service, COMP_INFO); + add_kexport(service, COMP_PLT); add_kexport(service, SCHED_NOTIF); return; From bea3a917bdf1d0be7b112901fb2c57db5cfe55d3 Mon Sep 17 00:00:00 2001 From: Joseph Espy Date: Wed, 16 Aug 2017 13:58:04 -0400 Subject: [PATCH 074/122] Update to file system for musl libc and minor changes We are now compiling cFE under musl libc. This broke the temporary hack we were using to allow us to pass structs between musl libc and cFE's glibc Also I have made style changes, including comments and function names. Permissions are now implemented as bits in the permission enum, so they can use & and | notation. --- .../no_interface/cFE_booter/osfiles.c | 87 +++---- .../no_interface/cFE_booter/osfilesys.c | 241 ++++++++---------- .../no_interface/cFE_booter/osfilesys.h | 109 +++----- .../no_interface/cFE_booter/tar.c | 25 +- .../no_interface/cFE_booter/tar.h | 4 - 5 files changed, 199 insertions(+), 267 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osfiles.c b/src/components/implementation/no_interface/cFE_booter/osfiles.c index 6666c98ed9..2e8e52908b 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfiles.c +++ b/src/components/implementation/no_interface/cFE_booter/osfiles.c @@ -10,12 +10,15 @@ int32 OS_FS_Init(void) { + os_dirent_t d; + OS_printf("The length of a dirent object according to cos/musl is %d\n", sizeof(d)); + uint32 ret = 0; - ret = newfs_init("/ramdev0", "RAM", 512, 4096); - if (ret != OS_FS_SUCCESS) return ret; - ret = tar_parse(); + ret = tar_load(); + if (ret != OS_FS_SUCCESS) return ret; + ret = fs_init("/ramdev0", "RAM", 512, 4096); if (ret != OS_FS_SUCCESS) return ret; - return OS_FS_SUCCESS; + return tar_parse(); } /* @@ -23,11 +26,10 @@ int32 OS_FS_Init(void) */ int32 OS_creat(const char *path, int32 access) { - int32 ret = path_chk_isvalid(path); + int32 ret = path_isvalid(path); if (access != OS_READ_WRITE && access != OS_WRITE_ONLY) return OS_FS_ERROR; if (ret != OS_FS_SUCCESS) return ret; - ret = file_create((char *) path, access); - return ret; + return file_create((char *) path, access); } /* @@ -38,7 +40,7 @@ int32 OS_open(const char *path, int32 access, uint32 mode) if (access != OS_READ_WRITE && access != OS_WRITE_ONLY && access != OS_READ_ONLY) { return OS_FS_ERROR; } - int32 ret = path_chk_exists(path); + int32 ret = path_exists(path); if (ret != OS_FS_SUCCESS) return ret; return file_open((char *)path, access); } @@ -58,8 +60,7 @@ int32 OS_close(int32 filedes) int32 OS_read(int32 filedes, void *buffer, uint32 nbytes) { if (chk_fd(filedes) != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_FD; - int32 ret = file_read(filedes, buffer, nbytes); - return ret; + return file_read(filedes, buffer, nbytes); } /* @@ -85,9 +86,9 @@ int32 OS_chmod(const char *path, uint32 access) int32 OS_stat(const char *path, os_fstat_t *filestats) { if (!filestats || !path) return OS_FS_ERR_INVALID_POINTER; - int32 ret = path_chk_exists(path); + int32 ret = path_exists(path); if (ret != OS_FS_SUCCESS) return ret; - return file_stat((char *) path, (struct hack_stat *) filestats); + return file_stat((char *) path, filestats); } /* @@ -103,10 +104,9 @@ int32 OS_lseek(int32 filedes, int32 offset, uint32 whence) */ int32 OS_remove(const char *path) { - int32 ret = path_chk_exists(path); + int32 ret = path_exists(path); if (ret != OS_FS_SUCCESS) return ret; - ret = file_remove((char *)path); - return ret; + return file_remove((char *)path); } /* @@ -114,10 +114,12 @@ int32 OS_remove(const char *path) */ int32 OS_rename(const char *old_filename, const char *new_filename) { if (!old_filename || !new_filename) return OS_FS_ERR_INVALID_POINTER; - int32 ret = path_chk_exists(old_filename); + int32 ret = path_exists(old_filename); if (ret != OS_FS_SUCCESS) return ret; - ret = path_chk_isvalid(new_filename); + ret = path_isvalid(new_filename); if (ret != OS_FS_SUCCESS) return ret; + // if new filename already exists + if (path_exists(new_filename) == OS_SUCCESS) return OS_FS_ERR_PATH_INVALID; return file_rename((char *)old_filename, (char *)new_filename); } @@ -135,9 +137,9 @@ int32 OS_cp(const char *src, const char *dest) if (strlen(path_to_name(src_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; if (strlen(path_to_name(dest_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; - int32 ret = path_chk_exists(src_path); + int32 ret = path_exists(src_path); if (ret != OS_FS_SUCCESS) return ret; - ret = path_chk_isvalid(dest_path); + ret = path_isvalid(dest_path); if (ret != OS_FS_SUCCESS) return ret; return file_cp(src_path, dest_path); @@ -157,13 +159,12 @@ int32 OS_mv(const char *src, const char *dest) if (strlen(path_to_name(src_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; if (strlen(path_to_name(dest_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; - int32 ret = path_chk_exists(src); + int32 ret = path_exists(src); if (ret != OS_FS_SUCCESS) return ret; - ret = path_chk_isvalid(dest); + ret = path_isvalid(dest); if (ret != OS_FS_SUCCESS) return ret; - ret = file_mv(src_path, dest_path); - return ret; + return file_mv(src_path, dest_path); } /* @@ -182,7 +183,7 @@ int32 OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) */ int32 OS_FileOpenCheck(char *Filename) { - int32 ret = path_chk_exists(Filename); + int32 ret = path_exists(Filename); if (ret != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_POINTER; struct fsobj *file = file_find(Filename); @@ -198,7 +199,7 @@ int32 OS_FileOpenCheck(char *Filename) int32 OS_CloseAllFiles(void) { uint32 i; - for (i = 1 ; i < MAX_NUM_FILES + 1 ; i++) { + for (i = 1 ; i <= MAX_NUM_FILES ; i++) { OS_close(i); } return OS_FS_SUCCESS; @@ -209,7 +210,7 @@ int32 OS_CloseAllFiles(void) */ int32 OS_CloseFileByName(char *Filename) { - int32 ret = path_chk_exists(Filename); + int32 ret = path_exists(Filename); if (ret != OS_FS_SUCCESS) return ret; return file_close_by_name(Filename); } @@ -224,7 +225,7 @@ int32 OS_CloseFileByName(char *Filename) */ int32 OS_mkdir(const char *path, uint32 access) { - int32 ret = path_chk_isvalid(path); + int32 ret = path_isvalid(path); if (ret != OS_FS_SUCCESS) return ret; return file_mkdir((char *)path); } @@ -234,7 +235,7 @@ int32 OS_mkdir(const char *path, uint32 access) */ os_dirp_t OS_opendir(const char *path) { - if(path_chk_exists(path) != OS_FS_SUCCESS) return NULL; + if(path_exists(path) != OS_FS_SUCCESS) return NULL; int32 FD = dir_open((char *)path); if (FD == 0) return NULL; return (os_dirp_t) FD; @@ -254,7 +255,6 @@ int32 OS_closedir(os_dirp_t directory) */ void OS_rewinddir(os_dirp_t directory) { - if (!directory) return; dir_rewind((int32) directory); return; } @@ -265,8 +265,7 @@ void OS_rewinddir(os_dirp_t directory) os_dirent_t *OS_readdir(os_dirp_t directory) { if (!directory) return NULL; - os_dirent_t *dir = dir_read((int32) directory); - return dir; + return dir_read((int32) directory); } /* @@ -274,7 +273,7 @@ os_dirent_t *OS_readdir(os_dirp_t directory) */ int32 OS_rmdir(const char *path) { - int32 ret = path_chk_exists(path); + int32 ret = path_exists(path); if (ret != OS_FS_SUCCESS) return ret; return file_rmdir((char *)path); } @@ -292,7 +291,7 @@ int32 OS_mkfs(char *address, char *devname, char *volname, if (!devname || !volname) return OS_FS_ERR_INVALID_POINTER; if (strlen(devname) >= OS_FS_DEV_NAME_LEN || strlen(volname) >= OS_FS_VOL_NAME_LEN) return OS_FS_ERR_PATH_TOO_LONG; - return newfs_init(devname, volname, blocksize, numblocks); + return fs_init(devname, volname, blocksize, numblocks); } /* * Mounts a file system @@ -321,7 +320,7 @@ int32 OS_initfs(char *address, char *devname, char *volname, uint32 blocksize, u int32 OS_rmfs(char *devname) { if (!devname) return OS_FS_ERR_INVALID_POINTER; - return rmfs(devname); + return fs_remove(devname); } /* @@ -330,7 +329,7 @@ int32 OS_rmfs(char *devname) int32 OS_unmount(const char *mountpoint) { if (!mountpoint) return OS_FS_ERR_INVALID_POINTER; - int32 ret = path_chk_exists(mountpoint); + int32 ret = path_exists(mountpoint); if (ret != OS_FS_SUCCESS) return ret; return fs_unmount((char *)mountpoint); } @@ -340,23 +339,11 @@ int32 OS_unmount(const char *mountpoint) */ int32 OS_fsBlocksFree(const char *name) { - /* - * I am open to discussion on how we want to handle this. - * We could impose an artificial limit on the size of the filesystem - * if we expect the filesystem to be used much, that is the right choice, but - * otherwise it is not worth actually doing - */ return OS_ERR_NOT_IMPLEMENTED; } -/* -** Returns the number of free bytes in a file system -** Note the 64 bit data type to support filesystems that -** are greater than 4 Gigabytes -*/ int32 OS_fsBytesFree(const char *name, uint64 *bytes_free) { - // see comment in fsBlocksFree return OS_ERR_NOT_IMPLEMENTED; } @@ -375,9 +362,9 @@ os_fshealth_t OS_chkfs(const char *name, boolean repair) int32 OS_FS_GetPhysDriveName(char * PhysDriveName, char * MountPoint) { if (!PhysDriveName || !MountPoint) return OS_FS_ERR_INVALID_POINTER; - int32 ret = path_chk_exists(MountPoint); + int32 ret = path_exists(MountPoint); if (ret != OS_FS_SUCCESS) return ret; - return filesys_GetPhysDriveName(PhysDriveName, MountPoint); + return fs_get_drive_name(PhysDriveName, MountPoint); } /* @@ -395,7 +382,7 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) { if (!filesys_info) return OS_FS_ERR_INVALID_POINTER; - return filesys_GetFsInfo(filesys_info); + return fs_get_info(filesys_info); } /****************************************************************************** diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.c b/src/components/implementation/no_interface/cFE_booter/osfilesys.c index 01888f7533..519dd5d609 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.c +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.c @@ -2,12 +2,9 @@ #include "tar.h" struct fs filesystems[MAX_NUM_FS]; -struct fs *openfs = &filesystems[0];; +struct fs *openfs = &filesystems[0]; struct fsobj files[MAX_NUM_FILES]; -struct cos_compinfo *ci; - struct fd fd_tbl[OS_MAX_NUM_OPEN_FILES + 1]; -char copy_buffer[F_PART_DATA_SIZE]; /* * Notes on this version: @@ -29,19 +26,21 @@ char copy_buffer[F_PART_DATA_SIZE]; ** fsobj Level Methods ******************************************************************************/ +// checks if a file descriptor is valid and in use int32 chk_fd(int32 FD) { if (FD > OS_MAX_NUM_OPEN_FILES) return OS_FS_ERR_INVALID_FD; - if (FD <= 0) return OS_FS_ERR_INVALID_FD; + if (FD <= 0) return OS_FS_ERR_INVALID_FD; struct fd *filedes = &fd_tbl[FD]; if (!filedes->file) return OS_FS_ERR_INVALID_FD; - if (filedes->ino != filedes->file->ino) return OS_FS_ERR_INVALID_FD; + if (filedes->ino == 0 || filedes->file->ino == 0) return OS_FS_ERR_INVALID_FD; + assert(filedes->ino == filedes->file->ino); return OS_FS_SUCCESS; } //finds the next free file -uint32 newfile_get(struct fsobj **o) +uint32 file_get_new(struct fsobj **o) { uint32 count = 0; while (count < MAX_NUM_FILES && files[count].ino) { @@ -52,25 +51,24 @@ uint32 newfile_get(struct fsobj **o) **o = (struct fsobj) { //ino needs to be unique and nonzero, so ino is defined as index+1 - .ino = count +1 + .ino = count + 1 }; return OS_FS_SUCCESS; } uint32 file_insert(struct fsobj *o, char *path) { + assert(o && path && openfs); + //paths should always begin with '/' but we do not need it here if (path[0] != '/') return OS_FS_ERR_PATH_INVALID; path++; - assert(o && path && openfs); - if (!openfs->root) { if (strcmp(o->name, path) != 0) return OS_FS_ERR_PATH_INVALID; openfs->root = o; return OS_FS_SUCCESS; } - assert(openfs->root->ino); struct fsobj *cur = openfs->root; @@ -81,8 +79,8 @@ uint32 file_insert(struct fsobj *o, char *path) char *token = strtok(path_temp, delim); if (strcmp(token, cur->name) != 0) return OS_FS_ERR_PATH_INVALID; - //loop terminates when it finds a place to put o or determines path is invalid + //loop terminates when it finds a place to put o or determines path is invalid while (1) { if (token == NULL) { return OS_FS_ERR_PATH_INVALID; @@ -129,10 +127,27 @@ uint32 file_insert(struct fsobj *o, char *path) return 0; } -int32 file_open(char *path, permission_t permission) +// Internally, FDs are considered unused when ino == 0 +static int32 fd_get(int32 ino) +{ + uint32 count = 1; + struct fd *filedes; + + while (count <= OS_MAX_NUM_OPEN_FILES + 1 && fd_tbl[count].ino != 0) { + count++; + } + if (count == OS_MAX_NUM_OPEN_FILES + 1) return OS_FS_ERROR; + + filedes = &fd_tbl[count]; + filedes->ino = ino; + filedes->access = NONE; + return count; +} + +int32 file_open(char *path, enum fs_permissions permission) { assert(openfs); - if (!openfs->root) return OS_FS_ERR_PATH_TOO_LONG; + if (!openfs->root) return OS_FS_ERROR; if (!path) return OS_FS_ERR_INVALID_POINTER; // find the file @@ -141,7 +156,7 @@ int32 file_open(char *path, permission_t permission) if (file->type != FSOBJ_FILE) return OS_FS_ERROR; // get a new fd - int32 FD = newfd_get(file->ino); + int32 FD = fd_get(file->ino); if (FD == OS_FS_ERROR) { return OS_FS_ERR_NO_FREE_FDS; } @@ -189,10 +204,10 @@ int32 file_close_by_name(char *path) // converts from the cFE defined permission constants to internal permission type // unknown permissions return NONE, cFE should treat none as an error -permission_t permission_cFE_to_COS(uint32 permission) { +enum fs_permissions permission_cFE_to_COS(uint32 permission) { switch (permission) { case OS_READ_WRITE : - return READ_WRITE; + return READ & WRITE; case OS_WRITE_ONLY : return WRITE; case OS_READ_ONLY : @@ -204,9 +219,9 @@ permission_t permission_cFE_to_COS(uint32 permission) { return 0; } -uint32 permission_cos_to_cFE(permission_t permission) { +uint32 permission_cos_to_cFE(enum fs_permissions permission) { switch (permission) { - case READ_WRITE : + case READ & WRITE : return OS_READ_WRITE; case WRITE : return OS_WRITE_ONLY; @@ -220,16 +235,16 @@ uint32 permission_cos_to_cFE(permission_t permission) { } // checks if a path is the right format for a path, and if it exists -int32 path_chk_exists(const char *path) +int32 path_exists(const char *path) { - int32 ret = path_chk_isvalid(path); + int32 ret = path_isvalid(path); if (ret != OS_FS_SUCCESS) return ret; if (file_find((char *)path) == NULL) return OS_FS_ERROR; - return 0; + return OS_FS_SUCCESS; } // checks if a path is the correct format, for example to be inserted -int32 path_chk_isvalid(const char *path) +int32 path_isvalid(const char *path) { if (path == NULL) return OS_FS_ERR_INVALID_POINTER; if (strlen(path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; @@ -249,10 +264,10 @@ int32 path_chk_isvalid(const char *path) int32 path_translate(char *virt, char *local) { if (!virt || !local) return OS_FS_ERR_INVALID_POINTER; - int32 ret = path_chk_isvalid(virt); + int32 ret = path_isvalid(virt); if (ret != OS_FS_SUCCESS) return ret; if (!openfs->root) return OS_FS_ERR_PATH_INVALID; - ret = path_chk_exists(virt); + ret = path_exists(virt); if (ret != OS_FS_SUCCESS) return ret; strcpy(local, virt); return OS_FS_SUCCESS; @@ -262,12 +277,10 @@ int32 path_translate(char *virt, char *local) ** f_part Level Methods ******************************************************************************/ -uint32 newpart_get(struct f_part **part) +uint32 part_get_new(struct f_part **part) { - if (!ci) { - struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); - ci = &defci->ci; - } + struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); + struct cos_compinfo *ci = &defci->ci; *part = cos_page_bump_alloc(ci); @@ -288,49 +301,49 @@ int32 file_read(int32 FD, void *buffer, uint32 nbytes) struct fd *filedes = &fd_tbl[FD]; struct fsobj *o = filedes->file; + assert(o->refcnt >= 1); if (o->type != FSOBJ_FILE) return OS_FS_ERR_INVALID_FD; struct file_position *position = &filedes->position.file_pos; struct f_part *part = position->open_part; - if (o->refcnt < 1) return OS_FS_ERROR; - if (o->type == FSOBJ_DIR) return OS_FS_ERROR; // nbytes > number of bytes left in file, only number left are read if (nbytes > o->size - position->file_offset) { nbytes = o->size - position->file_offset; } - if (nbytes == 0) return 0; - uint32 bytes_to_read = nbytes; + if (nbytes == OS_FS_SUCCESS) return 0; + uint32 bytes_to_read = nbytes; if (o->memtype == DYNAMIC){ - uint32 read_size; //the length of a continuous segment to be read from while (1) { - read_size = F_PART_DATA_SIZE - position->file_offset; + //read_size is the length of a continuous segment to be read from + uint32 read_size = F_PART_DATA_SIZE - position->file_offset; part = position->open_part; assert(part); if (bytes_to_read > read_size) { memcpy(buffer, &part->data[position->part_offset], read_size); - buffer += read_size; - bytes_to_read -= read_size; - position->file_offset += read_size; + buffer += read_size; + bytes_to_read -= read_size; + position->file_offset += read_size; if (!part->next) { position->part_offset = F_PART_DATA_SIZE; return nbytes - bytes_to_read; } - position->open_part = part->next; + position->open_part = part->next; position->part_offset = 0; + } else if (bytes_to_read == read_size) { memcpy(buffer, &part->data[position->part_offset], read_size); - position->file_offset += read_size; + position->file_offset += read_size; if (!part->next) { position->part_offset = F_PART_DATA_SIZE; return nbytes; } - position->open_part = part->next; - position->part_offset = 0; + position->open_part = part->next; + position->part_offset = 0; return nbytes; // bytes_to_read < the continuous space left on f_part @@ -367,8 +380,8 @@ int32 file_write(int32 FD, void *buffer, uint32 nbytes) if (o->refcnt < 1) return OS_FS_ERROR; if (o->memtype == STATIC) return OS_FS_ERROR; if (o->type == FSOBJ_DIR) return OS_FS_ERROR; - if (nbytes == 0) return 0; + uint32 bytes_to_write = nbytes; uint32 bytes_remaining = F_PART_DATA_SIZE - position->part_offset; @@ -381,7 +394,7 @@ int32 file_write(int32 FD, void *buffer, uint32 nbytes) position->part_offset = 0; if (position->open_part->next == NULL) { struct f_part *part; - newpart_get(&part); + part_get_new(&part); part->file = o; part->next = NULL; part->prev = position->open_part; @@ -434,23 +447,21 @@ struct fsobj *file_find(char *path) return NULL; } -int32 file_create(char *path, permission_t permission) +int32 file_create(char *path, enum fs_permissions permission) { assert(path); struct fsobj *o; - if (newfile_get(&o) != OS_FS_SUCCESS) return OS_FS_ERROR; - + if (file_get_new(&o) != OS_FS_SUCCESS) return OS_FS_ERROR; o->name = path_to_name(path); o->type = FSOBJ_FILE; o->size = 0; o->permission = permission; + o->memtype = DYNAMIC; struct f_part *part; - newpart_get(&part); - assert(part); + part_get_new(&part); - o->memtype = DYNAMIC; o->file_part = part; part->file = o; part->data = (char *) part + sizeof(struct f_part); @@ -477,23 +488,26 @@ int32 file_rename(char *old_filename, char *new_filename) return OS_FS_SUCCESS; } -// This is part of but not a full posix implementation -// also because we are compiling with musl in cos and glibc in cFE -// I needed to introduce a struct that has the data layout of cFE's stat struct -int32 file_stat(char *path, struct hack_stat *filestats) +// This is part of but not a full posix implementation, +// stat has a lot of fields not applicable to us +int32 file_stat(char *path, os_fstat_t *filestats) { struct fsobj *file = file_find(path); if (!file) return OS_FS_ERROR; - filestats->st_dev = 0; - filestats->st_ino = file->ino; + *filestats = (os_fstat_t) { + .st_dev = 0, + .st_ino = file->ino, + .st_size = file->size, + .st_blksize = F_PART_DATA_SIZE + }; + if (file->type == FSOBJ_FILE) { filestats->st_mode = S_IFREG; } if (file->type == FSOBJ_DIR) { filestats->st_mode = S_IFDIR; } - filestats->st_size = file->size; - filestats->st_blksize = F_PART_DATA_SIZE; + return OS_FS_SUCCESS; } @@ -512,11 +526,9 @@ int32 file_lseek(int32 FD, int32 offset, uint32 whence) if (whence == SEEK_SET) { if (offset < 0) return OS_FS_ERROR; target_offset = offset; - } else if (whence == SEEK_CUR) { if (offset + (int32) position->file_offset < 0) return OS_FS_ERROR; target_offset = offset + position->file_offset; - } else if (whence == SEEK_END) { if (offset + (int32) position->file_offset < 0) return OS_FS_ERROR; target_offset = offset + o->size; @@ -535,7 +547,7 @@ int32 file_lseek(int32 FD, int32 offset, uint32 whence) // seeking past the end of a file writes zeros until that position if (position->open_part->next == NULL) { struct f_part *part; - newpart_get(&part); + part_get_new(&part); part->file = o; part->next = NULL; part->prev = position->open_part; @@ -550,16 +562,24 @@ int32 file_lseek(int32 FD, int32 offset, uint32 whence) if (position->file_offset > o->size) { o->size = position->file_offset; } - assert(position->file_offset == target_offset); return target_offset; } int32 file_cp(char *src, char *dest) { + static char copy_buffer[F_PART_DATA_SIZE]; + int32 fd_src = file_open(src, READ); if (chk_fd(fd_src) != OS_FS_SUCCESS) return fd_src; - int32 fd_dest = file_create(dest, fd_tbl[fd_src].file->permission); + // if the dest already exists, overwrite it + int32 fd_dest = file_open(dest, WRITE); + if (chk_fd(fd_dest) == OS_FS_SUCCESS) { + //writing size to zero effectivly deletes all the old data + fd_tbl[fd_dest].file->size = 0; + } else { + fd_dest = file_create(dest, fd_tbl[fd_src].file->permission); + } if (chk_fd(fd_dest) != OS_FS_SUCCESS) return fd_dest; int32 to_copy = fd_tbl[fd_src].file->size; @@ -601,8 +621,7 @@ int32 file_mv(char *src, char *dest) } file->name = path_to_name(dest); - file_insert(file, dest); - file = file_find(dest); + if (file_insert(file, dest) != OS_FS_SUCCESS) return OS_FS_ERROR; return OS_FS_SUCCESS; } @@ -613,7 +632,6 @@ int32 file_mv(char *src, char *dest) */ int32 file_FDGetInfo(int32 FD, OS_FDTableEntry *fd_prop) { - int32 ret = chk_fd(FD); if (ret != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_FD; @@ -632,23 +650,6 @@ int32 file_FDGetInfo(int32 FD, OS_FDTableEntry *fd_prop) ** Dirent Level Methods ******************************************************************************/ -// Internally, FDs are considered unused when ino == 0 -int32 newfd_get(int32 ino) -{ - uint32 count = 1; - struct fd *filedes; - - while (count <= OS_MAX_NUM_OPEN_FILES + 1 && fd_tbl[count].ino != 0) { - count++; - } - if (count == OS_MAX_NUM_OPEN_FILES + 1) return OS_FS_ERROR; - - filedes = &fd_tbl[count]; - filedes->ino = ino; - filedes->access = NONE; - return count; -} - int32 dir_open(char *path) { struct fsobj *file; @@ -657,7 +658,7 @@ int32 dir_open(char *path) if (file->ino == 0) return 0; if (file->type != FSOBJ_DIR) return 0; - int32 FD = newfd_get(file->ino); + int32 FD = fd_get(file->ino); if (FD > OS_MAX_NUM_OPEN_FILES + 1 || FD <= 0) return 0; file->refcnt++; @@ -684,7 +685,7 @@ uint32 dir_close(int32 FD) void dir_rewind(int32 FD) { - if (FD > OS_MAX_NUM_OPEN_FILES + 1 || FD <= 0) return; + if (FD >= OS_MAX_NUM_OPEN_FILES || FD <= 0) return; struct fd *filedes = &fd_tbl[FD]; if (filedes->ino == 0) return; @@ -703,7 +704,7 @@ os_dirent_t *dir_read(int32 FD) if (filedes->ino == 0) return NULL; if (filedes->file->type != FSOBJ_DIR) return NULL; - struct hack_dirent *dir = &filedes->position.dir_pos.dirent; + os_dirent_t *dir = &filedes->position.dir_pos.dirent; switch (filedes->position.dir_pos.status) { case NORMAL : @@ -721,7 +722,7 @@ os_dirent_t *dir_read(int32 FD) strcpy(dir->d_name, ".."); dir->d_ino = 0; filedes->position.dir_pos.status = PARENT_DIR_LINK; - return (os_dirent_t *)dir; + return dir; } if (filedes->position.dir_pos.cur == filedes->position.dir_pos.open_dir) { @@ -746,7 +747,7 @@ int32 file_mkdir(char *path) { assert(path); struct fsobj *o; - if (newfile_get(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + if (file_get_new(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; o->name = path_to_name(path); o->type = FSOBJ_DIR; o->next = NULL; @@ -789,8 +790,8 @@ int32 file_rmdir(char *path) int32 file_rm(struct fsobj *o) { - // I think I should keep a file from being deleted if it is open, rather than closing it - //file_close_by_ino(o->ino); + // TODO, pass an error back out of library if someone implicitly tries to close open file + //assert(o->refcnt == 0); assert(o && o->child == NULL); // if o is first in list of children, update parent link to it if (o->prev == NULL && o->parent) { @@ -845,9 +846,9 @@ uint32 fs_mount(char *devname, char *mountpoint) // but to load tar I need to pre-mount the first filesystem if (strcmp(mountpoint, "/ram") && filesystems[i].root) return OS_FS_ERROR; struct fsobj *o; - if (newfile_get(&o)) return OS_FS_ERROR; - filesystems[i].mountpoint = mountpoint; - openfs = &filesystems[i]; + if (file_get_new(&o)) return OS_FS_ERROR; + filesystems[i].mountpoint = mountpoint; + openfs = &filesystems[i]; if (!filesystems[i].root) { file_mkdir(mountpoint); } @@ -870,52 +871,33 @@ uint32 fs_unmount(char *mountpoint) { return OS_FS_ERROR; } -/* - * Given a pointer to an FS, initializes values and fsobj for root - */ -uint32 fs_init(struct fs *filesys, char *devname, char *volname, uint32 blocksize, uint32 numblocks) -{ - filesys->devname = devname; - filesys->volname = volname; - filesys->mountpoint = ""; - filesys->blocksize = blocksize; - filesys->numblocks = numblocks; - filesys->root = NULL; - return OS_FS_SUCCESS; -} - -uint32 newfs_init(char *devname, char *volname, uint32 blocksize, uint32 numblocks) +uint32 fs_init(char *devname, char *volname, uint32 blocksize, uint32 numblocks) { - uint32 count = 1, ret = 0; + uint32 count = 0, ret = 0; if (!devname) return OS_FS_ERR_INVALID_POINTER; if (blocksize == 0 || numblocks == 0) return OS_FS_ERROR; if (strlen(devname) >= OS_FS_DEV_NAME_LEN || strlen(volname) >= OS_FS_VOL_NAME_LEN) return OS_FS_ERROR; - - // the first filesystem is always the tar - if (!filesystems[0].devname) { - ret = tar_load(); - if (ret != OS_FS_SUCCESS) return ret; - ret = fs_init(&filesystems[0], devname, volname, blocksize, numblocks); - if (ret != OS_FS_SUCCESS) return ret; - return OS_FS_SUCCESS; - } - - // filesystem[0] is initialized during OS_FS_Init - if (strcmp(devname, filesystems[0].devname) == 0) return OS_SUCCESS; - while (count < MAX_NUM_FS && filesystems[count].devname) { count++; } if (count == MAX_NUM_FS) return OS_FS_ERR_DEVICE_NOT_FREE; - ret = fs_init(&filesystems[count], devname, volname, blocksize, numblocks); - if (ret !=OS_FS_SUCCESS) return ret; + + filesystems[count] = (struct fs) { + .devname = devname, + .volname = volname, + .mountpoint = "", + .blocksize = blocksize, + .numblocks = numblocks, + .root = NULL + }; + openfs = &filesystems[count]; return OS_FS_SUCCESS; } -int32 rmfs(char *devname) +int32 fs_remove(char *devname) { if (!devname) return OS_FS_ERR_INVALID_POINTER; @@ -935,19 +917,20 @@ int32 rmfs(char *devname) } -int32 filesys_GetPhysDriveName(char *PhysDriveName, char *MountPoint) +int32 fs_get_drive_name(char *PhysDriveName, char *MountPoint) { uint32 i; for (i = 0 ; i < MAX_NUM_FS && filesystems[i].devname != NULL ; i++) { if (filesystems[i].mountpoint && !strcmp(filesystems[i].mountpoint,MountPoint)) { - memcpy(PhysDriveName, "RAM FS\n",7); + char *new_name = "Ram FS\n"; + memcpy(PhysDriveName, new_name, strlen(new_name)); return OS_FS_SUCCESS; } } return OS_FS_ERROR; } -int32 filesys_GetFsInfo(os_fsinfo_t *filesys_info) +int32 fs_get_info(os_fsinfo_t *filesys_info) { filesys_info->MaxFds = MAX_NUM_FILES; uint32 i, count = 0; diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.h b/src/components/implementation/no_interface/cFE_booter/osfilesys.h index 7ac8df6d65..931c7d8d19 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.h +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.h @@ -1,14 +1,14 @@ #include #include -#include "gen/common_types.h" -#include "gen/osapi.h" -#include "gen/osapi-os-filesys.h" - #include #include #include +#include "gen/common_types.h" +#include "gen/osapi.h" +#include "gen/osapi-os-filesys.h" + #include "cFE_util.h" // Not to be confused with similar OSAL constants. @@ -20,51 +20,18 @@ // a page is 4096, size of f_part is 5 values * 4 bytes #define F_PART_DATA_SIZE (4096-sizeof(struct f_part)) -// currently we compile composite and cFE with different libc -// muslc for cos and whatever ubuntu32 14 use for cFE -// these have different structs so I need to implement a dirent struct in cos -// with the same layout as cFE's dirent -struct hack_dirent -{ - ino_t d_ino; - // off_t d_off; these are the 8 bytes that I am removing - unsigned short d_reclen; - unsigned char d_type; - char d_name[256]; -}; - -// for exactly the same reason as above, we need to declare a stat structure to pass -// back to the cFE that it will recoginize -struct hack_stat -{ - int64 st_dev; - uint32 padding1; // here to keep the offset consistant - int32 st_ino; - int32 st_mode; - int32 st_nlink; - int32 st_gid; - int32 st_uid; - int64 st_rdev; - uint32 padding2; // also here to keep offset consistant with cFE - int32 st_size; - int32 st_blksize; - int32 st_blocks; - int32 st_hack_atime; // st_time field are defined elsewhere - int32 st_hack_mtime; - int32 st_hack_ctime; -}; - -typedef enum { +enum fsobj_type { FSOBJ_FILE, FSOBJ_DIR, -} fsobj_type; //TODO: what is the preferred naming convention for this +}; -typedef enum { - READ, - WRITE, - READ_WRITE, - NONE, -} permission_t; +enum fs_permissions { + NONE = 0, + READ = 0x001, + WRITE = 0x010, + EXECUTE = 0x100, + ALL = READ | WRITE | EXECUTE, +}; struct file_position { struct f_part *open_part; //part of file being read/written to @@ -72,10 +39,10 @@ struct file_position { uint32 file_offset; //position within file as a whole }; -typedef enum { +enum fpart_alloc_type { STATIC, DYNAMIC, -} fpart_alloc_t; +}; /* * The structure of the filesystem is stored in the fsobj struct @@ -86,11 +53,11 @@ typedef enum { struct fsobj { char *name; int32 ino; // 0 for free file - fsobj_type type; /* dir vs file, determines the type of FD position */ + enum fsobj_type type; /* dir vs file, determines the type of FD position */ size_t size; uint32 refcnt; //number of filedes which have it opened - permission_t permission; // most permissive possible status it may be opened with - fpart_alloc_t memtype; + enum fs_permissions permission; // most permissive possible status it may be opened with + enum fpart_alloc_type memtype; struct f_part *file_part; struct fsobj *next, *prev; struct fsobj *child, *parent; // child != NULL iff type = dir @@ -107,19 +74,19 @@ struct f_part { * at one of two special paths, or at the end of the stream. The two special * paths are '.' and '..' and the occur at the end of the list of files */ -typedef enum { +enum dir_stream_status { NORMAL, CUR_DIR_LINK, PARENT_DIR_LINK, END_OF_STREAM, -} dir_stream_status_t; +}; // offset into linked list of children struct dir_position { struct fsobj *open_dir; /* Stream is children of open_dir */ struct fsobj *cur; /* refers to current (last returned) file in dir stream */ - dir_stream_status_t status; /* indicates if special file or end of stream */ - struct hack_dirent dirent; /* I really don't like storing this here. */ + enum dir_stream_status status; /* indicates if special file or end of stream */ + os_dirent_t dirent; /* I really don't like storing this here. */ }; /* @@ -134,7 +101,7 @@ union fd_position { // TODO: Switch non-dir to table based filedes struct fd { int32 ino; - permission_t access; /* must be < or == permissive as file->permission */ + enum fs_permissions access; /* must be < or == permissive as file->permission */ union fd_position position; /* the type of position is determined by file->type */ struct fsobj *file; }; @@ -179,13 +146,13 @@ int32 file_close_by_ino(int32 ino); int32 file_close_by_name(char *path); -uint32 newpart_get(struct f_part **part); +uint32 part_get_new(struct f_part **part); -uint32 newfile_get(struct fsobj **o); +uint32 file_get_new(struct fsobj **o); uint32 file_insert(struct fsobj *o, char *path); -int32 file_open(char *path, permission_t permission); +int32 file_open(char *path, enum fs_permissions permission); int32 file_close(int32 filedes); @@ -195,7 +162,7 @@ int32 file_write(int32 FD, void *buffer, uint32 nbytes); struct fsobj *file_find(char *path); -int32 file_create(char *path, permission_t permission); +int32 file_create(char *path, enum fs_permissions permission); int32 file_remove(char *path); @@ -209,18 +176,18 @@ int32 chk_fd(int32 FD); int32 file_FDGetInfo(int32 FD, OS_FDTableEntry *fd_prop); -int32 file_stat(char *path, struct hack_stat *filestats); +int32 file_stat(char *path, os_fstat_t *filestats); int32 file_lseek(int32 FD, int32 offset, uint32 whence); -permission_t permission_cFE_to_COS(uint32 permission); +enum fs_permissions permission_cFE_to_COS(uint32 permission); -uint32 permission_COS_to_cFE(permission_t permission); +uint32 permission_COS_to_cFE(enum fs_permissions permission); /****************************************************************************** ** dirent Level Methods ******************************************************************************/ -int32 newfd_get(int32 ino); +//int32 newfd_get(int32 ino); int32 dir_open(char *path); @@ -237,9 +204,9 @@ int32 file_rmdir(char *path); /****************************************************************************** ** fs Level Methods ******************************************************************************/ -int32 path_chk_isvalid(const char *path); +int32 path_isvalid(const char *path); -int32 path_chk_exists(const char *path); +int32 path_exists(const char *path); int32 path_translate(char *virt, char *local); @@ -247,12 +214,10 @@ uint32 fs_mount(char *devname, char *mountpoint); uint32 fs_unmount(char *mountpoint); -uint32 fs_init(struct fs *filesys, char *devname, char *volname, uint32 blocksize, uint32 numblocks); - -uint32 newfs_init(char *defilvname, char *volname, uint32 blocksize, uint32 numblocks); +uint32 fs_init(char *defilvname, char *volname, uint32 blocksize, uint32 numblocks); -int32 rmfs(char *devname); +int32 fs_remove(char *devname); -int32 filesys_GetPhysDriveName(char *PhysDriveName, char *MountPoint); +int32 fs_get_drive_name(char *PhysDriveName, char *MountPoint); -int32 filesys_GetFsInfo(os_fsinfo_t *finesys_info); +int32 fs_get_info(os_fsinfo_t *finesys_info); diff --git a/src/components/implementation/no_interface/cFE_booter/tar.c b/src/components/implementation/no_interface/cFE_booter/tar.c index 9c9e63cd32..3d36c8dc41 100644 --- a/src/components/implementation/no_interface/cFE_booter/tar.c +++ b/src/components/implementation/no_interface/cFE_booter/tar.c @@ -3,23 +3,23 @@ #include //should be overwritten by linking step in build process -__attribute__((weak)) char _binary_cFEfs_tar_size=0; -__attribute__((weak)) char _binary_cFEfs_tar_start=0; -__attribute__((weak)) char _binary_cFEfs_tar_end=0; +__attribute__((weak)) char _binary_cFEfs_tar_size = 0; +__attribute__((weak)) char _binary_cFEfs_tar_start = 0; +__attribute__((weak)) char _binary_cFEfs_tar_end = 0; //locations and size of tar char *tar_start; char *tar_end; size_t tar_size; -uint32 round_to_blocksize(uint32 offset) +static uint32 round_to_blocksize(uint32 offset) { if (offset % TAR_BLOCKSIZE) return offset + (TAR_BLOCKSIZE - (offset % TAR_BLOCKSIZE)); return offset; } -//used to convert filesize in oct to dec -uint32 oct_to_dec(char *oct) +//used to convert filesize in oct char string to dec, adapted from old fs code by gparmer +static uint32 oct_to_dec(char *oct) { int32 i, base; int32 tot; @@ -37,17 +37,20 @@ uint32 oct_to_dec(char *oct) /* * Loads the position in memory of linked tar file system * Checks for badly linked or no linked tar file. The names given by - * the linker are non-intuitive so a description of error checking is given: + * the linker are non-intuitive so a description of error checking is given * First checks to make sure that symbols have been overwritten by linking * process. Next checks that the size is greater than 0. Finally checks that * the end of the tar is after the start */ uint32 tar_load() { + // First make sure that symbols have been overwritten by linking process if (!_binary_cFEfs_tar_start) return OS_FS_ERR_DRIVE_NOT_CREATED; - if (! &_binary_cFEfs_tar_size) + // Next check that file size is greater than 0 + if (&_binary_cFEfs_tar_size == 0) return OS_FS_ERR_DRIVE_NOT_CREATED; + // Check that the end of the tar is after the start if (&_binary_cFEfs_tar_end < &_binary_cFEfs_tar_start) return OS_FS_ERR_DRIVE_NOT_CREATED; @@ -74,9 +77,8 @@ uint32 tar_parse() uint32 offset = 0; struct fsobj *o; - while (offset + tar_start < tar_end) { - if (newfile_get(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + if (file_get_new(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; //tar ends after two empty records if ( !(offset + tar_start)[0] && !(offset + tar_start)[TAR_BLOCKSIZE]) { @@ -99,14 +101,13 @@ uint32 tar_parse() /* * Copies information from a tar file header to a fsobj - * TODO: change name of this function and make it cast to tar hdr struct */ uint32 tar_hdr_read(uint32 tar_offset, struct fsobj *file) { assert(tar_offset < tar_size); assert(file->ino > 0); struct f_part *part; - newpart_get(&part); + part_get_new(&part); file->memtype = STATIC; char *location = tar_start; location += tar_offset; diff --git a/src/components/implementation/no_interface/cFE_booter/tar.h b/src/components/implementation/no_interface/cFE_booter/tar.h index feb08d1929..fa18590392 100644 --- a/src/components/implementation/no_interface/cFE_booter/tar.h +++ b/src/components/implementation/no_interface/cFE_booter/tar.h @@ -23,10 +23,6 @@ struct posix_header /* 500 */ }; -uint32 round_to_blocksize(uint32 offset); - -uint32 oct_to_dec(char *oct); - uint32 tar_load(); uint32 tar_parse(); From 25c5e4aa942eef1227e0cae07bd3c780753698eb Mon Sep 17 00:00:00 2001 From: Joseph Espy Date: Wed, 16 Aug 2017 15:05:18 -0400 Subject: [PATCH 075/122] Tiny style changes in cos osal cFE code. change COS to cos for style reasons, and panic if an invalid value is passed as a cFE permission_cFE_to_cos --- .../implementation/no_interface/cFE_booter/osfilesys.c | 4 ++-- src/components/implementation/no_interface/cFE_booter/tar.c | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.c b/src/components/implementation/no_interface/cFE_booter/osfilesys.c index 519dd5d609..a5e1929bfb 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.c +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.c @@ -204,7 +204,7 @@ int32 file_close_by_name(char *path) // converts from the cFE defined permission constants to internal permission type // unknown permissions return NONE, cFE should treat none as an error -enum fs_permissions permission_cFE_to_COS(uint32 permission) { +enum fs_permissions permission_cFE_to_cos(uint32 permission) { switch (permission) { case OS_READ_WRITE : return READ & WRITE; @@ -213,7 +213,7 @@ enum fs_permissions permission_cFE_to_COS(uint32 permission) { case OS_READ_ONLY : return READ; default : - return NONE; + PANIC("Invalid permission from cFE"); } PANIC("unreachable statement"); return 0; diff --git a/src/components/implementation/no_interface/cFE_booter/tar.c b/src/components/implementation/no_interface/cFE_booter/tar.c index 3d36c8dc41..e8ccd05367 100644 --- a/src/components/implementation/no_interface/cFE_booter/tar.c +++ b/src/components/implementation/no_interface/cFE_booter/tar.c @@ -86,7 +86,7 @@ uint32 tar_parse() return OS_FS_SUCCESS; } if (tar_hdr_read(offset, o)) return OS_FS_ERR_DRIVE_NOT_CREATED; - if (file_insert(o, offset + tar_start)) return OS_FS_ERR_DRIVE_NOT_CREATED; + if (file_insert(o, offset + tar_start) == OS_FS_SUCCESS) return OS_FS_ERR_DRIVE_NOT_CREATED; /* * data is aligned to 512 byte blocks. a header is 500 bytes, and @@ -106,14 +106,17 @@ uint32 tar_hdr_read(uint32 tar_offset, struct fsobj *file) { assert(tar_offset < tar_size); assert(file->ino > 0); + struct f_part *part; part_get_new(&part); file->memtype = STATIC; + char *location = tar_start; location += tar_offset; memmove(location + 1, location, strlen(location)); location[0] = '/'; file->name = path_to_name(location); + if (*(location + strlen(location) - 1) == '/') { file->type = FSOBJ_DIR; file->size = 0; From 5a5ba6e075c6f667f9e1b6166057b85dcbd65260 Mon Sep 17 00:00:00 2001 From: Joseph Espy Date: Tue, 22 Aug 2017 15:20:18 -0400 Subject: [PATCH 076/122] Fix error in code to create filesystem from tar --- .../implementation/no_interface/cFE_booter/osfiles.c | 1 - src/components/implementation/no_interface/cFE_booter/tar.c | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osfiles.c b/src/components/implementation/no_interface/cFE_booter/osfiles.c index 2e8e52908b..2bedf62446 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfiles.c +++ b/src/components/implementation/no_interface/cFE_booter/osfiles.c @@ -11,7 +11,6 @@ int32 OS_FS_Init(void) { os_dirent_t d; - OS_printf("The length of a dirent object according to cos/musl is %d\n", sizeof(d)); uint32 ret = 0; ret = tar_load(); diff --git a/src/components/implementation/no_interface/cFE_booter/tar.c b/src/components/implementation/no_interface/cFE_booter/tar.c index e8ccd05367..b391c7b403 100644 --- a/src/components/implementation/no_interface/cFE_booter/tar.c +++ b/src/components/implementation/no_interface/cFE_booter/tar.c @@ -78,15 +78,15 @@ uint32 tar_parse() struct fsobj *o; while (offset + tar_start < tar_end) { - if (file_get_new(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + if (file_get_new(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; //tar ends after two empty records if ( !(offset + tar_start)[0] && !(offset + tar_start)[TAR_BLOCKSIZE]) { o->ino = 0; return OS_FS_SUCCESS; } - if (tar_hdr_read(offset, o)) return OS_FS_ERR_DRIVE_NOT_CREATED; - if (file_insert(o, offset + tar_start) == OS_FS_SUCCESS) return OS_FS_ERR_DRIVE_NOT_CREATED; + if (tar_hdr_read(offset, o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + if (file_insert(o, offset + tar_start) != OS_FS_SUCCESS) return OS_FS_ERR_DRIVE_NOT_CREATED; /* * data is aligned to 512 byte blocks. a header is 500 bytes, and From 7dd51126eed111b9e12f6606fda24b127d8e8734 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Fri, 25 Aug 2017 13:46:06 -0400 Subject: [PATCH 077/122] Add initial implementation of osloader in the cFE_booter --- .../no_interface/cFE_booter/Makefile | 2 +- .../no_interface/cFE_booter/cFE_util.c | 23 +- .../no_interface/cFE_booter/cFE_util.h | 6 +- .../no_interface/cFE_booter/osapi.c | 2 + .../no_interface/cFE_booter/osloader.c | 548 ++++- .../no_interface/cFE_booter/osqueue.c | 3 + .../no_interface/ci_lab/Makefile | 10 + .../no_interface/sample_app/Makefile | 10 + .../no_interface/sample_lib/Makefile | 10 + .../no_interface/to_lab/Makefile | 10 + .../no_interface/vkernel/vkernel.c | 9 +- .../tests/micro_booter/micro_booter.h | 3 +- .../tests/unit_defcompinfo/unit_defcompinfo.c | 1 + .../tests/unit_schedtests/unit_schedlib.c | 1 + src/components/include/cos_debug.h | 11 +- src/components/include/llprint.h | 4 +- src/components/interface/cFE/Makefile | 5 + src/components/interface/cFE/ccsds.h | 463 ++++ src/components/interface/cFE/cfe.h | 81 + src/components/interface/cFE/cfe_error.h | 1317 ++++++++++++ src/components/interface/cFE/cfe_es.h | 1604 ++++++++++++++ src/components/interface/cFE/cfe_es_events.h | 1562 ++++++++++++++ src/components/interface/cFE/cfe_es_msg.h | 1666 +++++++++++++++ src/components/interface/cFE/cfe_es_perfids.h | 86 + src/components/interface/cFE/cfe_evs.h | 427 ++++ src/components/interface/cFE/cfe_evs_events.h | 704 +++++++ src/components/interface/cFE/cfe_evs_msg.h | 1188 +++++++++++ src/components/interface/cFE/cfe_fs.h | 363 ++++ .../interface/cFE/cfe_mission_cfg.h | 477 +++++ .../interface/cFE/cfe_platform_cfg.h | 1857 +++++++++++++++++ src/components/interface/cFE/cfe_psp.h | 422 ++++ src/components/interface/cFE/cfe_psp_config.h | 57 + .../interface/cFE/cfe_psp_configdata.h | 88 + src/components/interface/cFE/cfe_sb.h | 1267 +++++++++++ src/components/interface/cFE/cfe_sb_events.h | 798 +++++++ src/components/interface/cFE/cfe_sb_msg.h | 769 +++++++ src/components/interface/cFE/cfe_tbl.h | 858 ++++++++ src/components/interface/cFE/cfe_tbl_events.h | 1082 ++++++++++ .../interface/cFE/cfe_tbl_filedef.h | 122 ++ src/components/interface/cFE/cfe_tbl_msg.h | 851 ++++++++ src/components/interface/cFE/cfe_time.h | 939 +++++++++ .../interface/cFE/cfe_time_events.h | 592 ++++++ src/components/interface/cFE/cfe_time_msg.h | 1187 +++++++++++ src/components/interface/cFE/cfe_version.h | 83 + src/components/interface/cFE/common_types.h | 374 ++++ .../interface/cFE/network_includes.h | 104 + src/components/interface/cFE/osapi-os-core.h | 330 +++ .../interface/cFE/osapi-os-filesys.h | 440 ++++ .../interface/cFE/osapi-os-loader.h | 104 + src/components/interface/cFE/osapi-os-net.h | 129 ++ src/components/interface/cFE/osapi-os-timer.h | 82 + src/components/interface/cFE/osapi-version.h | 69 + src/components/interface/cFE/osapi.h | 149 ++ src/components/interface/cFE/osconfig.h | 219 ++ .../interface/cFE/private/README.txt | 22 + .../cFE/private/cfe_es_erlog_typedef.h | 60 + .../cFE/private/cfe_es_perfdata_typedef.h | 60 + .../cFE/private/cfe_es_resetdata_typedef.h | 96 + .../cFE/private/cfe_evs_log_typedef.h | 43 + .../interface/cFE/private/cfe_private.h | 319 +++ src/components/interface/cFE/psp_version.h | 44 + src/components/interface/cFE/stubs/s_stub.S | 35 + src/components/lib/cos_kernel_api.c | 17 +- 63 files changed, 24199 insertions(+), 65 deletions(-) create mode 100644 src/components/implementation/no_interface/ci_lab/Makefile create mode 100644 src/components/implementation/no_interface/sample_app/Makefile create mode 100644 src/components/implementation/no_interface/sample_lib/Makefile create mode 100644 src/components/implementation/no_interface/to_lab/Makefile create mode 100644 src/components/interface/cFE/Makefile create mode 100644 src/components/interface/cFE/ccsds.h create mode 100644 src/components/interface/cFE/cfe.h create mode 100644 src/components/interface/cFE/cfe_error.h create mode 100644 src/components/interface/cFE/cfe_es.h create mode 100644 src/components/interface/cFE/cfe_es_events.h create mode 100644 src/components/interface/cFE/cfe_es_msg.h create mode 100644 src/components/interface/cFE/cfe_es_perfids.h create mode 100644 src/components/interface/cFE/cfe_evs.h create mode 100644 src/components/interface/cFE/cfe_evs_events.h create mode 100644 src/components/interface/cFE/cfe_evs_msg.h create mode 100644 src/components/interface/cFE/cfe_fs.h create mode 100644 src/components/interface/cFE/cfe_mission_cfg.h create mode 100644 src/components/interface/cFE/cfe_platform_cfg.h create mode 100644 src/components/interface/cFE/cfe_psp.h create mode 100644 src/components/interface/cFE/cfe_psp_config.h create mode 100644 src/components/interface/cFE/cfe_psp_configdata.h create mode 100644 src/components/interface/cFE/cfe_sb.h create mode 100644 src/components/interface/cFE/cfe_sb_events.h create mode 100644 src/components/interface/cFE/cfe_sb_msg.h create mode 100644 src/components/interface/cFE/cfe_tbl.h create mode 100644 src/components/interface/cFE/cfe_tbl_events.h create mode 100644 src/components/interface/cFE/cfe_tbl_filedef.h create mode 100644 src/components/interface/cFE/cfe_tbl_msg.h create mode 100644 src/components/interface/cFE/cfe_time.h create mode 100644 src/components/interface/cFE/cfe_time_events.h create mode 100644 src/components/interface/cFE/cfe_time_msg.h create mode 100644 src/components/interface/cFE/cfe_version.h create mode 100644 src/components/interface/cFE/common_types.h create mode 100644 src/components/interface/cFE/network_includes.h create mode 100644 src/components/interface/cFE/osapi-os-core.h create mode 100644 src/components/interface/cFE/osapi-os-filesys.h create mode 100644 src/components/interface/cFE/osapi-os-loader.h create mode 100644 src/components/interface/cFE/osapi-os-net.h create mode 100644 src/components/interface/cFE/osapi-os-timer.h create mode 100644 src/components/interface/cFE/osapi-version.h create mode 100644 src/components/interface/cFE/osapi.h create mode 100644 src/components/interface/cFE/osconfig.h create mode 100644 src/components/interface/cFE/private/README.txt create mode 100644 src/components/interface/cFE/private/cfe_es_erlog_typedef.h create mode 100644 src/components/interface/cFE/private/cfe_es_perfdata_typedef.h create mode 100644 src/components/interface/cFE/private/cfe_es_resetdata_typedef.h create mode 100644 src/components/interface/cFE/private/cfe_evs_log_typedef.h create mode 100644 src/components/interface/cFE/private/cfe_private.h create mode 100644 src/components/interface/cFE/psp_version.h create mode 100644 src/components/interface/cFE/stubs/s_stub.S diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index 804cb18680..3273f8bae0 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -1,7 +1,7 @@ # C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c ASM_OBJS= COMPONENT=cFE_booter.o -INTERFACES= +INTERFACES=cFE DEPENDENCIES= IF_LIB:=./composite_cFE.o $(wildcard test/*.o) ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api -lcos_defkernel_api -lsl -lheap -lsl_thd_static_backend -lsl_lock diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.c b/src/components/implementation/no_interface/cFE_booter/cFE_util.c index 040a0c5c44..f4a37415ae 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "gen/osapi.h" #include "cFE_util.h" @@ -14,28 +15,6 @@ void llprint(const char *s, int len) call_cap(PRINT_CAP_TEMP, (int)s, len, 0, 0); } -int prints(char *s) -{ - int len = strlen(s); - llprint(s, len); - return len; -} - -int __attribute__((format(printf,1,2))) -printc(char *fmt, ...) -{ - char s[128]; - va_list arg_ptr; - int ret, len = 128; - - va_start(arg_ptr, fmt); - ret = vsnprintf(s, len, fmt, arg_ptr); - va_end(arg_ptr); - llprint(s, ret); - - return ret; -} - void panic_impl(const char* function, char* message){ printc("cFE panic in %s: %s", function, message); assert(0); diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.h b/src/components/implementation/no_interface/cFE_booter/cFE_util.h index d30d226f36..f109962394 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.h +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.h @@ -8,6 +8,9 @@ #include #include +#include + + #include "gen/common_types.h" // These variables store the global SPACECRAFT_ID and CPU_ID @@ -16,9 +19,6 @@ uint32 CFE_PSP_CpuId; void llprint(const char *s, int len); -// I'm not sure why we even have to reimplement prints... -int prints(char *s); - int __attribute__((format(printf,1,2))) printc(char *fmt, ...); #define PANIC(a) panic_impl(__func__, a) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 28b526a6f8..6bfd7b4560 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -28,6 +28,8 @@ int32 OS_API_Init(void) OS_FS_Init(); + OS_ModuleTableInit(); + have_initialized = 1; } diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index b5b20f40b6..3648ff5a40 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -1,25 +1,82 @@ +#include + +#include +#include + #include "cFE_util.h" #include "gen/osapi.h" #include "gen/common_types.h" +#define USER_CAPS_SYMB_NAME "ST_user_caps" + + +int cobj_count; +struct cobj_header *hs[MAX_NUM_SPDS+1]; + +static void +find_cobjs(struct cobj_header *h, int n) +{ + int i; + vaddr_t start, end; + + start = (vaddr_t)h; + printc("First cobj is '%s'.\n", h->name); + hs[0] = h; + + for (i = 1 ; i < n ; i++) { + int j = 0, size = 0, tot = 0; + + size = h->size; + for (j = 0 ; j < (int)h->nsect ; j++) { + tot += cobj_sect_size(h, j); + } + printc("cobj %s:%d found at %p:%x, size %x -> %x\n", + h->name, h->id, hs[i-1], size, tot, cobj_sect_get(hs[i-1], 0)->vaddr); + + end = start + round_up_to_cacheline(size); + hs[i] = h = (struct cobj_header*)end; + start = end; + } + + hs[n] = NULL; + cobj_count = i; + printc("cobj %s:%d found at %p -> %x\n", + hs[n-1]->name, hs[n-1]->id, hs[n-1], cobj_sect_get(hs[n-1], 0)->vaddr); +} + struct module_internal_record { int free; cpuaddr entry_point; uint32 host_module_id; char filename[OS_MAX_PATH_LEN]; char name[OS_MAX_API_NAME]; + struct cobj_header *header; }; struct module_internal_record module_table[OS_MAX_MODULES]; -/* -** Loader API -*/ +#define INIT_STR_SZ 52 +struct component_init_str { + unsigned int spdid, schedid; + int startup; + char init_str[INIT_STR_SZ]; +}__attribute__((packed)); + +struct component_init_str *init_args; + int32 OS_ModuleTableInit(void) { - uint32 i; + struct cobj_header *h = (struct cobj_header *)cos_comp_info.cos_poly[0]; + + int num_cobj = (int)cos_comp_info.cos_poly[1]; + + init_args = (struct component_init_str *)cos_comp_info.cos_poly[3]; + init_args++; + + find_cobjs(h, num_cobj); + uint32 i; for (i = 0; i < OS_MAX_MODULES; i++) { module_table[i].free = TRUE; module_table[i].entry_point = 0; @@ -33,34 +90,407 @@ int32 OS_ModuleTableInit(void) return OS_ERR_NOT_IMPLEMENTED; } -int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) +struct user_cap { + void (*invfn)(void); + int entryfn, invcount, capnum; +} __attribute__((packed)); + +struct symbol_of_jank { + char name[64]; + void *fn; +}; + +struct symbol_of_jank soj[] = { + { .name = "OS_printf", .fn = OS_printf }, + { .name = "", .fn = NULL }, +}; + +struct symbol_of_jank* lookup_symbol_in_soj(const char *symb_name) { - /* Check parameters. */ - if (symbol_address == NULL || symbol_name == NULL) { - return OS_INVALID_POINTER; + size_t i; + + for (i = 0; soj[i].fn != NULL; i++) { + if (!strcmp(symb_name, soj[i].name)) { + /* We have found the matching SOJ. */ + printc("Found matching SOJ @ %p for undef '%s'.\n", soj[i].fn, symb_name); + return &soj[i]; + } } - /* TODO: Look up entrypoint. */ + return &soj[i]; +} - return OS_ERR_NOT_IMPLEMENTED; +/* +** Loader API +*/ + + +struct cobj_header *get_cobj_header(const char* path) +{ + char name[OS_MAX_PATH_LEN]; + + printc("cobj: Object path is %s\n", path); + + int slash_index; + for (slash_index = strlen(path); path[slash_index] != '/' && slash_index != 0; slash_index--) { + } + if (slash_index == 0) { + PANIC("Could not find slash in object name, aborting..."); + } + /* We just want the name after the slash_index */ + strcpy(name, path + slash_index + 1); + printc("cobj: Object name appears to be %s\n", name); + + /* But before the '.' */ + int dot_index; + for (dot_index = 0; name[dot_index] != '.' && name[dot_index] != '\0'; dot_index++) { + } + if (name[dot_index] == '\0') { + PANIC("Invalid object name, aborting..."); + } + name[dot_index] = '\0'; + printc("cobj: Trimmed object name appears to be %s\n", name); + + int cobj_index; + for (cobj_index = 0; hs[cobj_index] != NULL; cobj_index++) { + if (!strcmp(hs[cobj_index]->name, name)) { + return hs[cobj_index]; + } + } + return NULL; } -int32 OS_SymbolTableDump(const char *filename, uint32 size_limit) +struct user_cap *find_user_caps(struct cobj_header *h) { - /* Not needed. */ - return OS_ERR_NOT_IMPLEMENTED; + size_t i; + + for (i = 0; i < h->nsymb; i++) { + struct cobj_symb *curr = cobj_symb_get(h, i); + if (!strcmp(curr->name, USER_CAPS_SYMB_NAME)) { + printc("cobj: found user caps array '%s' @ %x.\n", USER_CAPS_SYMB_NAME, curr->vaddr); + + /* Set to the first user cap in the array. */ + return (struct user_cap *) (intptr_t) curr->vaddr; + } + } + PANIC("Could not find user capability array!\n"); + return NULL; +} + +void inspect_cobj_symbols(struct cobj_header *h, vaddr_t *comp_info) +{ + unsigned int i; + + printc("cobj: getting spd symbs for header %s, nsymbs %d.\n", h->name, h->nsymb); + for (i = 0 ; i < h->nsymb ; i++) { + struct cobj_symb *symb; + + symb = cobj_symb_get(h, i); + assert(symb); + + if (symb->type == COBJ_SYMB_UNDEF) { + printc("cobj: undefined symbol %s: nsymb %d, usercap offset %d\n", symb->name, i, symb->user_caps_offset); + continue; + } else if (symb->type == COBJ_SYMB_EXPORTED) { + printc("cobj: exported symbol %s: nsymb %d, addr %x\n", symb->name, i, symb->vaddr); + continue; + } + + switch (symb->type) { + case COBJ_SYMB_COMP_INFO: + printc("cobj: comp info %s: addr %x\n", symb->name, symb->vaddr); + *comp_info = symb->vaddr; + break; + case COBJ_SYMB_COMP_PLT: + /* Otherwise known as ST_user_caps. */ + printc("cobj: capability array %s: addr %x\n", symb->name, symb->vaddr); + break; + default: + printc("boot: Unknown symbol type %d\n", symb->type); + break; + } + } +} + +static void +expand_pgtbl(int n_pte, pgtblcap_t pt, vaddr_t vaddr, struct cobj_header *h) +{ + printc("expand_pgtbl(%d, %lu, %lu, %p)\n", n_pte, pt, vaddr, h); + int i; + int tot = 0; + + struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); + struct cos_compinfo *ci = cos_compinfo_get(defci); + + /* Expand Page table, could do this faster */ + for (i = 0 ; i < (int)h->nsect ; i++) { + tot += cobj_sect_size(h, i); + } + + if (tot > SERVICE_SIZE) { + n_pte = tot / SERVICE_SIZE; + if (tot % SERVICE_SIZE) n_pte++; + } + + for (i = 0 ; i < n_pte ; i++) { + printc("cos_pgtbl_intern_alloc(%p, %lu, %lu, %d)\n", ci, pt, vaddr, SERVICE_SIZE); + if (!cos_pgtbl_intern_alloc(ci, pt, vaddr, SERVICE_SIZE)) PANIC("BUG"); + } +} + +static vaddr_t +map_cobj_section(vaddr_t dest_daddr) +{ + struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); + struct cos_compinfo *ci = cos_compinfo_get(defci); + + vaddr_t addr = (vaddr_t) cos_page_bump_alloc(ci); + assert(addr); + + if (cos_mem_alias_at(ci, dest_daddr, ci, addr)) PANIC("BUG"); + + return addr; +} + +void map_cobj_memory(struct cobj_header *h, pgtblcap_t pt) { + int i; + int flag; + vaddr_t dest_daddr, prev_map = 0; + int n_pte = 1; + struct cobj_sect *sect = cobj_sect_get(h, 0); + + printc("cobj: Expanding pgtbl\n"); + expand_pgtbl(n_pte, pt, sect->vaddr, h); + + /* NOTE: We just hardcode this, since we also want to map into this components memory` */ + /* We'll map the component into booter's heap. */ + // new_comp_cap_info[spdid].vaddr_mapped_in_booter = (vaddr_t)cos_get_heap_ptr(); + + for (i = 0 ; i < (int)h->nsect ; i++) { + int left; + + sect = cobj_sect_get(h, i); + flag = MAPPING_RW; + if (sect->flags & COBJ_SECT_KMEM) { + flag |= MAPPING_KMEM; + } + + dest_daddr = sect->vaddr; + left = cobj_sect_size(h, i); + + /* previous section overlaps with this one, don't remap! */ + if (round_to_page(dest_daddr) == prev_map) { + left -= (prev_map + PAGE_SIZE - dest_daddr); + dest_daddr = prev_map + PAGE_SIZE; + } + + while (left > 0) { + map_cobj_section(dest_daddr); + + prev_map = dest_daddr; + dest_daddr += PAGE_SIZE; + left -= PAGE_SIZE; + } + } +} + +static int +process_cinfo(struct cobj_header *h, spdid_t spdid, vaddr_t heap_val, + char *mem, vaddr_t symb_addr) +{ + int i; + struct cos_component_information *ci; + + assert(symb_addr == round_to_page(symb_addr)); + ci = (struct cos_component_information*)(mem); + + if (!ci->cos_heap_ptr) ci->cos_heap_ptr = heap_val; + + ci->cos_this_spd_id = spdid; + ci->init_string[0] = '\0'; + + for (i = 0 ; init_args[i].spdid ; i++) { + char *start, *end; + int len; + + if (init_args[i].spdid != spdid) continue; + + start = strchr(init_args[i].init_str, '\''); + if (!start) break; + start++; + end = strchr(start, '\''); + if (!end) break; + len = (int)(end-start); + memcpy(&ci->init_string[0], start, len); + ci->init_string[len] = '\0'; + } + + return 1; +} + +static vaddr_t +find_end(struct cobj_header *h) +{ + struct cobj_sect *sect; + int max_sect; + + max_sect = h->nsect-1; + sect = cobj_sect_get(h, max_sect); + + return sect->vaddr + round_up_to_page(sect->bytes); +} + + +void populate_cobj_memory(struct cobj_header *h, spdid_t spdid, vaddr_t comp_info, int first_time) { + unsigned int i; + /* Where are we in the actual component's memory in the booter? */ + char *start_addr; + /* Where are we in the destination address space? */ + vaddr_t init_daddr; + + // TODO: Verify this transformation is correct + // start_addr = (char *)(new_comp_cap_info[spdid].vaddr_mapped_in_booter); + start_addr = (char *) cos_get_heap_ptr(); + + init_daddr = cobj_sect_get(h, 0)->vaddr; + for (i = 0 ; i < h->nsect ; i++) { + struct cobj_sect *sect; + vaddr_t dest_daddr; + char *lsrc; + int left; + + sect = cobj_sect_get(h, i); + /* virtual address in the destination address space */ + dest_daddr = sect->vaddr; + /* where we're copying from in the cobj */ + lsrc = cobj_sect_contents(h, i); + /* how much is left to copy? */ + left = cobj_sect_size(h, i); + + printc("Destination is %p\n", (void*) dest_daddr); + + /* Initialize memory. */ + if (!(sect->flags & COBJ_SECT_KMEM) && + (first_time || !(sect->flags & COBJ_SECT_INITONCE))) { + if (sect->flags & COBJ_SECT_ZEROS) { + char * to = (char *) dest_daddr; + printc("Zeroing some memory %p (%d bytes)!\n", to, left); + // HACK: Should actually resolve this + // memset(start_addr + (dest_daddr - init_daddr), 0, left); + memset(to, 0, left); + } else { + char * to = (char *) dest_daddr; + char * from = lsrc; + printc("Setting some memory to %p from %p (%d bytes)!\n", to, from, left); + // HACK: Should actually resolve this + // memcpy(start_addr + (dest_daddr - init_daddr), lsrc, left); + memcpy(to, from, left); + } + } + + if (sect->flags & COBJ_SECT_CINFO) { + assert(left == PAGE_SIZE); + assert(comp_info == dest_daddr); + process_cinfo(h, spdid, find_end(h), start_addr + (comp_info-init_daddr), comp_info); + // NOTE: This is useless, since we never upcall + // struct cos_component_information *ci; + // ci = (struct cos_component_information*)(start_addr + (comp_info-init_daddr)); + // new_comp_cap_info[h->id].upcall_entry = ci->cos_upcall_entry; + + } + } + +} + + +void setup_cobj_memory(struct cobj_header *h, spdid_t spdid, vaddr_t comp_info, pgtblcap_t pt) +{ + /* Allocating memory and mapping it to the booter's address space */ + printc("cobj: doing map_cobj_memory\n"); + map_cobj_memory(h, pt); + + printc("cobj: doing populate_cobj_memory\n"); + populate_cobj_memory(h, spdid, comp_info, 1); +} + + +void load_cobj_into_memory(struct cobj_header *h) +{ + vaddr_t ci = 0; + pgtblcap_t pt = BOOT_CAPTBL_SELF_PT; + spdid_t spdid = h->id; + + printc("cobj: Loading cobj with id %d, name %s\n", h->id, h->name); + + + // NOTE: We end up not needing this information + // struct cobj_sect *sect; + // sect = cobj_sect_get(h, 0); + // new_comp_cap_info[spdid].addr_start = sect->vaddr; + + + inspect_cobj_symbols(h, &ci); + + if (ci == 0) { + PANIC("Could not find component info in cobj!"); + } + + printc("Mapping cobj '%s'.\n", h->name); + setup_cobj_memory(h, spdid, ci, pt); +} + +void link_cobj(struct cobj_header *h, struct user_cap *user_caps) +{ + unsigned int i; + + printc("link: printing symbols of jank.\n"); + for (i = 0; soj[i].fn != NULL; i++) { + printc("\tlink: symbol of jank %d '%s' with fn @ %p\n", i, soj[i].name, soj[i].fn); + } + + /* Iterate through each symbol in the header. If it is undefined, index into the user caps array and set the `invfn`. */ + printc("link: parsing symbols for cobj header '%s'.\n", h->name); + for (i = 0; i < h->nsymb; i++) { + struct cobj_symb *symb = cobj_symb_get(h, i); + assert(symb); + + if (symb->type == COBJ_SYMB_UNDEF) { + printc("link: found undefined symbol '%s': nsymb %u, usercap offset %d\n", symb->name, i, symb->user_caps_offset); + + // FIXME: Figure out if this is an ok way to do this + // struct symbol_of_jank *symbol = lookup_symbol_in_soj(symb->name); + cpuaddr addr; + int result = OS_SymbolLookup(&addr, symb->name); + if (result != OS_SUCCESS) { + printc("link: ERROR: could not find matching symbol for '%s'.\n", symb->name); + PANIC("Cannot resolve symbol!"); + } + + struct user_cap cap = (struct user_cap) { + .invfn = (void *) addr + }; + + printc("link: setting user cap index %d invfn @ %p\n", symb->user_caps_offset, cap.invfn); + user_caps[symb->user_caps_offset] = cap; + } + } + + printc("link: done parsing symbols for cobj header '%s'.\n", h->name); + } int32 OS_ModuleLoad(uint32 *module_id, const char *module_name, const char *filename) { + printc("OS_ModuleLoad start\n"); + uint32 i; uint32 possible_id; - char translated_path[OS_MAX_PATH_LEN]; /* Check parameters. */ if (module_id == NULL || module_name == NULL || filename == NULL) { return OS_INVALID_POINTER; } + printc("OS_ModuleLoad %s %s\n", module_name, filename); /* Find a free id. */ for (possible_id = 0; possible_id < OS_MAX_MODULES; possible_id++) { @@ -69,31 +499,97 @@ int32 OS_ModuleLoad(uint32 *module_id, const char *module_name, const char *file /* Check bounds of that id. */ if (possible_id >= OS_MAX_MODULES || module_table[possible_id].free == FALSE) { + printc("OS_ERR_NO_FREE_IDS\n"); return OS_ERR_NO_FREE_IDS; } /* Check if the module was already loaded. */ for (i = 0; i < OS_MAX_MODULES; i++) { if (module_table[i].free == FALSE && strcmp(module_name, module_table[i].name) == 0) { + printc("OS_ERR_NAME_TAKEN\n"); return OS_ERR_NAME_TAKEN; } } + struct cobj_header *h = get_cobj_header(filename); + if (!h) { + printc("Could not find cobj for designated object %s!\n", filename); + return OS_ERROR; + } + /* Claim the module id. */ module_table[possible_id].free = FALSE; - /* Translate the filename. */ - int32 return_code = OS_TranslatePath(filename, (char *)translated_path); - if (return_code != OS_SUCCESS) { - module_table[possible_id].free = TRUE; - return return_code; + module_table[possible_id].header = h; + + struct user_cap *caps = find_user_caps(h); + + // Load + link the cobj + load_cobj_into_memory(h); + link_cobj(h, caps); + + printc("osloader: Loading finished successfully, returning OS_SUCCESS\n"); + + return OS_SUCCESS; +} + +cpuaddr search_cobj_for_symbol(struct cobj_header *h, const char *symbol_name) +{ + unsigned int i; + + for (i = 0 ; i < h->nsymb ; i++) { + struct cobj_symb *symb; + + symb = cobj_symb_get(h, i); + assert(symb); + + + // TODO: Check if we need to do more work for certain symbol types (eg. undefined symbols) + if (!strcmp(symb->name, symbol_name) && symb->type == COBJ_SYMB_EXPORTED) { + return (cpuaddr) symb->vaddr; + } + } + return 0; +} + +int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) +{ + printc("osloader: doing symbol lookup for %s\n", symbol_name); + /* Check parameters. */ + if (symbol_address == NULL || symbol_name == NULL) { + return OS_INVALID_POINTER; } - /* TODO: Load the module. */ + struct symbol_of_jank *jank_symbol = lookup_symbol_in_soj(symbol_name); + if (jank_symbol->fn != NULL) { + *symbol_address = (cpuaddr) jank_symbol->fn; + printc("osloader: found soj for %s, address %p\n", symbol_name, (void *) jank_symbol->fn); + return OS_SUCCESS; + } - return OS_ERR_NOT_IMPLEMENTED; + int i; + for(i = 0; i < OS_MAX_MODULES; i++) { + if(!module_table[i].free) { + cpuaddr addr = search_cobj_for_symbol(module_table[i].header, symbol_name); + if (addr != 0) { + printc("osloader: found cobj symbol for %s, address %p\n", symbol_name, (void *) addr); + size_t j; + printc("[ "); + for(j = 0; j < 1000; j++) + { + printc("%02x ", ((char *) addr)[j]); + } + printc("]\n"); + *symbol_address = addr; + return OS_SUCCESS; + } + } + } + + return OS_ERROR; } + int32 OS_ModuleUnload(uint32 module_id) { /* Check the given id. */ @@ -101,11 +597,11 @@ int32 OS_ModuleUnload(uint32 module_id) return OS_ERR_INVALID_ID; } - /* TODO: Unload module. */ + // TODO: Verify that doing nothing here makes sense module_table[module_id].free = TRUE; - return OS_ERR_NOT_IMPLEMENTED; + return OS_SUCCESS; } int32 OS_ModuleInfo(uint32 module_id, OS_module_prop_t *module_info) @@ -123,7 +619,11 @@ int32 OS_ModuleInfo(uint32 module_id, OS_module_prop_t *module_info) strncpy(module_info->filename, module_table[module_id].filename, OS_MAX_API_NAME); strncpy(module_info->name, module_info[module_id].name, OS_MAX_API_NAME); - /* TODO: Address info? */ + return OS_SUCCESS; +} +int32 OS_SymbolTableDump(const char *filename, uint32 size_limit) +{ + /* Not needed. */ return OS_ERR_NOT_IMPLEMENTED; } diff --git a/src/components/implementation/no_interface/cFE_booter/osqueue.c b/src/components/implementation/no_interface/cFE_booter/osqueue.c index 67ffcda3fb..eb42bda053 100644 --- a/src/components/implementation/no_interface/cFE_booter/osqueue.c +++ b/src/components/implementation/no_interface/cFE_booter/osqueue.c @@ -5,6 +5,9 @@ #include +#undef OS_MAX_QUEUES +#define OS_MAX_QUEUES 15 + #define MAX_QUEUE_DATA_SIZE (1024 * 1024) // The main queue data structure. diff --git a/src/components/implementation/no_interface/ci_lab/Makefile b/src/components/implementation/no_interface/ci_lab/Makefile new file mode 100644 index 0000000000..3569653431 --- /dev/null +++ b/src/components/implementation/no_interface/ci_lab/Makefile @@ -0,0 +1,10 @@ +# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c +ASM_OBJS= +COMPONENT=ci_lab.o +INTERFACES= +DEPENDENCIES=cFE +IF_LIB:=./cFE_ci_lab_app.o +ADDITIONAL_LIBS= + +include ../../Makefile.subsubdir +MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/sample_app/Makefile b/src/components/implementation/no_interface/sample_app/Makefile new file mode 100644 index 0000000000..73f85f8184 --- /dev/null +++ b/src/components/implementation/no_interface/sample_app/Makefile @@ -0,0 +1,10 @@ +# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c +ASM_OBJS= +COMPONENT=sample_app.o +INTERFACES= +DEPENDENCIES=cFE +IF_LIB:=./cFE_sample_app.o +ADDITIONAL_LIBS= + +include ../../Makefile.subsubdir +MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/sample_lib/Makefile b/src/components/implementation/no_interface/sample_lib/Makefile new file mode 100644 index 0000000000..9ad7160cea --- /dev/null +++ b/src/components/implementation/no_interface/sample_lib/Makefile @@ -0,0 +1,10 @@ +# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c +ASM_OBJS= +COMPONENT=sample_lib.o +INTERFACES= +DEPENDENCIES=cFE +IF_LIB:=./cFE_sample_lib.o +ADDITIONAL_LIBS= + +include ../../Makefile.subsubdir +MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/to_lab/Makefile b/src/components/implementation/no_interface/to_lab/Makefile new file mode 100644 index 0000000000..35515bd780 --- /dev/null +++ b/src/components/implementation/no_interface/to_lab/Makefile @@ -0,0 +1,10 @@ +# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c +ASM_OBJS= +COMPONENT=to_lab.o +INTERFACES= +DEPENDENCIES=cFE +IF_LIB:=./cFE_to_lab_app.o +ADDITIONAL_LIBS= + +include ../../Makefile.subsubdir +MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/vkernel/vkernel.c b/src/components/implementation/no_interface/vkernel/vkernel.c index dfcce436c5..0b75876009 100644 --- a/src/components/implementation/no_interface/vkernel/vkernel.c +++ b/src/components/implementation/no_interface/vkernel/vkernel.c @@ -9,6 +9,7 @@ #define assert(node) do { if (unlikely(!(node))) { debug_print("assert error in @ "); *((int *)0) = 0; } } while (0) #define PRINT_FN prints #define debug_print(str) (PRINT_FN(str __FILE__ ":" STR(__LINE__) ".\n")) +#undef BUG #define BUG() do { debug_print("BUG @ "); *((int *)0) = 0; } while (0); #define SPIN() do { while (1) ; } while (0) @@ -31,13 +32,13 @@ vm_exit(void *d) { printc("%d: EXIT\n", (int)d); ready_vms --; - vmx_info[(int)d].state = VM_EXITED; + vmx_info[(int)d].state = VM_EXITED; while (1) cos_thd_switch(BOOT_CAPTBL_SELF_INITTHD_BASE); } void -scheduler(void) +scheduler(void) { static unsigned int i; thdid_t tid; @@ -47,7 +48,7 @@ scheduler(void) while (ready_vms) { index = i++ % VM_COUNT; - + if (vmx_info[index].state == VM_RUNNING) { assert(vk_info.vminitasnd[index]); @@ -72,7 +73,7 @@ cos_init(void) cos_compinfo_init(vk_cinfo, BOOT_CAPTBL_SELF_PT, BOOT_CAPTBL_SELF_CT, BOOT_CAPTBL_SELF_COMP, (vaddr_t)cos_get_heap_ptr(), BOOT_CAPTBL_FREE, vk_cinfo); /* - * TODO: If there is any captbl modification, this could mess up a bit. + * TODO: If there is any captbl modification, this could mess up a bit. * Care to be taken not to use this for captbl mod api * Or use some offset into the future in CAPTBL_FREE */ diff --git a/src/components/implementation/tests/micro_booter/micro_booter.h b/src/components/implementation/tests/micro_booter/micro_booter.h index bc004fa23a..952406f4f9 100644 --- a/src/components/implementation/tests/micro_booter/micro_booter.h +++ b/src/components/implementation/tests/micro_booter/micro_booter.h @@ -3,6 +3,8 @@ #include #include +#include + #undef assert #ifndef assert /* On assert, immediately switch to the "exit" thread */ @@ -11,7 +13,6 @@ #define PRINT_FN prints #define debug_print(str) (PRINT_FN(str __FILE__ ":" STR(__LINE__) ".\n")) -#define BUG() do { debug_print("BUG @ "); *((int *)0) = 0; } while (0); #define BUG_DIVZERO() do { debug_print("Testing divide by zero fault @ "); int i = num / den; } while (0); #define SPIN() do { while (1) ; } while (0) diff --git a/src/components/implementation/tests/unit_defcompinfo/unit_defcompinfo.c b/src/components/implementation/tests/unit_defcompinfo/unit_defcompinfo.c index ab44d0ca60..d6dbaedd3c 100644 --- a/src/components/implementation/tests/unit_defcompinfo/unit_defcompinfo.c +++ b/src/components/implementation/tests/unit_defcompinfo/unit_defcompinfo.c @@ -14,6 +14,7 @@ #define assert(node) do { if (unlikely(!(node))) { debug_print("assert error in @ "); *((int *)0) = 0; } } while (0) #define PRINT_FN prints #define debug_print(str) (PRINT_FN(str __FILE__ ":" STR(__LINE__) ".\n")) +#undef BUG #define BUG() do { debug_print("BUG @ "); *((int *)0) = 0; } while (0); #define SPIN() do { while (1) ; } while (0) diff --git a/src/components/implementation/tests/unit_schedtests/unit_schedlib.c b/src/components/implementation/tests/unit_schedtests/unit_schedlib.c index b3360bd26d..b21c4ad18e 100644 --- a/src/components/implementation/tests/unit_schedtests/unit_schedlib.c +++ b/src/components/implementation/tests/unit_schedtests/unit_schedlib.c @@ -16,6 +16,7 @@ #define assert(node) do { if (unlikely(!(node))) { debug_print("assert error in @ "); *((int *)0) = 0; } } while (0) #define PRINT_FN prints #define debug_print(str) (PRINT_FN(str __FILE__ ":" STR(__LINE__) ".\n")) +#undef BUG #define BUG() do { debug_print("BUG @ "); *((int *)0) = 0; } while (0); #define SPIN(iters) do { if (iters > 0) { for (; iters > 0 ; iters -- ) ; } else { while (1) ; } } while (0) diff --git a/src/components/include/cos_debug.h b/src/components/include/cos_debug.h index 0f7c083b8c..aa1e2fedae 100644 --- a/src/components/include/cos_debug.h +++ b/src/components/include/cos_debug.h @@ -1,8 +1,12 @@ #ifndef COS_DEBUG_H +#define COS_DEBUG_H #include #include +static volatile int *volatile_null_ptr = (int *) NULL; + + #ifdef COMPONENT_ASSERTIONS #define DEBUG #endif @@ -10,13 +14,14 @@ #ifndef PRINT_FN #define PRINT_FN prints #endif -#include +#include /* Convoluted: We need to pass the __LINE__ through 2 macros to get it * to expand to a constant string */ + #define STRX(x) #x #define STR(x) STRX(x) #define debug_print(str) (PRINT_FN(str __FILE__ ":" STR(__LINE__) ".\n")) -#define BUG() do { debug_print("BUG @ "); *((int *)0) = 0; } while (0); +#define BUG() do { debug_print("BUG @ "); *volatile_null_ptr = 0; } while (0); #ifdef DEBUG #ifndef assert @@ -25,7 +30,7 @@ * static assertion that the condition is true past the assertion. */ __attribute__ ((noreturn)) static inline void __cos_noret(void) { while (1) ; } -#define assert(node) do { if (unlikely(!(node))) { debug_print("FIXME: assert error in @ "); *((int *)0) = 0; __cos_noret(); } } while(0) +#define assert(node) do { if (unlikely(!(node))) { debug_print("FIXME: assert error in @ "); *volatile_null_ptr = 0; __cos_noret(); } } while(0) #endif #ifndef BUG_ON #define BUG_ON(c) assert(!(c)) diff --git a/src/components/include/llprint.h b/src/components/include/llprint.h index 6d72ff5865..631a23e3ff 100644 --- a/src/components/include/llprint.h +++ b/src/components/include/llprint.h @@ -9,7 +9,7 @@ static void cos_llprint(char *s, int len) { call_cap(PRINT_CAP_TEMP, (int)s, len, 0, 0); } -int +static int prints(char *s) { int len = strlen(s); @@ -19,7 +19,7 @@ prints(char *s) return len; } -int __attribute__((format(printf,1,2))) +static int __attribute__((format(printf,1,2))) printc(char *fmt, ...) { char s[128]; diff --git a/src/components/interface/cFE/Makefile b/src/components/interface/cFE/Makefile new file mode 100644 index 0000000000..f55b30401e --- /dev/null +++ b/src/components/interface/cFE/Makefile @@ -0,0 +1,5 @@ +LIB_OBJS= +LIBS=$(LIB_OBJS:%.o=%.a) +ASM_STUBS=s_stubpg.o + +include ../Makefile.subdir diff --git a/src/components/interface/cFE/ccsds.h b/src/components/interface/cFE/ccsds.h new file mode 100644 index 0000000000..a077d2c9d8 --- /dev/null +++ b/src/components/interface/cFE/ccsds.h @@ -0,0 +1,463 @@ +/****************************************************************************** +** File: ccsds.h +** +** Copyright (c) 2004-2012, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** +** Purpose: +** Define typedefs and macros for CCSDS packet headers. +** +** $Log: ccsds.h $ +** Revision 1.6.1.2 2014/12/02 13:48:54GMT-05:00 rmcgraw +** DCR22841:3 Added CFE_MAKE_BIG16 to ccsds.h in branch64 +** Revision 1.6.1.1 2014/12/01 11:18:00EST rmcgraw +** DCR22841:1 Reverted cmd sec hdr struct and RD/WR macros to pre-6.4.0 state +** Revision 1.6 2014/07/10 10:24:07EDT rmcgraw +** DCR9772:1 Changes from C. Monaco & W.M Reid from APL for endianess neutrality +** Revision 1.5 2011/02/03 15:27:48EST lwalling +** Modified telemetry secondary header definition to support CFE_SB_PACKET_TIME_FORMAT selection +** Revision 1.4 2010/10/25 15:01:27EDT jmdagost +** Corrected bad apostrophe in prologue. +** Revision 1.3 2010/10/04 15:25:32EDT jmdagost +** Cleaned up copyright symbol. +** Revision 1.2 2010/09/21 16:15:16EDT jmdagost +** Removed unused function prototypes. +** Revision 1.1 2008/04/17 08:05:18EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.4 2006/06/12 11:18:18EDT rjmcgraw +** Added legal statement +** Revision 1.3 2006/04/28 15:09:44EDT rjmcgraw +** Corrected comments in CCSDS_CmdSecHdr_t definition +** +******************************************************************************/ + +#ifndef _ccsds_ +#define _ccsds_ + +/* +** Include Files +*/ + +#include "common_types.h" +#include "cfe_mission_cfg.h" + + +/* Macro to convert 16 bit word from platform "endianness" to Big Endian */ +#ifdef SOFTWARE_BIG_BIT_ORDER + #define CFE_MAKE_BIG16(n) (n) +#else + #define CFE_MAKE_BIG16(n) ( (((n) << 8) & 0xFF00) | (((n) >> 8) & 0x00FF) ) +#endif + + +/* CCSDS_TIME_SIZE is specific to the selected CFE_SB time format */ +#if (CFE_SB_PACKET_TIME_FORMAT == CFE_SB_TIME_32_16_SUBS) + /* 32 bits seconds + 16 bits subseconds */ + #define CCSDS_TIME_SIZE 6 +#elif (CFE_SB_PACKET_TIME_FORMAT == CFE_SB_TIME_32_32_SUBS) + /* 32 bits seconds + 32 bits subseconds */ + #define CCSDS_TIME_SIZE 8 +#elif (CFE_SB_PACKET_TIME_FORMAT == CFE_SB_TIME_32_32_M_20) + /* 32 bits seconds + 20 bits microsecs + 12 bits reserved */ + #define CCSDS_TIME_SIZE 8 +#else + /* unknown format */ + #error unable to define CCSDS_TIME_SIZE! +#endif + + +/* +** Type Definitions +*/ + +/********************************************************************** +** Structure definitions for CCSDS headers. All items in the structure +** must be aligned on 16-bit words. Bitfields must be avoided since +** some compilers (such as gcc) force them into 32-bit alignment. +**********************************************************************/ + +/*----- CCSDS packet primary header. -----*/ + +typedef struct { + + uint8 StreamId[2]; /* packet identifier word (stream ID) */ + /* bits shift ------------ description ---------------- */ + /* 0x07FF 0 : application ID */ + /* 0x0800 11 : secondary header: 0 = absent, 1 = present */ + /* 0x1000 12 : packet type: 0 = TLM, 1 = CMD */ + /* 0xE000 13 : CCSDS version, always set to 0 */ + + uint8 Sequence[2]; /* packet sequence word */ + /* bits shift ------------ description ---------------- */ + /* 0x3FFF 0 : sequence count */ + /* 0xC000 14 : segmentation flags: 3 = complete packet */ + + uint8 Length[2]; /* packet length word */ + /* bits shift ------------ description ---------------- */ + /* 0xFFFF 0 : (total packet length) - 7 */ + +} CCSDS_PriHdr_t; + +/*----- CCSDS command secondary header. -----*/ + +typedef struct { + + uint16 Command; /* command secondary header */ + /* bits shift ------------ description ---------------- */ + /* 0x00FF 0 : checksum, calculated by ground system */ + /* 0x7F00 8 : command function code */ + /* 0x8000 15 : reserved, set to 0 */ + +} CCSDS_CmdSecHdr_t; + +/*----- CCSDS telemetry secondary header. -----*/ + +typedef struct { + + uint8 Time[CCSDS_TIME_SIZE]; + +} CCSDS_TlmSecHdr_t; + +/*----- Generic combined command header. -----*/ + +typedef struct { + CCSDS_PriHdr_t PriHdr; + CCSDS_CmdSecHdr_t SecHdr; +} CCSDS_CmdPkt_t; + +/*----- Generic combined telemetry header. -----*/ + +typedef struct { + CCSDS_PriHdr_t PriHdr; + CCSDS_TlmSecHdr_t SecHdr; +} CCSDS_TlmPkt_t; + + +/* +** Macro Definitions +*/ + +/********************************************************************** +** Constant values. +**********************************************************************/ + +/* Value of packet type for a telemetry packet. */ +#define CCSDS_TLM 0 +/* Value of packet type for a command packet. */ +#define CCSDS_CMD 1 + +/* Value of secondary header flag if secondary header not present. */ +#define CCSDS_NO_SEC_HDR 0 +/* Value of secondary header flag if secondary header exists. */ +#define CCSDS_HAS_SEC_HDR 1 + +#define NUM_CCSDS_APIDS 2048 +#define NUM_CCSDS_PKT_TYPES 2 + + +/********************************************************************** +** Initial values for CCSDS header fields. +**********************************************************************/ + +/* Initial value of the sequence count. */ +#define CCSDS_INIT_SEQ 0 +/* Initial value of the sequence flags. */ +#define CCSDS_INIT_SEQFLG 3 +/* Initial value of the command function code. */ +#define CCSDS_INIT_FC 0 +/* Initial value of the command checksum. */ +#define CCSDS_INIT_CHECKSUM 0 + +/* Note: the stream ID and length are always explicitly set for a packet, +** so default values are not required. */ + + +/********************************************************************** +** Macros for reading and writing bit fields in a 16-bit integer. +** These are used to implement the read and write macros below. +**********************************************************************/ + +/* Read bits specified by 'mask' from 'word' and shift down by 'shift'. */ +#define CCSDS_RD_BITS(word,mask,shift) \ + (((word) & mask) >> shift) + +/* Shift 'value' up by 'shift' and write to those bits in 'word' that +** are specified by 'mask'. Other bits in 'word' are unchanged. */ +#define CCSDS_WR_BITS(word,mask,shift,value) \ + ((word) = (uint16)(((word) & ~mask) | (((value) & (mask >> shift)) << shift))) + + +/********************************************************************** +** Macros for reading and writing the fields in a CCSDS header. All +** of the macros are used in a similar way: +** +** CCSDS_RD_xxx(header) -- Read field xxx from header. +** CCSDS_WR_xxx(header,value) -- Write value to field xxx of header. +** +** Note that 'header' is a reference to the actual header structure, +** not to a pointer to the structure. If using a pointer, one must +** refer to the structure as *pointer. +** +** The CCSDS_WR_xxx macros may refer to 'header' more than once; thus +** the expression for 'header' must NOT contain any side effects. +**********************************************************************/ + +/* Read entire stream ID from primary header. */ +#define CCSDS_RD_SID(phdr) (((phdr).StreamId[0] << 8) + ((phdr).StreamId[1])) +/* Write entire stream ID to primary header. */ +#define CCSDS_WR_SID(phdr,value) ( ((phdr).StreamId[0] = (value >> 8) ) ,\ + ((phdr).StreamId[1] = (value & 0xff) ) ) + +/* Read application ID from primary header. */ +#define CCSDS_RD_APID(phdr) (CCSDS_RD_SID(phdr) & 0x07FF) +/* Write application ID to primary header. */ +#define CCSDS_WR_APID(phdr,value) ((((phdr).StreamId[0] = ((phdr).StreamId[0] & 0xF8) | ((value >> 8) & 0x07))) ,\ + (((phdr).StreamId[1] = ((value)) & 0xff)) ) + +/* Read secondary header flag from primary header. */ +#define CCSDS_RD_SHDR(phdr) (((phdr).StreamId[0] & 0x08) >> 3) +/* Write secondary header flag to primary header. */ +#define CCSDS_WR_SHDR(phdr,value) ((phdr).StreamId[0] = ((phdr).StreamId[0] & 0xf7) | ((value << 3) & 0x08)) + +/* Read packet type (0=TLM,1=CMD) from primary header. */ +#define CCSDS_RD_TYPE(phdr) (((phdr).StreamId[0] & 0x10) >> 4) +/* Write packet type (0=TLM,1=CMD) to primary header. */ +#define CCSDS_WR_TYPE(phdr,value) ((phdr).StreamId[0] = ((phdr).StreamId[0] & 0xEF) | ((value << 4) & 0x10)) + +/* Read CCSDS version from primary header. */ +#define CCSDS_RD_VERS(phdr) (((phdr).StreamId[0] & 0xE0) >> 5) +/* Write CCSDS version to primary header. */ +#define CCSDS_WR_VERS(phdr,value) ((phdr).StreamId[0] = ((phdr).StreamId[0] & 0x1F) | ((value << 5) & 0xE0)) + +/* Read sequence count from primary header. */ +#define CCSDS_RD_SEQ(phdr) ((((phdr).Sequence[0] & 0x3F) << 8) + ((phdr).Sequence[1])) +/* Write sequence count to primary header. */ +#define CCSDS_WR_SEQ(phdr,value) ((((phdr).Sequence[0] = ((phdr).Sequence[0] & 0xC0) | ((value >> 8) & 0x3f))) ,\ + (((phdr).Sequence[1] = ((value)) & 0xff)) ) + +/* Read sequence flags from primary header. */ +#define CCSDS_RD_SEQFLG(phdr) (((phdr).Sequence[0] & 0xC0) >> 6) +/* Write sequence flags to primary header. */ +#define CCSDS_WR_SEQFLG(phdr,value) ((phdr).Sequence[0] = ((phdr).Sequence[0] & 0x3F) | ((value << 6) & 0xC0) ) + +/* Read total packet length from primary header. */ +#define CCSDS_RD_LEN(phdr) ( ( (phdr).Length[0] << 8) + (phdr).Length[1] + 7) +/* Write total packet length to primary header. */ +#define CCSDS_WR_LEN(phdr,value) ((((phdr).Length[0] = ((value) - 7) >> 8)) ,\ + (((phdr).Length[1] = ((value) - 7) & 0xff)) ) + +/* Read function code from command secondary header. */ +#define CCSDS_RD_FC(shdr) CCSDS_RD_BITS((shdr).Command, 0x7F00, 8) +/* Write function code to command secondary header. */ +#define CCSDS_WR_FC(shdr,value) CCSDS_WR_BITS((shdr).Command, 0x7F00, 8, value) + +/* Read checksum from command secondary header. */ +#define CCSDS_RD_CHECKSUM(shdr) CCSDS_RD_BITS((shdr).Command, 0x00FF, 0) +/* Write checksum to command secondary header. */ +#define CCSDS_WR_CHECKSUM(shdr,val) CCSDS_WR_BITS((shdr).Command, 0x00FF, 0, val) + + +/********************************************************************** +** Macros for clearing a CCSDS header to a standard initial state. All +** of the macros are used in a similar way: +** CCSDS_CLR_xxx_HDR(header) -- Clear header of type xxx. +**********************************************************************/ + +/* Clear primary header. */ +#define CCSDS_CLR_PRI_HDR(phdr) \ + ( (phdr).StreamId[0] = 0,\ + (phdr).StreamId[1] = 0,\ + (phdr).Sequence[0] = (CCSDS_INIT_SEQFLG << 6),\ + (phdr).Sequence[1] = 0,\ + (phdr).Length[0] = 0, \ + (phdr).Length[1] = 0 ) + +/* Clear command secondary header. */ +#define CCSDS_CLR_CMDSEC_HDR(shdr) \ + ( (shdr).Command = (CCSDS_INIT_CHECKSUM << 0) | (CCSDS_INIT_FC << 8) ) + + +#define CCSDS_WR_SEC_HDR_SEC(shdr, value) shdr.Time[0] = ((value>>24) & 0xFF), \ + shdr.Time[1] = ((value>>16) & 0xFF), \ + shdr.Time[2] = ((value>>8) & 0xFF), \ + shdr.Time[3] = ((value) & 0xFF) + +#define CCSDS_RD_SEC_HDR_SEC(shdr) (((uint32)shdr.Time[0]) << 24) | \ + (((uint32)shdr.Time[1]) << 16) | \ + (((uint32)shdr.Time[2]) << 8) | \ + ((uint32)shdr.Time[3]) + +/* Clear telemetry secondary header. */ +#if (CFE_SB_PACKET_TIME_FORMAT == CFE_SB_TIME_32_16_SUBS) + /* 32 bits seconds + 16 bits subseconds */ + #define CCSDS_CLR_TLMSEC_HDR(shdr) \ + ( (shdr).Time[0] = 0,\ + (shdr).Time[1] = 0,\ + (shdr).Time[2] = 0,\ + (shdr).Time[3] = 0,\ + (shdr).Time[4] = 0,\ + (shdr).Time[5] = 0 ) + + +#define CCSDS_WR_SEC_HDR_SUBSEC(shdr, value) shdr.Time[4] = ((value>>8) & 0xFF), \ + shdr.Time[5] = ((value) & 0xFF) + +#define CCSDS_RD_SEC_HDR_SUBSEC(shdr) (((uint32)shdr.Time[4]) << 8) | \ + ((uint32)shdr.Time[5]) +#elif ((CFE_SB_PACKET_TIME_FORMAT == CFE_SB_TIME_32_32_SUBS) ||\ + (CFE_SB_PACKET_TIME_FORMAT == CFE_SB_TIME_32_32_M_20)) + /* 32 bits seconds + 32 bits subseconds */ + #define CCSDS_CLR_TLMSEC_HDR(shdr) \ + ( (shdr).Time[0] = 0,\ + (shdr).Time[1] = 0,\ + (shdr).Time[2] = 0,\ + (shdr).Time[3] = 0,\ + (shdr).Time[4] = 0,\ + (shdr).Time[5] = 0,\ + (shdr).Time[6] = 0,\ + (shdr).Time[7] = 0 ) + +#define CCSDS_WR_SEC_HDR_SUBSEC(shdr, value) shdr.Time[4] = ((value>>24) & 0xFF), \ + shdr.Time[5] = ((value>>16) & 0xFF), \ + shdr.Time[6] = ((value>>8) & 0xFF), \ + shdr.Time[7] = ((value) & 0xFF) + +#define CCSDS_RD_SEC_HDR_SUBSEC(shdr) (((uint32)shdr.Time[4]) << 24) | \ + (((uint32)shdr.Time[5]) << 16) | \ + (((uint32)shdr.Time[6]) << 8) | \ + ((uint32)shdr.Time[7]) +#endif + + + +/********************************************************************** +** Macros for extracting fields from a stream ID. All of the macros +** are used in a similar way: +** +** CCSDS_SID_xxx(sid) -- Extract field xxx from sid. +**********************************************************************/ + +/* Extract application ID from stream ID. */ +#define CCSDS_SID_APID(sid) CCSDS_RD_BITS(sid, 0x07FF, 0) + +/* Extract secondary header flag from stream ID. */ +#define CCSDS_SID_SHDR(sid) CCSDS_RD_BITS(sid, 0x0800, 11) + +/* Extract packet type (0=TLM,1=CMD) from stream ID. */ +#define CCSDS_SID_TYPE(sid) CCSDS_RD_BITS(sid, 0x1000, 12) + +/* Extract CCSDS version from stream ID. */ +#define CCSDS_SID_VERS(sid) CCSDS_RD_BITS(sid, 0xE000, 13) + + +/********************************************************************** +** Macros for frequently used combinations of operations. +** +** CCSDS_INC_SEQ(phdr) -- Increment sequence count. +**********************************************************************/ + +/* Increment sequence count in primary header by 1. */ +#define CCSDS_INC_SEQ(phdr) \ + CCSDS_WR_SEQ(phdr, (CCSDS_RD_SEQ(phdr)+1)) + + +/*********************************************************************/ + +/* +** Exported Functions +*/ + +/****************************************************************************** +** Function: CCSDS_InitPkt() +** +** Purpose: +** Initialize a CCSDS packet. The primary header is initialized with +** specified values, and if the Clear flag is set, the rest of the packet +** is filled with zeros. +** +** Arguments: +** PktPtr : Pointer to primary header of packet. +** StreamId : Stream ID to use for the packet. +** Length : Length of the packet in bytes. +** Clear : Indicates whether to clear the entire packet: +** TRUE = fill sequence count and packet data with zeros +** (used after a cold restart) +** FALSE = leave sequence count and packet data unchanged +** (used after a warm restart if data must be preserved) +** +** Return: +** (none) +*/ + +void CCSDS_InitPkt (CCSDS_PriHdr_t *PktPtr, + uint16 StreamId, + uint16 Length, + boolean Clear ); + + + +/****************************************************************************** +** Function: CCSDS_LoadCheckSum() +** +** Purpose: +** Compute and load a checksum for a CCSDS command packet that has a +** secondary header. +** +** Arguments: +** PktPtr : Pointer to header of command packet. The packet must +** have a secondary header and the length in the primary +** header must be correct. The checksum field in the packet +** will be modified. +** +** Return: +** (none) +*/ + +void CCSDS_LoadCheckSum (CCSDS_CmdPkt_t *PktPtr); + +/****************************************************************************** +** Function: CCSDS_ValidCheckSum() +** +** Purpose: +** Determine whether a checksum in a command packet is valid. +** +** Arguments: +** PktPtr : Pointer to header of command packet. The packet must +** have a secondary header and the length in the primary +** header must be correct. +** +** Return: +** TRUE if checksum of packet is valid; FALSE if not. +** A valid checksum is 0. +*/ + +boolean CCSDS_ValidCheckSum (CCSDS_CmdPkt_t *PktPtr); + +/****************************************************************************** +** Function: CCSDS_ComputeCheckSum() +** +** Purpose: +** Compute the checksum for a command packet. The checksum is the XOR of +** all bytes in the packet; a valid checksum is zero. +** +** Arguments: +** PktPtr : Pointer to header of command packet. The packet must +** have a secondary header and the length in the primary +** header must be correct. +** +** Return: +** TRUE if checksum of packet is valid; FALSE if not. +*/ + +uint8 CCSDS_ComputeCheckSum (CCSDS_CmdPkt_t *PktPtr); + + +#endif /* _ccsds_ */ +/*****************************************************************************/ diff --git a/src/components/interface/cFE/cfe.h b/src/components/interface/cFE/cfe.h new file mode 100644 index 0000000000..3f050d5155 --- /dev/null +++ b/src/components/interface/cFE/cfe.h @@ -0,0 +1,81 @@ +/* +** $Id: cfe.h 1.4 2010/10/25 14:01:09GMT-05:00 jmdagost Exp $ +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Purpose: cFE header file +** +** Author: David Kobe, the Hammers Company, Inc. +** +** Notes: This header file centralizes the includes for all cFE +** Applications. It includes all header files necessary +** to completely define the cFE interface. +** +** $Log: cfe.h $ +** Revision 1.4 2010/10/25 14:01:09GMT-05:00 jmdagost +** Corrected bad apostrophe in prologue. +** Revision 1.3 2010/10/04 15:24:39EDT jmdagost +** Cleaned up copyright symbol. +** Revision 1.2 2009/06/10 13:28:30EDT acudmore +** added cfe_psp.h include +** Revision 1.1 2008/04/17 08:05:18EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.4 2006/06/08 14:28:31EDT David Kobe (dlkobe) +** Added NASA Open Source Legal Statement +** Revision 1.3 2005/11/04 15:27:51GMT-05:00 rjmcgraw +** Added cfe_tbl.h +** Revision 1.2 2005/07/05 10:57:21EDT lswalling +** add cfe_error.h to included header files +** Revision 1.1 2005/06/09 10:57:50EDT rperera +** Initial revision +** Member added to project d:/mksdata/MKS-CFE-REPOSITORY/cfe-core/inc/project.pj +** Revision 1.1 2005/04/28 19:30:28 swalling +** initial version +** +*/ + +/*************************************************************************/ + +/* +** Ensure that header is included only once... +*/ +#ifndef _cfe_ +#define _cfe_ + +#include "common_types.h" /* Define basic data types */ + +#include "osapi.h" /* Define OS API function prototypes */ + +#include "cfe_mission_cfg.h" /* Define mission configuration parameters */ + +/* + * Note that the platform configuration is _not_ included with cfe.h anymore. + * + * Most applications should not depend on any of the #defines in that file. + * If an application truly does need a value from the platform config, then + * it can retrieve it from the mission data dictionary using a public API. + */ +#if !defined(_ENHANCED_BUILD_) +#include "cfe_platform_cfg.h" /* Define platform configuration parameters */ +#endif + +#include "cfe_msgids.h" /* Define common cFE Message IDs */ +#include "cfe_error.h" /* Define common cFE error codes */ + +#include "cfe_es.h" /* Define Executive Service API */ +#include "cfe_evs.h" /* Define Event Service API */ +#include "cfe_fs.h" /* Define File Service API */ +#include "cfe_sb.h" /* Define Software Bus API */ +#include "cfe_time.h" /* Define Time Service API */ +#include "cfe_tbl.h" /* Define Table Service API */ + +#include "cfe_psp.h" /* Define Platform Support Package API */ + +#endif /* _cfe_ */ diff --git a/src/components/interface/cFE/cfe_error.h b/src/components/interface/cFE/cfe_error.h new file mode 100644 index 0000000000..d1e9b745f1 --- /dev/null +++ b/src/components/interface/cFE/cfe_error.h @@ -0,0 +1,1317 @@ +/* +** +** Filename: cfe_error.h +** $Id: cfe_error.h 1.14 2014/05/30 13:23:19GMT-05:00 lwalling Exp $ +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Title: cFE Status Code Definition Header File +** +** Purpose: +** Common source of cFE API return status codes. +** +** Design Notes: +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** +** $Date: 2014/05/30 13:23:19GMT-05:00 $ +** $Revision: 1.14 $ +** $Log: cfe_error.h $ +** Revision 1.14 2014/05/30 13:23:19GMT-05:00 lwalling +** Added error code definition for CFE_EVS_EVT_NOT_REGISTERED +** Revision 1.13 2011/12/28 13:59:09EST lwalling +** Add definition for CFE_TBL_ERR_BAD_SPACECRAFT_ID and CFE_TBL_ERR_BAD_PROCESSOR_ID +** Revision 1.12 2011/11/30 15:42:21EST jmdagost +** Added cFE ES Task Delete Error code to list. +** Revision 1.11 2010/10/25 17:49:30EDT jmdagost +** Added FS Filename Length Error code, renumbered subsequent FS codes. +** Revision 1.10 2010/10/04 17:06:28EDT jmdagost +** Cleaned up copyright symbol. +** Revision 1.9 2009/07/29 15:55:18EDT aschoeni +** Added an error code for GetPoolBufInfo when the buffer is not in the pool +** Revision 1.8 2009/07/24 13:51:32EDT aschoeni +** Added SB_BUFFER_INVALID error type to support Zero Copy Mode +** Revision 1.7 2009/05/01 14:34:15EDT dkobe +** Added special note to CFE_TBL_ERR_NEVER_LOADED error code +** Revision 1.6 2009/05/01 14:26:32EDT dkobe +** Modified return code contents to emphasize success vs failure of API calls +** Revision 1.5 2008/12/08 12:06:59EST dkobe +** Updates to correct doxygen errors +** Revision 1.4 2008/08/27 16:58:29EDT apcudmore +** added error code for timer delete error in ES task cleanup +** Revision 1.3 2008/08/06 22:42:36EDT dkobe +** Added CFE_TIME_RegisterSynchCallback, CFE_TIME_UnregisterSynchCallback and CFE_TIME_CleanUpApp +** Revision 1.2 2008/06/20 15:40:32EDT apcudmore +** Added support for OSAL based module loader +** - Removed calls and references to the BSP based module loader +** Revision 1.1 2008/04/17 08:05:18EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.40 2007/05/25 16:24:49EDT David Kobe (dlkobe) +** Continued updating doxygen comments +** Revision 1.39 2007/05/25 11:57:50EDT apcudmore +** Added CFE_ES_APP_CLEANUP_ERR +** Revision 1.38 2007/05/23 11:22:01EDT dlkobe +** Added doxygen formatting +** Revision 1.37 2007/05/14 10:26:03EDT apcudmore +** Preserve the EVS Local event log on a processor restart: +** - moved the EVS Log to the ES reset data structure +** - Added a couple of EVS Log related variables into the EVS_Log_t structure +** - Added a routine to the EVS early init to get a pointer to the EVS Log +** - Added code to the EVS housekeeping service routine to copy Log variables into TLM +** Revision 1.36 2007/05/04 15:53:17EDT dlkobe +** Added error codes returned by CFE_ES_DeleteCDS function +** Revision 1.35 2007/04/28 14:48:59EDT dlkobe +** Baseline Implementation of Critical Tables +** Revision 1.32 2007/04/04 16:06:39EDT dlkobe +** Made numerous changes to correct issues identified during ES code walkthrough +** Revision 1.30 2007/03/23 10:47:22EST apcudmore +** Added CFE_ES_GetTaskInfo call and corresponding CFE_ES_TaskInfo_t data structure. +** +**/ + +/* +** Ensure that header is included only once... +*/ +#ifndef _cfe_error_ +#define _cfe_error_ + +/* Include Files */ +#include "osapi.h" + +/* +** Status Codes are 32 bit values formatted as follows: +** +** 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +** 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +** +---+---+-----+-----------------+-------------------------------+ +** |Sev| R | Srv | Mission Defined | Code | +** +---+---+-----+-----------------+-------------------------------+ +** +** where +** +** Sev - is the severity code +** +** 00 - Success +** 01 - Informational +** 11 - Error +** +** R - are reserved bits +** +** Srv - is the cFE Service Identifier +** +** 000 - Not a cFE Service +** 001 - Events Services +** 010 - Executive Services +** 011 - File Services +** 100 - OS API Services +** 101 - Software Bus Services +** 110 - Tables Services +** 111 - Time Services +** +** +** Mission Defined - These bits are available for Mission +** specific coding standards. They can +** be used to classify error codes related +** to mission specific library function calls, etc. +** +** Code - is the status code +*/ + + +/* +** Error Severity +*/ +#define CFE_SEVERITY_BITMASK ((int32)0xc0000000) + +#define CFE_SEVERITY_SUCCESS ((int32)0x00000000) +#define CFE_SEVERITY_INFO ((int32)0x40000000) +#define CFE_SEVERITY_ERROR ((int32)0xc0000000) + +/* +** cFE Service Identifiers +*/ +#define CFE_SERVICE_BITMASK ((int32)0x0e000000) + +#define CFE_EVENTS_SERVICE ((int32)0x02000000) +#define CFE_EXECUTIVE_SERVICE ((int32)0x04000000) +#define CFE_FILE_SERVICE ((int32)0x06000000) +#define CFE_OSAPI_SERVICE ((int32)0x08000000) +#define CFE_SOFTWARE_BUS_SERVICE ((int32)0x0a000000) +#define CFE_TABLE_SERVICE ((int32)0x0c000000) +#define CFE_TIME_SERVICE ((int32)0x0e000000) + +/* +************* COMMON STATUS CODE ************* +*/ + +/** +** Operation was performed successfully +*/ +#define CFE_SUCCESS (0) + +/* +************* EVENTS SERVICES STATUS CODES ************* +*/ + +/** +** #CFE_EVS_Register() FilterScheme parameter was illegal +** +*/ +#define CFE_EVS_UNKNOWN_FILTER ((int32)0xc2000001) + +/** +** Calling application never previously called #CFE_EVS_Register() +** +*/ +#define CFE_EVS_APP_NOT_REGISTERED ((int32)0xc2000002) + +/** +** Application ID returned by #CFE_ES_GetAppIDByName is greater +** than #CFE_ES_MAX_APPLICATIONS +** +*/ +#define CFE_EVS_APP_ILLEGAL_APP_ID ((int32)0xc2000003) + +/** +** Number of Application event filters input upon +** registration is greater than #CFE_EVS_MAX_EVENT_FILTERS +** +*/ +#define CFE_EVS_APP_FILTER_OVERLOAD ((int32)0xc2000004) + +/** +** Could not get pointer to the ES Reset area, so we could +** not get the pointer to the EVS Log. +** +*/ +#define CFE_EVS_RESET_AREA_POINTER ((int32)0xc2000005) + + +/** +** #CFE_EVS_ResetFilter() EventID argument was not found in +** any event filter registered by the calling application. +** +*/ +#define CFE_EVS_EVT_NOT_REGISTERED ((int32)0xc2000006) + + +/** +** Current version of cFE does not have the function or the feature +** of the function implemented. This could be due to either an early +** build of the cFE for this platform or the platform does not support +** the specified feature. +** +*/ +#define CFE_EVS_NOT_IMPLEMENTED ((int32)0xc200ffff) + +/* +************* EXECUTIVE SERVICES STATUS CODES ************* +*/ + +/** +** The given application ID does not reflect a currently active application. +** +*/ +#define CFE_ES_ERR_APPID ((int32)0xc4000001) + +/** +** There is no match for the given application name in the current application list. +** +*/ +#define CFE_ES_ERR_APPNAME ((int32)0xc4000002) + +/** +** Invalid pointer argument (NULL) +** +*/ +#define CFE_ES_ERR_BUFFER ((int32)0xc4000003) + +/** +** There was an error loading or creating the App. +** +*/ +#define CFE_ES_ERR_APP_CREATE ((int32)0xc4000004) + +/** +** There was an error creating a child task. +** +*/ +#define CFE_ES_ERR_CHILD_TASK_CREATE ((int32)0xc4000005) + +/** +** The cFE system Log is full. +** +*/ +#define CFE_ES_ERR_SYS_LOG_FULL ((int32)0xc4000006) + +/** +** The Memory Pool handle is invalid. +** +*/ +#define CFE_ES_ERR_MEM_HANDLE ((int32)0xc4000007) + +/** +** The block size requested is invalid. +** +*/ +#define CFE_ES_ERR_MEM_BLOCK_SIZE ((int32)0xc4000008) + +/** +** Could not load the shared library. +** +*/ +#define CFE_ES_ERR_LOAD_LIB ((int32)0xc4000009) + +/** +** Bad parameter passed into an ES API. +** +*/ +#define CFE_ES_BAD_ARGUMENT ((int32)0xc400000a) + +/** +** Errors occured when trying to register a child task. +** +*/ +#define CFE_ES_ERR_CHILD_TASK_REGISTER ((int32)0xc400000b) + +/** +** Error occured ehen trying to pass a system call to the OS shell +** +*/ +#define CFE_ES_ERR_SHELL_CMD ((int32)0xc400000c) + +/** +** The Application is receiving the pointer to a CDS that was already present. +** +*/ +#define CFE_ES_CDS_ALREADY_EXISTS ((int32)0x4400000d) + + +/** +** The Application is requesting a CDS Block that is larger than the remaining +** CDS memory. +** +*/ +#define CFE_ES_CDS_INSUFFICIENT_MEMORY ((int32)0xc400000e) + + +/** +** The Application is requesting a CDS Block with an invalid ASCII string name. +** Either the name is too long (> #CFE_ES_CDS_MAX_NAME_LENGTH) or was an empty string. +** +*/ +#define CFE_ES_CDS_INVALID_NAME ((int32)0xc400000f) + + +/** +** The Application is requesting a CDS Block with a size of zero. +** +*/ +#define CFE_ES_CDS_INVALID_SIZE ((int32)0xc4000010) + + +/** +** The CDS Registry has as many entries in it as it can hold. The +** CDS Registry size can be adjusted with the #CFE_ES_CDS_MAX_NUM_ENTRIES +** macro defined in the cfe_platform_cfg.h file. +** +*/ +#define CFE_ES_CDS_REGISTRY_FULL ((int32)0xc4000011) + + +/** +** The CDS contents are invalid. +** +*/ +#define CFE_ES_CDS_INVALID ((int32)0xc4000012) + + +/** +** The CDS was inaccessible +** +*/ +#define CFE_ES_CDS_ACCESS_ERROR ((int32)0xc4000013) + + +/** +** Occurs when a file operation fails +** +*/ +#define CFE_ES_FILE_IO_ERR ((int32)0xc4000014) + + +/** +** Occurs when the BSP is not successful in returning the reset area address. +** +*/ +#define CFE_ES_RST_ACCESS_ERR ((int32)0xc4000015) + +/** +** Occurs when the Task ID passed into #CFE_ES_GetTaskInfo is invalid. +** +*/ +#define CFE_ES_ERR_TASKID ((int32)0xc4000016) + +/** +** Occurs when the #CFE_ES_RegisterApp fails. +** +*/ +#define CFE_ES_ERR_APP_REGISTER ((int32)0xc4000017) + +/** +** There was an error deleting a child task. +** +*/ +#define CFE_ES_ERR_CHILD_TASK_DELETE ((int32)0xc4000018) + +/** +** There was an attempt to delete a cFE App Main Task with +** the #CFE_ES_DeleteChildTask API. +** +*/ +#define CFE_ES_ERR_CHILD_TASK_DELETE_MAIN_TASK ((int32)0xc4000019) + +/** +** Occurs when trying to read a CDS Data block and the CRC of the current +** data does not match the stored CRC for the data. Either the contents of +** the CDS Data Block are corrupted or the CDS Control Block is corrupted. +** +*/ +#define CFE_ES_CDS_BLOCK_CRC_ERR ((int32)0xc400001A) + +/** +** Occurs when trying to delete a Mutex that belongs to a task that ES +** is cleaning up. +** +*/ +#define CFE_ES_MUT_SEM_DELETE_ERR ((int32)0xc400001B) + + +/** +** Occurs when trying to delete a Binary Semaphore that belongs to a task that ES +** is cleaning up. +** +*/ +#define CFE_ES_BIN_SEM_DELETE_ERR ((int32)0xc400001C) + +/** +** Occurs when trying to delete a Counting Semaphore that belongs to a task that ES +** is cleaning up. +** +*/ +#define CFE_ES_COUNT_SEM_DELETE_ERR ((int32)0xc400001D) + +/** +** Occurs when trying to delete a Queue that belongs to a task that ES +** is cleaning up. +** +*/ +#define CFE_ES_QUEUE_DELETE_ERR ((int32)0xc400001E) + +/** +** Occurs when trying to close a file that belongs to a task that ES +** is cleaning up. +** +*/ +#define CFE_ES_FILE_CLOSE_ERR ((int32)0xc400001F) + +/** +** Occurs when Table Services is trying to delete a Critical Data Store that +** is not a Critical Table Image or when Executive Services is trying to delete +** a Critical Table Image. +** +*/ +#define CFE_ES_CDS_WRONG_TYPE_ERR ((int32)0xc4000020) + +/** +** Occurs when a search of the Critical Data Store Registry does not find a +** critical data store with the specified name. +** +*/ +#define CFE_ES_CDS_NOT_FOUND_ERR ((int32)0xc4000021) + +/** +** Occurs when an attempt was made to delete a CDS when an application +** with the same name associated with the CDS is still present. CDSs +** can ONLY be deleted when Applications that created them are not present +** in the system. +** +*/ +#define CFE_ES_CDS_OWNER_ACTIVE_ERR ((int32)0xc4000022) + + +/** +** Occurs when an attempt was made to Clean Up an application +** which involves calling Table, EVS, and SB cleanup functions, then +** deleting all ES resources, child tasks, and unloading the +** object module. The approach here is to keep going even though one +** of these steps had an error. There will be syslog messages detailing +** each problem. +** +*/ +#define CFE_ES_APP_CLEANUP_ERR ((int32)0xc4000023) + +/** +** Occurs when trying to delete a Timer that belongs to a task that ES +** is cleaning up. +** +*/ +#define CFE_ES_TIMER_DELETE_ERR ((int32)0xc4000024) + +/** +** The specified address is not in the memory pool. +** +*/ +#define CFE_ES_BUFFER_NOT_IN_POOL ((int32)0xc4000025) + + +/** +** Occurs when trying to delete a task that ES +** is cleaning up. +** +*/ +#define CFE_ES_TASK_DELETE_ERR ((int32)0xc4000026) + +/** +** Occurs if the timeout for a given operation was exceeded +** +*/ +#define CFE_ES_OPERATION_TIMED_OUT ((int32)0xc4000027) + + +/** +** Current version of cFE does not have the function or the feature +** of the function implemented. This could be due to either an early +** build of the cFE for this platform or the platform does not support +** the specified feature. +** +*/ +#define CFE_ES_NOT_IMPLEMENTED ((int32)0xc400ffff) + + +/* +************* FILE SERVICES STATUS CODES ************* +*/ + +/* +** A parameter given by a caller to a File Services API did not pass +** validation checks. +** +*/ +#define CFE_FS_BAD_ARGUMENT ((int32)0xc6000001) + +/* +** FS was unable to extract a filename from a path string +** +*/ +#define CFE_FS_INVALID_PATH ((int32)0xc6000002) + +/* +** FS filename string is too long +** +*/ +#define CFE_FS_FNAME_TOO_LONG ((int32)0xc6000003) + +/* +** The GZIP file contains invalid data and cannot be read +*/ +#define CFE_FS_GZIP_BAD_DATA ((int32)0xc6000004) + +/* +** The GZIP file codeblock is bad, which means the file is +** most likely corrupted +*/ +#define CFE_FS_GZIP_BAD_CODE_BLOCK ((int32)0xc6000005) + +/* +** The memory buffer used by the decompression routine is +** exhausted. +*/ +#define CFE_FS_GZIP_NO_MEMORY ((int32)0xc6000006) + +/* +** There is a CRC error in the GZIP file, which means the +** file is most likely corrupted. +*/ +#define CFE_FS_GZIP_CRC_ERROR ((int32)0xc6000007) + +/* +** There is a length error in the GZIP internal data +** structures, which means the file is most likely corrupted. +*/ +#define CFE_FS_GZIP_LENGTH_ERROR ((int32)0xc6000008) + +/* +** An error occurred trying to write the uncompressed +** file. +*/ +#define CFE_FS_GZIP_WRITE_ERROR ((int32)0xc6000009) + +/* +** An error occurred trying to read the GZIP file +*/ +#define CFE_FS_GZIP_READ_ERROR ((int32)0xc600000A) + +/* +** An error occurred trying to open the DestinationFile +** where the GZIP file will be uncompressed. The +** function must be able to open a new write-only file to +** store the uncompressed file in. +*/ +#define CFE_FS_GZIP_OPEN_OUTPUT ((int32)0xc600000B) + +/* +** An error occurred trying to open the GZIP file +** to be decompressed. The function must be able to open +** the GZIP file as read-only in order to decompress it +** to a new file ( most likely in a RAM disk ) +*/ +#define CFE_FS_GZIP_OPEN_INPUT ((int32)0xc600000C) + +/* +** An error occured trying to read the GZIP file header, +** which means the file is most likely corrupted or +** not a valid GZIP file. +*/ +#define CFE_FS_GZIP_READ_ERROR_HEADER ((int32)0xc600000D) + +/* +** An error occurred trying to read the GZIP index, +** which means the file is most likely corrupted. +*/ +#define CFE_FS_GZIP_INDEX_ERROR ((int32)0xc600000E) + +/* +** The file to be decompressed is not a valid GZIP file +*/ +#define CFE_FS_GZIP_NON_ZIP_FILE ((int32)0xc600000F) + +/** +** Current version of cFE does not have the function or the feature +** of the function implemented. This could be due to either an early +** build of the cFE for this platform or the platform does not support +** the specified feature. +** +*/ +#define CFE_FS_NOT_IMPLEMENTED ((int32)0xc600ffff) + +/* +************* OSAPI STATUS CODES ************* +*/ + +/** +** +** +*/ +#define CFE_OS_ERROR (OS_ERROR) + +/** +** +** +*/ +#define CFE_OS_INVALID_POINTER (OS_INVALID_POINTER) + +/** +** +** +*/ +#define CFE_OS_ERROR_ADDRESS_MISALIGNED (OS_ERROR_ADDRESS_MISALIGNED) + +/** +** +** +*/ +#define CFE_OS_ERROR_TIMEOUT (OS_ERROR_TIMEOUT) + +/** +** +** +*/ +#define CFE_OS_INVALID_INT_NUM (OS_INVALID_INT_NUM) + +/** +** +** +*/ +#define CFE_OS_SEM_FAILURE (OS_SEM_FAILURE) + +/** +** +** +*/ +#define CFE_OS_SEM_TIMEOUT (OS_SEM_TIMEOUT) + +/** +** +** +*/ +#define CFE_OS_QUEUE_EMPTY (OS_QUEUE_EMPTY) + +/** +** +** +*/ +#define CFE_OS_QUEUE_FULL (OS_QUEUE_FULL) + +/** +** +** +*/ +#define CFE_OS_QUEUE_TIMEOUT (OS_QUEUE_TIMEOUT) + +/** +** +** +*/ +#define CFE_OS_QUEUE_INVALID_SIZE (OS_QUEUE_INVALID_SIZE) + +/** +** +** +*/ +#define CFE_OS_QUEUE_ID_ERROR (OS_QUEUE_ID_ERROR) + +/** +** +** +*/ +#define CFE_OS_ERR_NAME_TOO_LONG (OS_ERR_NAME_TOO_LONG) + +/** +** +** +*/ +#define CFE_OS_ERR_NO_FREE_IDS (OS_ERR_NO_FREE_IDS) + +/** +** +** +*/ +#define CFE_OS_ERR_NAME_TAKEN (OS_ERR_NAME_TAKEN) + +/** +** +** +*/ +#define CFE_OS_ERR_INVALID_ID (OS_ERR_INVALID_ID) + +/** +** +** +*/ +#define CFE_OS_ERR_NAME_NOT_FOUND (OS_ERR_NAME_NOT_FOUND) + +/** +** +** +*/ +#define CFE_OS_ERR_SEM_NOT_FULL (OS_ERR_SEM_NOT_FULL) + +/** +** +** +*/ +#define CFE_OS_ERR_INVALID_PRIORITY (OS_ERR_INVALID_PRIORITY) + +/** +** +** +*/ +#define CFE_OS_ERROR_TASK_ID (OS_ERROR_TASK_ID) + +/** +** +** +*/ +#define CFE_OS_SEM_UNAVAILABLE (OS_SEM_UNAVAILABLE) + +/** +** +** +*/ +#define CFE_OS_FS_ERROR (OS_FS_ERROR) + +/** +** +** +*/ +#define CFE_OS_FS_ERR_INVALID_POINTER (OS_FS_ERR_INVALID_POINTER) + +/** +** +** +*/ +#define CFE_OS_FS_ERR_PATH_TOO_LONG (OS_FS_ERR_PATH_TOO_LONG) + +/** +** +** +*/ +#define CFE_OS_FS_ERR_NAME_TOO_LONG (OS_FS_ERR_NAME_TOO_LONG) + +/** +** +** +*/ +#define CFE_OS_FS_ERR_DRIVE_NOT_CREATED (OS_FS_ERR_DRIVE_NOT_CREATED) + +/** +** Current version of cFE does not have the function or the feature +** of the function implemented. This could be due to either an early +** build of the cFE for this platform or the platform does not support +** the specified feature. +** +*/ +#define CFE_OSAPI_NOT_IMPLEMENTED (OS_FS_UNIMPLEMENTED) + +/* +************* SOFTWARE BUS SERVICES STATUS CODES ************* +*/ + +/** +** In #CFE_SB_RcvMsg, this return value indicates that a packet has not +** been received in the time given in the "timeout" parameter. +** +*/ +#define CFE_SB_TIME_OUT ((int32)0xca000001) + + +/** +** When "Polling" a pipe for a message in #CFE_SB_RcvMsg, this return +** value indicates that there was not a message on the pipe. +** +*/ +#define CFE_SB_NO_MESSAGE ((int32)0xca000002) + + +/** +** A parameter given by a caller to a Software Bus API did not pass +** validation checks. +** +*/ +#define CFE_SB_BAD_ARGUMENT ((int32)0xca000003) + + +/** +** This error code will be returned from #CFE_SB_CreatePipe when the +** SB cannot accomodate the request to create a pipe because the maximum +** number of pipes (#CFE_SB_MAX_PIPES) are in use. This configuration +** parameter is defined in the cfe_platform_cfg.h file. +** +*/ +#define CFE_SB_MAX_PIPES_MET ((int32)0xca000004) + + +/** +** The maximum number of queues(#OS_MAX_QUEUES) are in use. Or possibly a +** lower level problem with creating the underlying queue has occurred +** such as a lack of memory. If the latter is the problem, the status +** code displayed in the event must be tracked. +** +*/ +#define CFE_SB_PIPE_CR_ERR ((int32)0xca000005) + + +/** +** This return value indicates an error at the Queue read level. This +** error typically cannot be corrected by the caller. Some possible +** causes are: queue was not properly initialized or created, the number +** of bytes read from the queue was not the number of bytes requested in +** the read. The queue id is invalid. Similar errors regarding the pipe +** will be caught by higher level code in the Software Bus. +** +*/ +#define CFE_SB_PIPE_RD_ERR ((int32)0xca000006) + + +/** +** The size field in the message header indicates the message exceeds the +** max Software Bus message size. The max size is defined by +** configuration parameter #CFE_SB_MAX_SB_MSG_SIZE in cfe_mission_cfg.h +** +*/ +#define CFE_SB_MSG_TOO_BIG ((int32)0xca000007) + + +/** +** This error code will be returned from #CFE_SB_SendMsg when the memory +** in the SB message buffer pool has been depleted. The amount of memory +** in the pool is dictated by the configuration parameter +** #CFE_SB_BUF_MEMORY_BYTES specified in the cfe_platform_cfg.h file. Also +** the memory statistics, including current utilization figures and high +** water marks for the SB Buffer memory pool can be monitored by sending +** a Software Bus command to send the SB statistics packet. +** +*/ +#define CFE_SB_BUF_ALOC_ERR ((int32)0xca000008) + + +/** +** Will be returned when calling one of the SB subscription API's if the +** SB routing table cannot accomodate another unique message ID because +** the platform configuration parameter #CFE_SB_MAX_MSG_IDS has been met. +** +*/ +#define CFE_SB_MAX_MSGS_MET ((int32)0xca000009) + + +/** +** Will be returned when calling one of the SB subscription API's if the +** SB routing table cannot accomodate another destination for a +** particular the given message ID. This occurs when the number of +** destinations in use meets the platform configuration parameter +** #CFE_SB_MAX_DEST_PER_PKT. +** +*/ +#define CFE_SB_MAX_DESTS_MET ((int32)0xca00000a) + + +/** +** This error code is returned by the #CFE_SB_Unsubscribe API if there has +** not been an entry in the routing tables for the MsgId/PipeId given as +** parameters. +*/ +#define CFE_SB_NO_SUBSCRIBERS ((int32)0xca00000b) + + +/** +** This error code will be returned by the #CFE_SB_Subscribe API if the +** code detects an internal index is out of range. The most likely +** cause would be a Single Event Upset. +** +*/ +#define CFE_SB_INTERNAL_ERR ((int32)0xca00000c) + + +/** +** This error code will be returned when a request such as ...SetMsgTime +** is made on a packet that does not include a field for msg time. +** +*/ +#define CFE_SB_WRONG_MSG_TYPE ((int32)0xca00000d) + + +/** +** This error code will be returned when a request to release or send a +** zero copy buffer is invalid, such as if the handle or buffer is not +** correct or the buffer was previously released. +** +*/ +#define CFE_SB_BUFFER_INVALID ((int32)0xca00000e) + + +/** +** Current version of cFE does not have the function or the feature +** of the function implemented. This could be due to either an early +** build of the cFE for this platform or the platform does not support +** the specified feature. +** +*/ +#define CFE_SB_NOT_IMPLEMENTED ((int32)0xca00ffff) + +/* +************* TABLE SERVICES STATUS CODES ************* +*/ + +/** +** The calling Application attempted to pass a +** Table handle that represented too large an index or +** identified a Table Access Descriptor that was not used. +** +*/ +#define CFE_TBL_ERR_INVALID_HANDLE ((int32)0xcc000001) + +/** +** The calling Application attempted to register a table whose +** name length exceeded the platform configuration value of +** #CFE_TBL_MAX_NAME_LENGTH or was zero characters long. +** +*/ +#define CFE_TBL_ERR_INVALID_NAME ((int32)0xcc000002) + +/** +** The calling Application attempted to register a table: +** a) that was a double buffered table with size greater than #CFE_TBL_MAX_DBL_TABLE_SIZE +** b) that was a single buffered table with size greater than #CFE_TBL_MAX_SNGL_TABLE_SIZE +** c) that had a size of zero +** +*/ +#define CFE_TBL_ERR_INVALID_SIZE ((int32)0xcc000003) + +/** +** The calling Application has identified a table that has a load pending. +** +*/ +#define CFE_TBL_INFO_UPDATE_PENDING ((int32)0x4c000004) + +/** +** This is an error indicating that the table has never been loaded from +** either a file or a copy from a block of memory so the contents that the +** returned pointer is pointing to are zeros. +** NOTE: Unlike other most other errors, this error condition still +** returns a valid table pointer. This pointer must be released with the +** #CFE_TBL_ReleaseAddress API before the table can be loaded with data. +** +*/ +#define CFE_TBL_ERR_NEVER_LOADED ((int32)0xcc000005) + +/** +** An application attempted to create a table and the Table +** registry already contained #CFE_TBL_MAX_NUM_TABLES in it. +** +*/ +#define CFE_TBL_ERR_REGISTRY_FULL ((int32)0xcc000006) + +/** +** This is an error that the registration is trying to replace +** an existing table with the same name. The previous table +** stays in place and the new table is rejected. +** +*/ +#define CFE_TBL_WARN_DUPLICATE ((int32)0x4c000007) + +/** +** The calling application either failed when calling #CFE_TBL_Register, +** failed when calling #CFE_TBL_Share or forgot to call either one. +** +*/ +#define CFE_TBL_ERR_NO_ACCESS ((int32)0xcc000008) + +/** +** The calling application is trying to access a table that has +** been unregistered. +** +*/ +#define CFE_TBL_ERR_UNREGISTERED ((int32)0xcc000009) + +/** +** The calling application does not have a legitimate Application ID. +** Most likely cause is a failure to register with the cFE via the +** #CFE_ES_RegisterApp function. +** +*/ +#define CFE_TBL_ERR_BAD_APP_ID ((int32)0xcc00000A) + +/** +** An application attempted to create a table and the Table +** Handle Array already used all CFE_TBL_MAX_NUM_HANDLES in it. +** +*/ +#define CFE_TBL_ERR_HANDLES_FULL ((int32)0xcc00000B) + +/** +** An application attempted to register a table with the same name +** as a table that is already in the registry. The size of the new +** table is different from the size already in the registry. +** +*/ +#define CFE_TBL_ERR_DUPLICATE_DIFF_SIZE ((int32)0xcc00000C) + +/** +** An application attempted to register a table with the same name +** as a table that is already in the registry. The previously registered +** table is owned by a different application. +** +*/ +#define CFE_TBL_ERR_DUPLICATE_NOT_OWNED ((int32)0xcc00000D) + +/** +** The calling Application has identified a table that has been updated.
+** \b NOTE: This is a nominal return code informing the calling application +** that the table identified in the call has had its contents updated since +** the last time the application obtained its address or status. +** +*/ +#define CFE_TBL_INFO_UPDATED ((int32)0x4c00000E) + +/** +** The calling Application has tried to allocate a working buffer but +** none were available. +** +*/ +#define CFE_TBL_ERR_NO_BUFFER_AVAIL ((int32)0xcc00000F) + +/** +** The calling Application has attempted to perform a load on a +** table that was created with "Dump Only" attributes. +** +*/ +#define CFE_TBL_ERR_DUMP_ONLY ((int32)0xcc000010) + +/** +** The calling Application called #CFE_TBL_Load with an illegal +** value for the second parameter. +** +*/ +#define CFE_TBL_ERR_ILLEGAL_SRC_TYPE ((int32)0xcc000011) + +/** +** The calling Application called #CFE_TBL_Load when another Application +** was trying to load the table. +** +*/ +#define CFE_TBL_ERR_LOAD_IN_PROGRESS ((int32)0xcc000012) + +/** +** The calling Application called #CFE_TBL_Load with a bad filename. +** +*/ +#define CFE_TBL_ERR_FILE_NOT_FOUND ((int32)0xcc000013) + +/** +** The calling Application called #CFE_TBL_Load with a filename that specified a file +** that contained more data than the size of the table OR which contained more data +** than specified in the table header. +** +*/ +#define CFE_TBL_ERR_FILE_TOO_LARGE ((int32)0xcc000014) + +/** +** The calling Application called #CFE_TBL_Load with a filename that specified a file +** that started with the first byte of the table but contained less data than the size of the table. +** It should be noted that #CFE_TBL_WARN_PARTIAL_LOAD also indicates a partial load (one that starts +** at a non-zero offset). +** +*/ +#define CFE_TBL_WARN_SHORT_FILE ((int32)0x4c000015) + +/** +** The calling Application called #CFE_TBL_Load with a filename that specified a file +** whose content ID was not that of a table image. +** +*/ +#define CFE_TBL_ERR_BAD_CONTENT_ID ((int32)0xcc000016) + +/** +** The calling Application has attempted to update a table without a pending load. +** +*/ +#define CFE_TBL_INFO_NO_UPDATE_PENDING ((int32)0x4c000017) + +/** +** The calling Application tried to update a table that is locked by another user. +** +*/ +#define CFE_TBL_INFO_TABLE_LOCKED ((int32)0x4c000018) + +/** +** The calling Application should call #CFE_TBL_Validate for the specified table. +** +*/ +#define CFE_TBL_INFO_VALIDATION_PENDING ((int32)0x4c000019) + +/** +** The calling Application tried to validate a table that did not have a validation request pending. +** +*/ +#define CFE_TBL_INFO_NO_VALIDATION_PENDING ((int32)0x4c00001A) + +/** +** The calling Application tried to access a table file whose Subtype identifier indicated it was not +** a table image file. +** +*/ +#define CFE_TBL_ERR_BAD_SUBTYPE_ID ((int32)0xcc00001B) + +/** +** The calling Application tried to access a table file whose Subtype identifier indicated it was not +** a table image file. +** +*/ +#define CFE_TBL_ERR_FILE_SIZE_INCONSISTENT ((int32)0xcc00001C) + +/** +** The calling Application tried to access a table file whose standard cFE File Header was the wrong size, etc. +** +*/ +#define CFE_TBL_ERR_NO_STD_HEADER ((int32)0xcc00001D) + +/** +** The calling Application tried to access a table file whose standard cFE +** Table File Header was the wrong size, etc. +** +*/ +#define CFE_TBL_ERR_NO_TBL_HEADER ((int32)0xcc00001E) + + +/** +** The calling Application tried to load a table using a filename +** that was too long. +** +*/ +#define CFE_TBL_ERR_FILENAME_TOO_LONG ((int32)0xcc00001F) + + +/** +** The calling Application tried to load a table using a file whose +** header indicated that it was for a different table. +** +*/ +#define CFE_TBL_ERR_FILE_FOR_WRONG_TABLE ((int32)0xcc000020) + + +/** +** The calling Application tried to load a table file whose header +** claimed the load was larger than what was actually read from the file. +** +*/ +#define CFE_TBL_ERR_LOAD_INCOMPLETE ((int32)0xcc000021) + + +/** +** The calling Application tried to load a table file whose header +** claimed the load did not start with the first byteIt should be noted +** that #CFE_TBL_WARN_SHORT_FILE also indicates a partial load. +** +*/ +#define CFE_TBL_WARN_PARTIAL_LOAD ((int32)0x4c000022) + + +/** +** The calling Application tried to load a table file whose header +** claimed the load did not start with the first byte and the table +** image had NEVER been loaded before. Partial loads are not allowed +** on uninitialized tables. It should be noted that +** #CFE_TBL_WARN_SHORT_FILE also indicates a partial load. +** +*/ +#define CFE_TBL_ERR_PARTIAL_LOAD ((int32)0xcc000023) + + +/** +** The calling Application should call #CFE_TBL_Manage for the specified table. +** The ground has requested a dump of the Dump-Only table and needs to synchronize +** with the owning application. +** +*/ +#define CFE_TBL_INFO_DUMP_PENDING ((int32)0x4c000024) + + +/** +** The calling Application has used an illegal combination of table options. +** A summary of the illegal combinations are as follows: +** \par #CFE_TBL_OPT_USR_DEF_ADDR cannot be combined with any of the following: +** -# #CFE_TBL_OPT_DBL_BUFFER +** -# #CFE_TBL_OPT_LOAD_DUMP +** -# #CFE_TBL_OPT_CRITICAL +** \par #CFE_TBL_OPT_DBL_BUFFER cannot be combined with the following: +** -# #CFE_TBL_OPT_USR_DEF_ADDR +** -# #CFE_TBL_OPT_DUMP_ONLY +** +*/ +#define CFE_TBL_ERR_INVALID_OPTIONS ((int32)0xcc000025) + + +/** +** The calling Application attempted to register a table as "Critical". +** Table Services failed to create an appropriate Critical Data Store +** (See System Log for reason) to save the table contents. The table +** will be treated as a normal table from now on. +** +*/ +#define CFE_TBL_WARN_NOT_CRITICAL ((int32)0x4c000026) + + +/** +** The calling Application registered a critical table whose previous +** contents were discovered in the Critical Data Store. The discovered +** contents were copied back into the newly registered table as the +** table's initial contents.
+** \b NOTE: In this situation, the contents of the table are \b NOT +** validated using the table's validation function. +** +*/ +#define CFE_TBL_INFO_RECOVERED_TBL ((int32)0x4c000027) + + +/** +** The selected table file failed validation for Spacecraft ID. +** The platform configuration file has verification of table files +** enabled for Spacecraft ID and an attempt was made to load a table +** with an invalid Spacecraft ID in the table file header. +** +*/ +#define CFE_TBL_ERR_BAD_SPACECRAFT_ID (int32)(0xcc000028L) + + +/** +** The selected table file failed validation for Processor ID. +** The platform configuration file has verification of table files +** enabled for Processor ID and an attempt was made to load a table +** with an invalid Processor ID in the table file header. +** +*/ +#define CFE_TBL_ERR_BAD_PROCESSOR_ID (int32)(0xcc000029L) + + +/** +** Current version of cFE does not have the function or the feature +** of the function implemented. This could be due to either an early +** build of the cFE for this platform or the platform does not support +** the specified feature. +** +*/ +#define CFE_TBL_NOT_IMPLEMENTED ((int32)0xcc00ffff) + + +/* +************* TIME SERVICES STATUS CODES ************* +*/ + +/** +** Current version of cFE does not have the function or the feature +** of the function implemented. This could be due to either an early +** build of the cFE for this platform or the platform does not support +** the specified feature. +** +*/ +#define CFE_TIME_NOT_IMPLEMENTED ((int32)0xce00ffff) + +/** +** One of the TIME Services API functions to set the time with data +** from an external time source has been called, but TIME Services +** has been commanded to not accept external time data. However, +** the command is still a signal for the Time Server to generate +** a "time at the tone" command packet using internal data. +** +*/ +#define CFE_TIME_INTERNAL_ONLY ((int32)0xce000001) + +/** +** One of the TIME Services API functions to set the time with data +** from an external time source has been called, but TIME Services +** has determined that the new time data is invalid. However, +** the command is still a signal for the Time Server to generate +** a "time at the tone" command packet using internal data. +** +** Note that the test for invalid time update data only occurs if TIME +** Services has previously been commanded to set the clock state +** to "valid". +*/ +#define CFE_TIME_OUT_OF_RANGE ((int32)0xce000002) + +/** +** An attempt to register too many cFE Time Services Synchronization +** callbacks has been made. Adjust the #CFE_TIME_MAX_NUM_SYNCH_FUNCS +** configuration parameter, recompile and try again. +** +*/ +#define CFE_TIME_TOO_MANY_SYNCH_CALLBACKS ((int32)0xce000003) + +/** +** An attempt to unregister a cFE Time Services Synchronization +** callback has failed because the specified callback function was not +** located in the Synchronization Callback Registry. +** +*/ +#define CFE_TIME_CALLBACK_NOT_REGISTERED ((int32)0xce000004) + +#endif /* _cfe_error_ */ diff --git a/src/components/interface/cFE/cfe_es.h b/src/components/interface/cFE/cfe_es.h new file mode 100644 index 0000000000..83c9ac43f1 --- /dev/null +++ b/src/components/interface/cFE/cfe_es.h @@ -0,0 +1,1604 @@ +/* +** +** File: +** cfe_es.h +** $Id: cfe_es.h 1.14 2014/08/19 13:32:01GMT-05:00 sstrege Exp $ +** +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** +** Purpose: +** Unit specification for Executive Services library functions and macros. +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** cFE Flight Software Application Developers Guide +** +** Notes: +** +** $Date: 2014/08/19 13:32:01GMT-05:00 $ +** $Revision: 1.14 $ +** $Log: cfe_es.h $ +** Revision 1.14 2014/08/19 13:32:01GMT-05:00 sstrege +** Fixed doxygen warnings +** Revision 1.13 2011/07/15 14:28:34EDT lwalling +** Removed const qualifier from CounterName argument to CFE_ES_RegisterGenCounter() +** Revision 1.12 2010/11/05 15:54:27EDT aschoeni +** Added Generic Counter API to ES +** Revision 1.11 2010/11/01 16:03:10EDT jmdagost +** Removed cfe.h from include list and added cfe_mission_cfg.h +** Revision 1.10 2010/10/20 12:35:43EDT jmdagost +** Major revision to make semaphore use in memory pool creation optional. +** Revision 1.9 2009/07/29 15:54:46EDT aschoeni +** Added GetPoolBufInfo function to return size or invalidity of a buffer in a pool +** Revision 1.8 2008/12/08 16:10:54EST dkobe +** Correcting errors generated during detailed design document generation +** Revision 1.7 2008/12/08 12:07:09EST dkobe +** Updates to correct doxygen errors +** Revision 1.6 2008/07/31 15:41:31EDT apcudmore +** Added execution counter API: +** -- Added execution counter to ES internal task data +** -- Added code to increment counter in RunLoop +** -- Added code to report counter in GetInfo APIs +** -- Added API to increment counter for child tasks +** -- Added code to cFE Core apps to increment counters. +** Revision 1.5 2008/07/30 14:53:57EDT apcudmore +** Added CFE_ES_WaitForStartupSync API +** Revision 1.4 2008/07/08 12:35:28EDT apcudmore +** Added an "AddressesAreValid" flag to the ES App Info structure. +** Revision 1.3 2008/06/26 15:41:51EDT apcudmore +** Added public CFE_ES_GetAppInfo API. +** Moved the old API to CFE_ES_GetAppInfoInternal +** -- May merge these two in the near future. +** Revision 1.2 2008/06/20 15:40:27EDT apcudmore +** Added support for OSAL based module loader +** - Removed calls and references to the BSP based module loader +** Revision 1.1 2008/04/17 08:05:19EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.58 2007/09/27 15:54:56EDT David Kobe (dlkobe) +** Added doxygen comments for commands and telemetry +** Revision 1.57 2007/09/25 10:24:05EDT apcudmore +** Implement Application Restart on Exception: +** - Added logic to Exception Handler +** - Changed Exception Hook to pass host task ID +** - Added App Reset ER Log entry type +** Revision 1.56 2007/09/21 15:40:15EDT David Kobe (dlkobe) +** Modified pointer type definitions to eliminate Linux gcc compile warnings +** Revision 1.55 2007/09/20 10:52:57EDT apcudmore +** Added Query All Tasks command, file definition, events, error codes etc. +** Revision 1.54 2007/09/12 16:06:09EDT David Kobe (dlkobe) +** Moved the definitions of CFE_ES_CRC_xx to the cfe_mission_cfg.h file and deleted TBL Services +** CRC #define statement. +** Revision 1.53 2007/08/31 14:11:05EDT apcudmore +** Updated reset subtypes ( trunk ) +** Revision 1.52 2007/08/07 12:52:40EDT dlkobe +** Modified CFE_ES_GetPoolBuf API's first parameter to be of type uint32** +** Revision 1.51 2007/05/25 16:24:48EDT dlkobe +** Continued updating doxygen comments +** Revision 1.50 2007/05/23 11:21:23EDT dlkobe +** Added doxygen formatting +** Revision 1.49 2007/05/22 14:56:49EDT apcudmore +** cFE Non-Volatile Disk/Startup File changes: +** - cFE startup now passes in startup file path/name +** - cFE startup code does not init non-volatile disk ( BSP does ) +** - BSPs now can map cFE paths without making the OS_initfs/OS_mount calls +** - MCP750 vxWorks6.2 BSP inits/mounts CF disk +** - Desktop ports pass in the same startup file path/name as before +** Revision 1.48 2007/05/14 15:43:45EDT apcudmore +** Cleaned up events and disabled debug code for application restart. +** Revision 1.47 2007/05/09 12:42:13EDT dlkobe +** Added structure for Dump CDS Registry Record format +** Revision 1.46 2007/05/04 20:07:51EDT dlkobe +** Added command to telemeter memory pool statistics +** Revision 1.45 2007/04/12 10:37:18EDT apcudmore +** Added support for ES task to call CFE_ES_ExitApp on initialization and runtime failure. +** Revision 1.44 2007/04/10 11:39:19EDT rjmcgraw +** Added function prototype CFE_ES_PerfLogAdd +** Revision 1.43 2007/04/10 11:29:10EDT rjmcgraw +** Changed perf entry and exit routines to macros +** Revision 1.42 2007/04/09 15:12:03EDT dlkobe +** Modified 'Name' parameter to be a const pointer +** Revision 1.41 2007/04/05 16:16:03EDT apcudmore +** Added CFE_ES_DeleteChildTask and CFE_ES_ExitChildTask along with headers, +** and associated Error codes. +** Revision 1.39 2007/04/03 16:49:24EDT apcudmore +** Moved all command code defines, command , and telemetry definitions to cfe_es_msg.h +** Revision 1.38 2007/04/02 10:57:45EDT rjmcgraw +** Moved BIT macros from perf.h to cfe_es.h +** Revision 1.37 2007/03/29 15:49:08EST rjmcgraw +** Changed name of performance cmd codes +** Revision 1.36 2007/03/29 15:22:34EST rjmcgraw +** Changed #define names for Logic Analyzer Cmd Codes +** +*/ + +#ifndef _cfe_es_ +#define _cfe_es_ + +/* +** Includes +*/ +#include "cfe_mission_cfg.h" +#include "cfe_es_perfids.h" + +/*****************************************************************************/ + +/* +** Macro Definitions +*/ + +/* +** The OS_PRINTF macro may be defined by OSAL to enable +** printf-style argument checking. If using a version of OSAL +** that does not define this then define it as a no-op. +*/ +#ifndef OS_PRINTF +#define OS_PRINTF(m,n) +#endif + +#define CFE_ES_DBIT(x) (1L << (x)) /* Places a one at bit positions 0 thru 31 */ +#define CFE_ES_DTEST(i,x) (((i) & CFE_ES_DBIT(x)) != 0) /* TRUE iff bit x of i is set */ +#define CFE_ES_TEST_LONG_MASK(m,s) (CFE_ES_DTEST(m[(s)/32],(s)%32)) /* Test a bit within an array of 32-bit integers. */ +#define CFE_ES_MAX_MEMPOOL_BLOCK_SIZES 17 /**< Max number of size divisions allowed in a memory pool */ + +/* +** Note about reset type and subtypes: +** +** These values come from the PSP so the actual definition of these enumerations +** was moved to the PSP header file . +** +** In the future the Electronic Data sheets (EDS) for PSP/ES +** will define the exact values to use in telemetry messages. +*/ + +/* +** Reset types +*/ +/** \name Reset Type extensions */ +/** \{ */ +#define CFE_ES_APP_RESTART CFE_PSP_RST_TYPE_MAX /**< Application only was reset (extend the PSP enumeration here) */ +/** \} */ + + +/** \name Critical Data Store Macros */ +/** \{ */ +/** Maximum length allowed for CDS name.
+** NOTE: "+2" is for NULL Character and "." (i.e. - "AppName.CDSName") */ +#define CFE_ES_CDS_MAX_FULL_NAME_LEN (CFE_ES_CDS_MAX_NAME_LENGTH + OS_MAX_API_NAME + 2) + +#define CFE_ES_CDS_BAD_HANDLE (CFE_ES_CDSHandle_t) 0xFFFF +/** \} */ + +/* +** ES Run Status and Exit Status defines +*/ +/** \name Run Status and Exit Status identifiers */ +/** \{ */ +#define CFE_ES_RUNSTATUS_APP_RUN 1 /**< \brief Indicates that the Application should continue to run */ +#define CFE_ES_RUNSTATUS_APP_EXIT 2 /**< \brief Indicates that the Application wants to exit normally */ +#define CFE_ES_RUNSTATUS_APP_ERROR 3 /**< \brief Indicates that the Application is quitting with an error */ +#define CFE_ES_RUNSTATUS_SYS_EXCEPTION 4 /**< \brief The cFE App caused an exception */ +#define CFE_ES_RUNSTATUS_SYS_RESTART 5 /**< \brief The system is requesting a restart of the cFE App */ +#define CFE_ES_RUNSTATUS_SYS_RELOAD 6 /**< \brief The system is requesting a reload of the cFE App */ +#define CFE_ES_RUNSTATUS_SYS_DELETE 7 /**< \brief The system is requesting that the cFE App is stopped */ +#define CFE_ES_RUNSTATUS_CORE_APP_INIT_ERROR 8 /**< \brief Indicates that the Core Application could not Init */ +#define CFE_ES_RUNSTATUS_CORE_APP_RUNTIME_ERROR 9 /**< \brief Indicates that the Core Application had a runtime failure */ +/** \} */ + +#define CFE_ES_APP_KILL_TIMEOUT 5 /**< \brief Number of cycles that ES will wait before killing an app */ + +#define CFE_ES_NO_MUTEX 0 /**< \brief Indicates that the memory pool selection will not use a semaphore */ +#define CFE_ES_USE_MUTEX 1 /**< \brief Indicates that the memory pool selection will use a semaphore */ + +/* +** System Log Defines +*/ +/* "+1" is for the space between the timestamp and the message in the system log */ +#define CFE_ES_MAX_SYSLOG_MSG_SIZE (CFE_EVS_MAX_MESSAGE_LENGTH + CFE_TIME_PRINTED_STRING_SIZE + 1) + + +/* + * To preserve source-code compatibility with existing code, + * this allows the old enum names to still work. This should + * be turned off after the new names are established. + * (sed -i -e 's///g' should take care of it) + * + * Note about why this is a good idea to do -- + * In the list below there are two values with similar names: + * CFE_ES_EXCEPTION, CFE_ES_SYS_EXCEPTION + * + * But these map to different values for two different purposes, + * one is a app status and the other is a reset subtype. Using the + * new names makes it much clearer as to which is which, will + * greatly reduce the chance of getting them mixed up, and make it + * much more obvious to a code reviewer if the ARE mixed up somewhere. + */ +#ifndef CFE_ES_ENABLE_NEW_ENUM_NAMES + +#define CFE_ES_PROCESSOR_RESET CFE_PSP_RST_TYPE_PROCESSOR +#define CFE_ES_POWERON_RESET CFE_PSP_RST_TYPE_POWERON + +#define CFE_ES_POWER_CYCLE CFE_PSP_RST_SUBTYPE_POWER_CYCLE +#define CFE_ES_PUSH_BUTTON CFE_PSP_RST_SUBTYPE_PUSH_BUTTON +#define CFE_ES_HW_SPECIAL_COMMAND CFE_PSP_RST_SUBTYPE_HW_SPECIAL_COMMAND +#define CFE_ES_HW_WATCHDOG CFE_PSP_RST_SUBTYPE_HW_WATCHDOG +#define CFE_ES_RESET_COMMAND CFE_PSP_RST_SUBTYPE_RESET_COMMAND +#define CFE_ES_EXCEPTION CFE_PSP_RST_SUBTYPE_EXCEPTION +#define CFE_ES_UNDEFINED_RESET CFE_PSP_RST_SUBTYPE_UNDEFINED_RESET +#define CFE_ES_HWDEBUG_RESET CFE_PSP_RST_SUBTYPE_HWDEBUG_RESET +#define CFE_ES_BANKSWITCH_RESET CFE_PSP_RST_SUBTYPE_BANKSWITCH_RESET + +#define CFE_ES_APP_RUN CFE_ES_RUNSTATUS_APP_RUN +#define CFE_ES_APP_EXIT CFE_ES_RUNSTATUS_APP_EXIT +#define CFE_ES_APP_ERROR CFE_ES_RUNSTATUS_APP_ERROR +#define CFE_ES_SYS_EXCEPTION CFE_ES_RUNSTATUS_SYS_EXCEPTION +#define CFE_ES_SYS_RESTART CFE_ES_RUNSTATUS_SYS_RESTART +#define CFE_ES_SYS_RELOAD CFE_ES_RUNSTATUS_SYS_RELOAD +#define CFE_ES_SYS_DELETE CFE_ES_RUNSTATUS_SYS_DELETE +#define CFE_ES_CORE_APP_INIT_ERROR CFE_ES_RUNSTATUS_CORE_APP_INIT_ERROR +#define CFE_ES_CORE_APP_RUNTIME_ERROR CFE_ES_RUNSTATUS_CORE_APP_RUNTIME_ERROR + +#endif + +/*****************************************************************************/ +/* +** Type Definitions +*/ + +/* +** Memory Handle type +*/ +typedef cpuaddr CFE_ES_MemHandle_t; /**< \brief Data type used to hold Handles of Memory Pools created via CFE_ES_PoolCreate and CFE_ES_PoolCreateNoSem */ + +/* +** +** CFE_ES_AppInfo_t is a structure that is used to provide +** information about an app. It is primarily used for the QueryOne and +** QueryAll Commands. +** +*/ +typedef struct +{ + uint32 AppId; /**< \cfetlmmnemonic \ES_APP_ID + \brief Application ID for this Application */ + uint32 Type; /**< \cfetlmmnemonic \ES_APPTYPE + \brief The type of App: CORE or EXTERNAL */ + + char Name[OS_MAX_API_NAME]; /**< \cfetlmmnemonic \ES_APPNAME + \brief The Registered Name of the Application */ + char EntryPoint[OS_MAX_API_NAME]; /**< \cfetlmmnemonic \ES_APPENTRYPT + \brief The Entry Point label for the Application */ + char FileName[OS_MAX_PATH_LEN]; /**< \cfetlmmnemonic \ES_APPFILENAME + \brief The Filename of the file containing the Application */ + + uint32 StackSize; /**< \cfetlmmnemonic \ES_STACKSIZE + \brief The Stack Size of the Application */ + uint32 ModuleId; /**< \cfetlmmnemonic \ES_MODULEID + \brief The ID of the Loadable Module for the Application */ + uint32 AddressesAreValid; /**< \cfetlmmnemonic \ES_ADDRVALID + \brief Indicates that the Code, Data, and BSS addresses/sizes are valid */ + uint32 CodeAddress; /**< \cfetlmmnemonic \ES_CODEADDR + \brief The Address of the Application Code Segment*/ + uint32 CodeSize; /**< \cfetlmmnemonic \ES_CODESIZE + \brief The Code Size of the Application */ + uint32 DataAddress; /**< \cfetlmmnemonic \ES_DATAADDR + \brief The Address of the Application Data Segment*/ + uint32 DataSize; /**< \cfetlmmnemonic \ES_DATASIZE + \brief The Data Size of the Application */ + uint32 BSSAddress; /**< \cfetlmmnemonic \ES_BSSADDR + \brief The Address of the Application BSS Segment*/ + uint32 BSSSize; /**< \cfetlmmnemonic \ES_BSSSIZE + \brief The BSS Size of the Application */ + uint32 StartAddress; /**< \cfetlmmnemonic \ES_STARTADDR + \brief The Start Address of the Application */ + uint16 ExceptionAction; /**< \cfetlmmnemonic \ES_EXCEPTNACTN + \brief What should occur if Application has an exception + (Restart Application OR Restart Processor) */ + uint16 Priority; /**< \cfetlmmnemonic \ES_PRIORITY + \brief The Priority of the Application */ + uint32 MainTaskId; /**< \cfetlmmnemonic \ES_MAINTASKID + \brief The Application's Main Task ID */ + uint32 ExecutionCounter; /**< \cfetlmmnemonic \ES_MAINTASKEXECNT + \brief The Application's Main Task Execution Counter */ + char MainTaskName[OS_MAX_API_NAME]; /**< \cfetlmmnemonic \ES_MAINTASKNAME + \brief The Application's Main Task ID */ + uint32 NumOfChildTasks; /**< \cfetlmmnemonic \ES_CHILDTASKS + \brief Number of Child tasks for an App */ + +} CFE_ES_AppInfo_t; + +/* +** Task Info Type +*/ +typedef struct +{ + uint32 TaskId; /**< \brief Task Id */ + uint32 ExecutionCounter; /**K \brief Task Execution Counter */ + uint8 TaskName[OS_MAX_API_NAME]; /**< \brief Task Name */ + uint32 AppId; /**< \brief Parent Application ID */ + uint8 AppName[OS_MAX_API_NAME]; /**< \brief Parent Application Name */ + +} CFE_ES_TaskInfo_t; + +/* +** Memory Pool Statistics data type +*/ +typedef struct +{ + uint32 BlockSize; /**< \brief Number of bytes in each of these blocks */ + uint32 NumCreated; /**< \brief Number of Memory Blocks of this size created */ + uint32 NumFree; /**< \brief Number of Memory Blocks of this size that are free */ +} CFE_ES_BlockStats_t; + +typedef struct +{ + uint32 PoolSize; /**< \cfetlmmnemonic \ES_POOLSIZE + \brief Size of Memory Pool (in bytes) */ + uint32 NumBlocksRequested; /**< \cfetlmmnemonic \ES_BLKSREQ + \brief Number of times a memory block has been allocated */ + uint32 CheckErrCtr; /**< \cfetlmmnemonic \ES_BLKERRCTR + \brief Number of errors detected when freeing a memory block */ + uint32 NumFreeBytes; /**< \cfetlmmnemonic \ES_FREEBYTES + \brief Number of bytes never allocated to a block */ + CFE_ES_BlockStats_t BlockStats[CFE_ES_MAX_MEMPOOL_BLOCK_SIZES]; /**< \cfetlmmnemonic \ES_BLKSTATS + \brief Contains stats on each block size */ +} CFE_ES_MemPoolStats_t; + +/* +** CDS Handle type +*/ +typedef cpuaddr CFE_ES_CDSHandle_t; /**< \brief Data type used to hold Handles of Critical Data Stores. See CFE_ES_RegisterCDS */ + +typedef struct +{ + CFE_ES_CDSHandle_t Handle; /**< \brief Handle of CDS */ + uint32 Size; /**< \brief Size, in bytes, of the CDS memory block */ + boolean Table; /**< \brief Flag that indicates whether CDS contains a Critical Table */ + char Name[CFE_ES_CDS_MAX_FULL_NAME_LEN]; /**< \brief Processor Unique Name of CDS */ + uint8 ByteAlignSpare1; /**< \brief Spare byte to insure structure size is multiple of 4 bytes */ +} CFE_ES_CDSRegDumpRec_t; + +/* +** Child Task Main Function Prototype +*/ +typedef void (*CFE_ES_ChildTaskMainFuncPtr_t)(void); /**< \brief Required Prototype of Child Task Main Functions */ +typedef int32 (*CFE_ES_LibraryEntryFuncPtr_t)(void); /**< \brief Required Prototype of Library Initialization Functions */ + +typedef enum +{ + CFE_ES_STATICENTRYTYPE_INVALID = 0, + CFE_ES_STATICENTRYTYPE_FIRST_VALID = 2000, + CFE_ES_STATICENTRYTYPE_APPLICATION, + CFE_ES_STATICENTRYTYPE_LIBRARY, + CFE_ES_STATICENTRYTYPE_MAX +} CFE_ES_StaticEntryType_t; + +/* +** API Structure for statically linked CFS Applications +*/ +typedef const struct +{ + CFE_ES_StaticEntryType_t EntryType; + union + { + CFE_ES_ChildTaskMainFuncPtr_t AppEntryFunc; /**< \brief Entry point for Application */ + CFE_ES_LibraryEntryFuncPtr_t LibInitFunc; /**< \brief Initialization function for Library */ + cpuaddr EntryFuncAddr; + } Ptrs; + uint32 Priority; + uint32 StackSize; +} CFE_ES_AppStaticModuleApi_t; + +#ifdef CFS_STATIC_MODULE + +#define CFS_MODULE_DECLARE_APP(name,pri,stack) \ + void name##_Main(void); \ + CFE_ES_AppStaticModuleApi_t CFS_##name##_API = \ + { \ + .EntryType = CFE_ES_STATICENTRYTYPE_APPLICATION, \ + .Ptrs.AppEntryFunc = name##_Main, \ + .Priority = pri, \ + .StackSize = stack, \ + } + +#define CFS_MODULE_DECLARE_LIB(name) \ + int32 name##_Init(void); \ + CFE_ES_AppStaticModuleApi_t CFS_##name##_API = \ + { \ + .EntryType = CFE_ES_STATICENTRYTYPE_LIBRARY, \ + .Ptrs.LibInitFunc = name##_Init, \ + } +#else +#define CFS_MODULE_DECLARE_APP(name,pri,stack) +#define CFS_MODULE_DECLARE_LIB(name) +#endif + + +/*****************************************************************************/ +/* +** Exported Functions +*/ + +/*****************************************************************************/ + +#if !defined(OSAL_OPAQUE_OBJECT_IDS) +/* +** \brief Compatibility wrapper for older versions of OSAL +** +** \par Description +** In future versions of OSAL the task/object ID values might not be zero based +** If that is the case then the OSAL must also define a function to convert back +** to zero-based numbers such that the value can be used as an array index. +** +** When using an existing/older version of OSAL, this inline function is defined +** to mimic this call for backward compatibility. It just passes through the same +** value without modification. +** +** \param[in] ObjectId The object ID from OSAL +** \param[out] ArrayIndex A zero-based value suitable for use as an array index +** \returns OS_SUCCESS (a real version might return an error code). +*/ +static inline int32 OS_ConvertToArrayIndex(uint32 ObjectId, uint32 *ArrayIndex) +{ + *ArrayIndex = ObjectId; + return OS_SUCCESS; +} +#endif + + + +/*****************************************************************************/ +/** +** \brief cFE Main Entry Point used by Board Support Package to start cFE +** +** \par Description +** cFE main entry point. This is the entry point into the cFE software. +** It is called only by the Board Support Package software. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] StartType Identifies whether this was a #CFE_PSP_RST_TYPE_POWERON or #CFE_PSP_RST_TYPE_PROCESSOR. +** +** \param[in] StartSubtype Specifies, in more detail, what caused the \c StartType identified above. +** See #CFE_ES_POWER_CYCLE for possible examples. +** +** \param[in] ModeId Identifies the source of the Boot as determined by the BSP. +** +** \param[in] StartFilePath Identifies the startup file to use to initialize the cFE apps. +** +** \sa #CFE_ES_ResetCFE +** +******************************************************************************/ +void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId , const char *StartFilePath ); + +/*****************************************************************************/ +/** +** \brief Return the most recent Reset Type +** +** \par Description +** Provides the caller with codes that identifies the type of Reset +** the processor most recently underwent. The caller can also obtain +** information on what caused the reset by supplying a pointer to a +** variable that will be filled with the Reset Sub-Type. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] ResetSubtypePtr Pointer to \c uint32 type variable in which the Reset Sub-Type will be stored. +** The caller can set this pointer to NULL if the Sub-Type is of no interest. +** +** \param[out] *ResetSubtypePtr If the provided pointer was not \c NULL, the Reset Sub-Type is stored at the given address. +** For a list of possible Sub-Type values, see \link #CFE_ES_POWER_CYCLE "Reset Sub-Types" \endlink. +** +** \returns +** \retcode #CFE_PSP_RST_TYPE_POWERON \retdesc \copydoc CFE_PSP_RST_TYPE_POWERON \endcode +** \retcode #CFE_PSP_RST_TYPE_PROCESSOR \retdesc \copydoc CFE_PSP_RST_TYPE_PROCESSOR \endcode +** \endreturns +** +** \sa #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName, #CFE_ES_GetTaskInfo +** +******************************************************************************/ +int32 CFE_ES_GetResetType(uint32 *ResetSubtypePtr); + +/*****************************************************************************/ +/** +** \brief Reset the cFE Core and all cFE Applications +** +** \par Description +** This API causes an immediate reset of the cFE Kernel and all cFE Applications. +** The caller can specify whether the reset should clear all memory (#CFE_PSP_RST_TYPE_POWERON) +** or try to retain volatile memory areas (#CFE_PSP_RST_TYPE_PROCESSOR). +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] ResetType Identifies the type of reset desired. Allowable settings are: +** \arg #CFE_PSP_RST_TYPE_POWERON - Causes all memory to be cleared +** \arg #CFE_PSP_RST_TYPE_PROCESSOR - Attempts to retain volatile disk, critical data store and user reserved memory. +** +** \returns +** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode +** \retcode #CFE_ES_NOT_IMPLEMENTED \retdesc \copydoc CFE_ES_NOT_IMPLEMENTED \endcode +** \endreturns +** +** \sa #CFE_ES_Main +** +******************************************************************************/ +int32 CFE_ES_ResetCFE(uint32 ResetType); + +/*****************************************************************************/ +/** +** \brief Restart a single cFE Application +** +** \par Description +** This API causes a cFE Application to be stopped and restarted. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] AppID Identifies the application to be reset. +** +** \returns +** \retcode #CFE_ES_NOT_IMPLEMENTED \retdesc \copydoc CFE_ES_NOT_IMPLEMENTED \endcode +** \endreturns +** +** \sa #CFE_ES_ReloadApp, #CFE_ES_DeleteApp +** +******************************************************************************/ +int32 CFE_ES_RestartApp(uint32 AppID); + +/*****************************************************************************/ +/** +** \brief Reload a single cFE Application +** +** \par Description +** This API causes a cFE Application to be stopped and restarted from +** the specified file. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] AppID Identifies the application to be reset. +** +** \param[in] AppFileName Identifies the new file to start. +** +** \returns +** \retcode #CFE_ES_NOT_IMPLEMENTED \retdesc \copydoc CFE_ES_NOT_IMPLEMENTED \endcode +** \endreturns +** +** \sa #CFE_ES_RestartApp, #CFE_ES_DeleteApp +** +******************************************************************************/ +int32 CFE_ES_ReloadApp(uint32 AppID, const char *AppFileName); + +/*****************************************************************************/ +/** +** \brief Delete a cFE Application +** +** \par Description +** This API causes a cFE Application to be stopped deleted. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] AppID Identifies the application to be reset. +** +** \returns +** \retcode #CFE_ES_NOT_IMPLEMENTED \retdesc \copydoc CFE_ES_NOT_IMPLEMENTED \endcode +** \endreturns +** +** \sa #CFE_ES_RestartApp, #CFE_ES_ReloadApp +** +******************************************************************************/ +int32 CFE_ES_DeleteApp(uint32 AppID); + +/*****************************************************************************/ +/** +** \brief Exit a cFE Application +** +** \par Description +** This API is the "Exit Point" for the cFE application +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] ExitStatus . +** +** \returns +** \retcode #CFE_ES_NOT_IMPLEMENTED \retdesc \copydoc CFE_ES_NOT_IMPLEMENTED \endcode +** \endreturns +** +** \sa #CFE_ES_RunLoop, #CFE_ES_RegisterApp +** +******************************************************************************/ +void CFE_ES_ExitApp(uint32 ExitStatus); + + +/*****************************************************************************/ +/** +** \brief Check for Exit, Restart, or Reload commands +** +** \par Description +** This is the API that allows an app to check for exit requests from +** the system. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] ExitStatus A pointer to a variable containing the Application's +** desired run status. Acceptable values are: +** \arg #CFE_ES_APP_RUN - \copydoc CFE_ES_APP_RUN +** \arg #CFE_ES_APP_EXIT - \copydoc CFE_ES_APP_EXIT +** \arg #CFE_ES_APP_ERROR - \copydoc CFE_ES_APP_ERROR +** +** \returns +** \retcode #TRUE \retdesc The application should continue executing \endcode +** \retcode #FALSE \retdesc The application should terminate itself \endcode +** \endreturns +** +** \sa #CFE_ES_ExitApp, #CFE_ES_RegisterApp +** +******************************************************************************/ +int32 CFE_ES_RunLoop(uint32 *ExitStatus); + +/*****************************************************************************/ +/** +** \brief Allow an Application to Wait for others to start up +** +** \par Description +** This is the API that allows an app to wait for the "rest" of the apps +** to finish initializing before continuing. It is most useful for +** applications such as Health and Safety or the Scheduler that need +** to wait until applications exist and are running before sending out +** packets to them. +** +** \par Assumptions, External Events, and Notes: +** This API should only be called as the last item of an Apps initialization. +** In addition, this API should only be called by an App that is started +** from the ES Startup file. It should not be used by an App that is +** started after the system is running. ( Although it will cause no harm ) +** +** \param[in] TimeOutMilliseconds The timeout value in Milliseconds. +** This parameter must be at least 1000. Lower values +** will be rounded up. There is not an option to +** wait indefinitely to avoid hanging a critical +** application because a non-critical app did not start. +** +** +** \sa #CFE_ES_RunLoop +** +******************************************************************************/ +void CFE_ES_WaitForStartupSync(uint32 TimeOutMilliseconds); + + +/* +** Application Management functions +*/ + +/*****************************************************************************/ +/** +** \brief Registers a cFE Application with the Executive Services +** +** \par Description +** This API registers the calling Application with the cFE. +** +** \par Assumptions, External Events, and Notes: +** NOTE: This function \b MUST be called before any other cFE API functions are called. +** +** \returns +** \retstmt Return codes from #OS_TaskRegister \endcode +** \retstmt Return codes from #OS_BinSemTake \endcode +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \endreturns +** +** \sa #CFE_ES_ExitApp, #CFE_ES_RunLoop +** +******************************************************************************/ +int32 CFE_ES_RegisterApp(void); + +/*****************************************************************************/ +/** +** \brief Get an Application ID for the calling Application +** +** \par Description +** This routine retrieves the cFE Application ID for the calling Application. +** +** \par Assumptions, External Events, and Notes: +** NOTE: \b All tasks associated with the Application would return the same Application ID. +** +** \param[in] AppIdPtr Pointer to variable that is to receive the Application's ID. +** +** \param[out] *AppIdPtr Application ID of the calling Application. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_ERR_APPID \retdesc \copydoc CFE_ES_ERR_APPID \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \endreturns +** +** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName, #CFE_ES_GetTaskInfo +** +******************************************************************************/ +int32 CFE_ES_GetAppID(uint32 *AppIdPtr); + +/*****************************************************************************/ +/** +** \brief Get an Application ID associated with a specified Application name +** +** \par Description +** This routine retrieves the cFE Application ID associated with a +** specified Application name. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] AppIdPtr Pointer to variable that is to receive the Application's ID. +** +** \param[in] AppName Pointer to null terminated character string containing an Application name. +** +** \param[out] *AppIdPtr Application ID of the calling Application. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \endreturns +** +** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppID, #CFE_ES_GetAppName, #CFE_ES_GetTaskInfo +** +******************************************************************************/ +int32 CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName); + +/*****************************************************************************/ +/** +** \brief Get an Application name for a specified Application ID +** +** \par Description +** This routine retrieves the cFE Application ID associated with a +** specified Application name. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] AppName Pointer to a character array of at least \c BufferLength in size that will +** be filled with the appropriate Application name. +** +** \param[in] AppId Application ID of Application whose name is being requested. +** +** \param[in] BufferLength The maximum number of characters, including the null terminator, that can be put +** into the \c AppName buffer. This routine will truncate the name to this length, +** if necessary. +** +** \param[out] *AppName Null terminated Application name of the Application associated with the +** specified Application ID. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_ERR_APPID \retdesc \copydoc CFE_ES_ERR_APPID \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \endreturns +** +** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetTaskInfo +** +******************************************************************************/ +int32 CFE_ES_GetAppName(char *AppName, uint32 AppId, uint32 BufferLength); + +/*****************************************************************************/ +/** +** \brief Get Application Information given a specified App ID +** +** \par Description +** This routine retrieves the information about an App associated with a +** specified App ID. The information includes all of the information ES +** maintains for an application ( documented in the CFE_ES_AppInfo_t type ) +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] AppInfo Pointer to a \c CFE_ES_AppInfo_t structure that holds the specific +** Application information. +** +** \param[in] AppId Application ID of Application whose name is being requested. +** +** \param[out] *AppInfo Filled out \c CFE_ES_AppInfo_t structure containing the +** App Name, and application memory addresses among other fields. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_ERR_APPID \retdesc \copydoc CFE_ES_ERR_APPID \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \endreturns +** +** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName +** +******************************************************************************/ +int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, uint32 AppId); + +/*****************************************************************************/ +/** +** \brief Get Task Information given a specified Task ID +** +** \par Description +** This routine retrieves the information about a Task associated with a +** specified Task ID. The information includes Task Name, and Parent/Creator +** Application ID. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TaskInfo Pointer to a \c CFE_ES_TaskInfo_t structure that holds the specific +** task information. +** +** \param[in] TaskId Application ID of Application whose name is being requested. +** +** \param[out] *TaskInfo Filled out \c CFE_ES_TaskInfo_t structure containing the +** Task Name, Parent App Name, Parent App ID among other fields. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_ERR_TASKID \retdesc \copydoc CFE_ES_ERR_TASKID \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \endreturns +** +** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName +** +******************************************************************************/ +int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, uint32 TaskId); + +/* +** Task management functions +*/ +/*****************************************************************************/ +/** +** \brief Registers a cFE Child task associated with a cFE Application +** +** \par Description +** This routine registers a cFE Child task and associates it with its parent +** cFE Application. +** +** \par Assumptions, External Events, and Notes: +** NOTE: This API \b MUST be called by the Child Task before any other cFE API calls are made. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_ERR_CHILD_TASK_REGISTER \retdesc \copydoc CFE_ES_ERR_CHILD_TASK_REGISTER \endcode +** \endreturns +** +** \sa #CFE_ES_CreateChildTask, #CFE_ES_DeleteChildTask, #CFE_ES_ExitChildTask +** +******************************************************************************/ +int32 CFE_ES_RegisterChildTask(void); + +/*****************************************************************************/ +/** +** \brief Creates a new task under an existing Application +** +** \par Description +** This routine creates a new task (a separate execution thread) owned by the calling Application. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TaskIdPtr A pointer to a variable that will be filled in with the new task's ID. +** +** \param[in] TaskName A pointer to a string containing the desired name of the new task. +** This can be up to #OS_MAX_API_NAME characters, including the trailing null. +** +** \param[in] FunctionPtr A pointer to the function that will be spawned as a new task. This function +** must have the following signature: uint32 function(void). Input parameters +** for the new task are not supported. +** +** \param[in] StackPtr A pointer to the location where the child task's stack pointer should start. +** NOTE: Not all underlying operating systems support this parameter. +** +** \param[in] StackSize The number of bytes to allocate for the new task's stack. +** +** \param[in] Priority The priority for the new task. Lower numbers are higher priority, with 0 being +** the highest priority. Applications cannot create tasks with a higher priority +** (lower number) than their own priority. +** +** \param[in] Flags Reserved for future expansion. +** +** \param[out] *TaskIdPtr The Task ID of the newly created child task. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_ERR_CHILD_TASK_CREATE \retdesc \copydoc CFE_ES_ERR_CHILD_TASK_CREATE \endcode +** \endreturns +** +** \sa #CFE_ES_RegisterChildTask, #CFE_ES_DeleteChildTask, #CFE_ES_ExitChildTask +** +******************************************************************************/ +int32 CFE_ES_CreateChildTask(uint32 *TaskIdPtr, + const char *TaskName, + CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, + uint32 *StackPtr, + uint32 StackSize, + uint32 Priority, + uint32 Flags); + +/*****************************************************************************/ +/** +** \brief Deletes a task under an existing Application +** +** \par Description +** This routine deletes a task under an Application specified by the \c TaskId obtained +** when the child task was created using the #CFE_ES_CreateChildTask API. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TaskId The task ID previously obtained when the Child Task was created with the #CFE_ES_CreateChildTask API. +** +** \returns +** \retcode #CFE_ES_NOT_IMPLEMENTED \retdesc \copydoc CFE_ES_NOT_IMPLEMENTED \endcode +** \endreturns +** +** \sa #CFE_ES_RegisterChildTask, #CFE_ES_CreateChildTask, #CFE_ES_ExitChildTask +** +******************************************************************************/ +int32 CFE_ES_DeleteChildTask(uint32 TaskId); + +/*****************************************************************************/ +/** +** \brief Exits a child task +** +** \par Description +** This routine allows the current executing child task to exit and +** be deleted by ES. +** +** \par Assumptions, External Events, and Notes: +** This function cannot be called from an Application's Main Task. +** +** \returns +** \retstmt +** This function does not return a value, but if it does return +** at all, it is assumed that the Task was either unregistered or +** this function was called from a cFE Application's main task. \endcode +** \endreturns +** +** \sa #CFE_ES_RegisterChildTask, #CFE_ES_CreateChildTask, #CFE_ES_DeleteChildTask +** +******************************************************************************/ +void CFE_ES_ExitChildTask(void); + +/*****************************************************************************/ +/** +** \brief Increments the execution counter for the calling task +** +** \par Description +** This routine increments the execution counter that is stored for +** the calling task. It can be called from cFE Application main tasks, child +** tasks, or cFE Core application main tasks. Normally, the call is not +** necessary from a cFE Application, since the CFE_ES_RunLoop call increments +** the counter for the Application. +** +** \par Assumptions, External Events, and Notes: +** NOTE: This API is not needed for Appplications that call the CFE_ES_RunLoop call. +** +** \returns +** \retstmt +** This function does not return a value. \endcode +** \endreturns +** +** \sa #CFE_ES_RunLoop +** +******************************************************************************/ +void CFE_ES_IncrementTaskCounter(void); + +/* +** Log management functions +*/ + +/*****************************************************************************/ +/** +** \brief Write a string to the cFE System Log +** +** \par Description +** This routine writes a formatted string to the cFE system log. This +** can be used to record very low-level errors that can't be reported +** using the Event Services. This function is used in place of printf +** for flight software. It should be used for significant startup events, +** critical errors, and conditionally compiled debug software. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] SpecStringPtr The format string for the log message. +** This is similar to the format string for a printf() call. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_ERR_SYS_LOG_FULL \retdesc \copydoc CFE_ES_ERR_SYS_LOG_FULL \endcode +** \endreturns +** +** \sa +** +******************************************************************************/ +int32 CFE_ES_WriteToSysLog(const char *SpecStringPtr, ...) OS_PRINTF(1,2); + +/*****************************************************************************/ +/** +** \brief Calculate a CRC on a block of memory +** +** \par Description +** This routine calculates a cyclic redundancy check (CRC) on a block of memory. The CRC algorithm +** used is determined by the last parameter. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] DataPtr Pointer to the base of the memory block. +** +** \param[in] DataLength The number of bytes in the memory block. +** +** \param[in] InputCRC A starting value for use in the CRC calculation. This parameter +** allows the user to calculate the CRC of non-contiguous blocks as +** a single value. Nominally, the user should set this value to zero. +** +** \param[in] TypeCRC One of the following CRC algorithm selections: +** +** \arg \c CFE_ES_CRC_8 - (Not currently implemented) +** \arg \c CFE_ES_CRC_16 - a CRC-16 algorithm +** \arg \c CFE_ES_CRC_32 - (not currently implemented) +** +** \returns +** \retstmt The result of the CRC calculation on the specified memory block. \endcode +** \endreturns +** +******************************************************************************/ +uint32 CFE_ES_CalculateCRC(const void *DataPtr, uint32 DataLength, uint32 InputCRC, uint32 TypeCRC); + +/* +** Critical Data Store API +*/ + +/*****************************************************************************/ +/** +** \brief Reserve space (or re-obtain previously reserved space) in the Critical Data Store (CDS) +** +** \par Description +** This routine allocates a block of memory in the Critical Data Store and associates it with +** the calling Application. The memory can survive an Application restart as well as a Processor Reset. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] HandlePtr Pointer Application's variable that will contain the CDS Memory Block Handle. +** +** \param[in] BlockSize The number of bytes needed in the CDS. +** +** \param[in] Name A pointer to a character string containing an application +** unique name of #CFE_ES_CDS_MAX_NAME_LENGTH characters or less. +** +** \param[out] *HandlePtr The handle of the CDS block that can be used in +** #CFE_ES_CopyToCDS and #CFE_ES_RestoreFromCDS. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc The memory block was successfully created in the CDS. \endcode +** \retcode #CFE_ES_NOT_IMPLEMENTED \retdesc The processor does not support a Critical Data Store. \endcode +** \retcode #CFE_ES_CDS_ALREADY_EXISTS \retdesc \copydoc CFE_ES_CDS_ALREADY_EXISTS \endcode +** \retcode #CFE_ES_CDS_INVALID_SIZE \retdesc \copydoc CFE_ES_CDS_INVALID_SIZE \endcode +** \retcode #CFE_ES_CDS_INVALID_NAME \retdesc \copydoc CFE_ES_CDS_INVALID_NAME \endcode +** \retcode #CFE_ES_CDS_REGISTRY_FULL \retdesc \copydoc CFE_ES_CDS_REGISTRY_FULL \endcode +** \endreturns +** +** \sa #CFE_ES_CopyToCDS, #CFE_ES_RestoreFromCDS +** +******************************************************************************/ +int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, int32 BlockSize, const char *Name); + +/*****************************************************************************/ +/** +** \brief Save a block of data in the Critical Data Store (CDS) +** +** \par Description +** This routine copies a specified block of memory into the Critical Data Store that +** had been previously registered via #CFE_ES_RegisterCDS. The block of memory to be +** copied must be at least as big as the size specified when registering the CDS. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] Handle The handle of the CDS block that was previously obtained from #CFE_ES_RegisterCDS. +** +** \param[in] DataToCopy A Pointer to the block of memory to be copied into the CDS. +** +** \returns +** \retcode #OS_SUCCESS \retdesc \copydoc OS_SUCCESS \endcode +** \retcode #CFE_ES_ERR_MEM_HANDLE \retdesc \copydoc CFE_ES_ERR_MEM_HANDLE \endcode +** \retcode #OS_ERROR \retdesc Problem with handle or a size mismatch \endcode +** \endreturns +** +** \sa #CFE_ES_RegisterCDS, #CFE_ES_RestoreFromCDS +** +*/ +int32 CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t Handle, void *DataToCopy); + +/*****************************************************************************/ +/** +** \brief Recover a block of data from the Critical Data Store (CDS) +** +** \par Description +** This routine copies data from the Critical Data Store identified with the \c Handle into +** the area of memory pointed to by the \c RestoreToMemory pointer. The area of memory to +** be copied into must be at least as big as the size specified when registering the CDS. +** The recovery will indicate an error if the data integrity check maintained by the CDS +** indicates the contents of the CDS have changed. However, the contents will still be +** copied into the specified area of memory. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] Handle The handle of the CDS block that was previously obtained from #CFE_ES_RegisterCDS. +** +** \param[in] RestoreToMemory A Pointer to the block of memory that is to be restored with the contents of the CDS. +** +** \param[out] *RestoreToMemory The contents of the specified CDS. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_CDS_BLOCK_CRC_ERR \retdesc \copydoc CFE_ES_CDS_BLOCK_CRC_ERR \endcode +** \retcode #OS_ERROR \retdesc Problem with handle or a size mismatch \endcode +** \endreturns +** +** \sa #CFE_ES_RegisterCDS, #CFE_ES_CopyToCDS +** +*/ +int32 CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t Handle); + +/* +** Memory Allocation/Deallocation API +*/ + +/*****************************************************************************/ +/** +** \brief Initializes a memory pool created by an application without using a semaphore during processing. +** +** \par Description +** This routine initializes a pool of memory supplied by the calling application. When a memory pool +** created by this routine is processed, no mutex handling is performed. +** +** \par Assumptions, External Events, and Notes: +** -# The size of the pool must be an integral number of 32-bit words +** -# The start address of the pool must be 32-bit aligned +** -# 168 bytes are used for internal bookkeeping, therefore, they will not be available for allocation. +** +** \param[in] HandlePtr A pointer to the variable the caller wishes to have the memory pool handle kept in. +** +** \param[in] MemPtr A Pointer to the pool of memory created by the calling application. This address must +** be on a 32-bit boundary. +** +** \param[in] Size The size of the pool of memory. Note that this must be an integral number of 32 bit words. +** +** \param[out] *HandlePtr The memory pool handle. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode +** \endreturns +** +** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats +** +******************************************************************************/ +int32 CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *HandlePtr, uint8 *MemPtr, uint32 Size); + +/*****************************************************************************/ +/** +** \brief Initializes a memory pool created by an application while using a semaphore during processing. +** +** \par Description +** This routine initializes a pool of memory supplied by the calling application. When a memory pool +** created by this routine is processed, mutex handling will be performed. +** +** \par Assumptions, External Events, and Notes: +** -# The size of the pool must be an integral number of 32-bit words +** -# The start address of the pool must be 32-bit aligned +** -# 168 bytes are used for internal bookkeeping, therefore, they will not be available for allocation. +** +** \param[in] HandlePtr A pointer to the variable the caller wishes to have the memory pool handle kept in. +** +** \param[in] MemPtr A Pointer to the pool of memory created by the calling application. This address must +** be on a 32-bit boundary. +** +** \param[in] Size The size of the pool of memory. Note that this must be an integral number of 32 bit words. +** +** \param[out] *HandlePtr The memory pool handle. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode +** \endreturns +** +** \sa #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats +** +******************************************************************************/ +int32 CFE_ES_PoolCreate(CFE_ES_MemHandle_t *HandlePtr, uint8 *MemPtr, uint32 Size); + +/*****************************************************************************/ +/** +** \brief Initializes a memory pool created by an application with application specified block sizes. +** +** \par Description +** This routine initializes a pool of memory supplied by the calling application. +** +** \par Assumptions, External Events, and Notes: +** -# The size of the pool must be an integral number of 32-bit words +** -# The start address of the pool must be 32-bit aligned +** -# 168 bytes are used for internal bookkeeping, therefore, they will not be available for allocation. +** +** \param[in] HandlePtr A pointer to the variable the caller wishes to have the memory pool handle kept in. +** +** \param[in] MemPtr A Pointer to the pool of memory created by the calling application. This address must +** be on a 32-bit boundary. +** +** \param[in] Size The size of the pool of memory. Note that this must be an integral number of 32 bit words. +** +** \param[in] NumBlockSizes The number of different block sizes specified in the \c BlockSizes array. If set equal to +** zero or if greater than 17, then default block sizes are used. +** +** \param[in] BlockSizes Pointer to an array of sizes to be used instead of the default block sizes specified by +** #CFE_ES_MEM_BLOCK_SIZE_01 through #CFE_ES_MAX_BLOCK_SIZE. If the pointer is equal to NULL, +** the default block sizes are used. +** +** \param[in] UseMutex Flag indicating whether the new memory pool will be processing with mutex handling or not. +** Valid parameter values are #CFE_ES_USE_MUTEX and #CFE_ES_NO_MUTEX +** +** \param[out] *HandlePtr The memory pool handle. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode +** \endreturns +** +** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_GetPoolBuf, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats +** +******************************************************************************/ +int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *HandlePtr, uint8 *MemPtr, uint32 Size, uint32 NumBlockSizes, uint32 *BlockSizes, uint16 UseMutex); + +/*****************************************************************************/ +/** +** \brief Gets a buffer from the memory pool created by #CFE_ES_PoolCreate or #CFE_ES_PoolCreateNoSem +** +** \par Description +** This routine obtains a block of memory from the memory pool supplied by the calling application. +** +** \par Assumptions, External Events, and Notes: +** -# The size allocated from the memory pool is, at a minimum, 12 bytes more than requested. +** +** \param[in] BufPtr A pointer to the Application's pointer in which will be stored the address of the allocated memory buffer. +** +** \param[in] HandlePtr The handle to the memory pool as returned by #CFE_ES_PoolCreate or #CFE_ES_PoolCreateNoSem. +** +** \param[in] Size The size of the buffer requested. NOTE: The size allocated may be larger. +** +** \param[out] *BufPtr The address of the requested buffer. +** +** \returns +** \retstmt When successful, the return value is a positive number and is the number of bytes +** actually allocated for the buffer. \endcode +** \retcode #CFE_ES_ERR_MEM_HANDLE \retdesc \copydoc CFE_ES_ERR_MEM_HANDLE \endcode +** \retcode #CFE_ES_ERR_MEM_BLOCK_SIZE \retdesc \copydoc CFE_ES_ERR_MEM_BLOCK_SIZE \endcode +** \endreturns +** +** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats, #CFE_ES_GetPoolBufInfo +** +******************************************************************************/ +int32 CFE_ES_GetPoolBuf(uint32 **BufPtr, CFE_ES_MemHandle_t HandlePtr, uint32 Size); + +/*****************************************************************************/ +/** +** \brief Gets info on a buffer previously allocated via #CFE_ES_GetPoolBuf +** +** \par Description +** This routine gets info on a buffer in the memory pool. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] HandlePtr The handle to the memory pool as returned by #CFE_ES_PoolCreate or #CFE_ES_PoolCreateNoSem. +** +** \param[in] BufPtr A pointer to the memory buffer to provide status for. +** +** \returns +** \retstmt When successful, the return value is a positive number and is the number of bytes actually allocated. \endcode +** \retcode #CFE_ES_ERR_MEM_HANDLE \retdesc \copydoc CFE_ES_ERR_MEM_HANDLE \endcode +** \retcode #CFE_ES_BUFFER_NOT_IN_POOL \retdesc \copydoc CFE_ES_BUFFER_NOT_IN_POOL \endcode +** \endreturns +** +** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_GetMemPoolStats, #CFE_ES_PutPoolBuf +** +******************************************************************************/ +int32 CFE_ES_GetPoolBufInfo(CFE_ES_MemHandle_t HandlePtr, uint32 *BufPtr); + +/*****************************************************************************/ +/** +** \brief Releases a buffer from the memory pool that was previously allocated via #CFE_ES_GetPoolBuf +** +** \par Description +** This routine releases a buffer back into the memory pool. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] HandlePtr The handle to the memory pool as returned by #CFE_ES_PoolCreate or #CFE_ES_PoolCreateNoSem. +** +** \param[in] BufPtr A pointer to the memory buffer to be released. +** +** \returns +** \retstmt When successful, the return value is a positive number and is the number of bytes actually released. \endcode +** \retcode #CFE_ES_ERR_MEM_HANDLE \retdesc \copydoc CFE_ES_ERR_MEM_HANDLE \endcode +** \endreturns +** +** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_GetMemPoolStats, #CFE_ES_GetPoolBufInfo +** +******************************************************************************/ +int32 CFE_ES_PutPoolBuf(CFE_ES_MemHandle_t HandlePtr, uint32 *BufPtr); + +/*****************************************************************************/ +/** +** \brief Extracts the statistics maintained by the memory pool software +** +** \par Description +** This routine fills the #CFE_ES_MemPoolStats_t data structure with the statistics +** maintained by the memory pool software. These statistics can then be telemetered +** by the calling Application. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] BufPtr Pointer to #CFE_ES_MemPoolStats_t data structure to be +** filled with memory statistics. +** +** \param[in] Handle The handle to the memory pool whose statistics are desired. +** +** \param[out] *BufPtr Memory Pool Statistics stored in given data structure. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_ERR_MEM_HANDLE \retdesc \copydoc CFE_ES_ERR_MEM_HANDLE \endcode +** \endreturns +** +** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_PutPoolBuf +** +******************************************************************************/ +int32 CFE_ES_GetMemPoolStats(CFE_ES_MemPoolStats_t *BufPtr, CFE_ES_MemHandle_t Handle); + +/* +** Performance Log API +*/ + +/*****************************************************************************/ +/** +** \brief Entry marker for use with Software Performance Analysis Tool. +** +** \par Description +** This macro logs the entry or start event/marker for the specified +** entry \c id. This macro, in conjunction with the #CFE_ES_PerfLogExit, +** is used by the Software Performance Analysis tool (see section 5.15). +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] id Identifier of the specific event or marker. +** +** \sa #CFE_ES_PerfLogExit, #CFE_ES_PerfLogAdd +** +******************************************************************************/ +#define CFE_ES_PerfLogEntry(id) (CFE_ES_PerfLogAdd(id, 0)) + +/*****************************************************************************/ +/** +** \brief Exit marker for use with Software Performance Analysis Tool. +** +** \par Description +** This macro logs the exit or end event/marker for the specified +** entry \c id. This macro, in conjunction with the #CFE_ES_PerfLogEntry, +** is used by the Software Performance Analysis tool (see section 5.15). +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] id Identifier of the specific event or marker. +** +** \sa #CFE_ES_PerfLogEntry, #CFE_ES_PerfLogAdd +** +******************************************************************************/ +#define CFE_ES_PerfLogExit(id) (CFE_ES_PerfLogAdd(id, 1)) + + +/*****************************************************************************/ +/** +** \brief Function called by CFE_ES_PerfLogEntry and CFE_ES_PerfLogExit macros +** +** \par Description +** This function logs the entry and exit marker for the specified +** \c id. This function is used by the Software Performance Analysis +** tool (see section 5.15). +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] Marker Identifier of the specific event or marker. +** \param[in] EntryExit Used to specify Entry(0) or Exit(1) +** +** \sa #CFE_ES_PerfLogEntry, #CFE_ES_PerfLogExit +** +******************************************************************************/ +void CFE_ES_PerfLogAdd(uint32 Marker, uint32 EntryExit); + +/* +** Generic Counter API +*/ + +/*****************************************************************************/ +/** +** \brief Register a generic counter +** +** \par Description +** This routine registers a generic counter. +** +** \par Assumptions, External Events, and Notes: +** None. +** +** \param[in] *CounterName The Name of the generic counter. +** +** \param[out] *CounterIdPtr The Counter Id of the newly created counter. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode +** \endreturns +** +** \sa #CFE_ES_IncrementGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName +** +******************************************************************************/ +int32 CFE_ES_RegisterGenCounter(uint32 *CounterIdPtr, const char *CounterName); + +/*****************************************************************************/ +/** +** \brief Delete a generic counter +** +** \par Description +** This routine deletes a previously registered generic counter. +** +** \par Assumptions, External Events, and Notes: +** None. +** +** \param[in] CounterId The Counter Id of the newly created counter. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode +** \endreturns +** +** \sa #CFE_ES_IncrementGenCounter, #CFE_ES_RegisterGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName +** +******************************************************************************/ +int32 CFE_ES_DeleteGenCounter(uint32 CounterId); + +/*****************************************************************************/ +/** +** \brief Increments the specified generic counter +** +** \par Description +** This routine increments the specified generic counter. +** +** \par Assumptions, External Events, and Notes: +** None. +** +** \param[in] CounterId The Counter to be incremented. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode +** \endreturns +** +** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName +** +******************************************************************************/ +int32 CFE_ES_IncrementGenCounter(uint32 CounterId); + +/*****************************************************************************/ +/** +** \brief Set the specified generic counter +** +** \par Description +** This routine sets the specified generic counter to the specified value. +** +** \par Assumptions, External Events, and Notes: +** None. +** +** \param[in] CounterId The Counter to be set. +** +** \param[in] Count The new value of the Counter. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode +** \endreturns +** +** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_IncrementGenCounter, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName +** +******************************************************************************/ +int32 CFE_ES_SetGenCount(uint32 CounterId, uint32 Count); + +/*****************************************************************************/ +/** +** \brief Get the specified generic counter count +** +** \par Description +** This routine gets the value of a generic counter. +** +** \par Assumptions, External Events, and Notes: +** None. +** +** \param[in] CounterId The Counter to get the value from. +** +** \param[in] *Count The value of the Counter. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode +** \endreturns +** +** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_IncrementGenCounter, #CFE_ES_GetGenCounterIDByName +** +******************************************************************************/ +int32 CFE_ES_GetGenCount(uint32 CounterId, uint32 *Count); + + +/*****************************************************************************/ +/** +** \brief Get the Id associated with a generic counter name +** +** \par Description +** This routine gets the Counter Id for a generic counter specified by name. +** +** \par Assumptions, External Events, and Notes: +** None. +** +** \param[in] *CounterName The name of the Counter. +** +** \param[out] *CounterIdPtr The Counter Id for the given name. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode +** \endreturns +** +** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_IncrementGenCounter, #CFE_ES_GetGenCount +******************************************************************************/ +int32 CFE_ES_GetGenCounterIDByName(uint32 *CounterIdPtr, const char *CounterName); + +/*****************************************************************************/ +/** +** \brief Process an exception detected by the underlying OS/PSP +** +** \par Description +** This hook routine is called from the PSP when an exception occurs +** +** \par Assumptions, External Events, and Notes: +** None. +** +** \param[in] HostTaskId The OS (not OSAL) task ID +** \param[in] ReasonString Identifier from PSP +** \param[in] ContextPointer Context data from PSP +** \param[in] ContextSize Size of context data from PSP +** +******************************************************************************/ +void CFE_ES_ProcessCoreException(uint32 HostTaskId, const char *ReasonString, + const uint32 *ContextPointer, uint32 ContextSize); + + + +#endif /* _cfe_es_ */ diff --git a/src/components/interface/cFE/cfe_es_events.h b/src/components/interface/cFE/cfe_es_events.h new file mode 100644 index 0000000000..71b89f5bdc --- /dev/null +++ b/src/components/interface/cFE/cfe_es_events.h @@ -0,0 +1,1562 @@ +/* +** File: +** cfe_es_events.h +** $Id: cfe_es_events.h 1.6 2014/08/21 15:34:53GMT-05:00 sstrege Exp $ +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** +** +** Purpose: +** cFE Executive Services (ES) Event IDs +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** cFE Flight Software Application Developers Guide +** +** Notes: +** +** +** $Log: cfe_es_events.h $ +** Revision 1.6 2014/08/21 15:34:53GMT-05:00 sstrege +** Updated CFE_ES_ERREXIT_APP_ERR_EID from 31 to 33 +** Revision 1.5 2014/08/19 14:40:27EDT sstrege +** Fixed doxygen warnings +** Revision 1.4 2014/05/05 15:56:42EDT acudmore +** Fixed misleading event message text. +** Revision 1.3 2010/11/04 16:17:43GMT-05:00 jmdagost +** Updated Perf Analyzer start message, inserted perf analyzer error msg, updated subsequent event IDs. +** Revision 1.2 2008/12/08 12:07:19EST dkobe +** Updates to correct doxygen errors +** Revision 1.1 2008/04/17 08:05:19EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.32 2007/09/20 10:52:56EDT apcudmore +** Added Query All Tasks command, file definition, events, error codes etc. +** Revision 1.31 2007/09/18 16:39:10EDT apcudmore +** Updated ES invalid command length event message to make it clear. +** Revision 1.30 2007/06/02 10:10:10EDT dlkobe +** Added doxygen comments for User's Guides +** Revision 1.29 2007/05/25 11:51:39EDT dlkobe +** Modified doxygen to improve supporting docs +** Revision 1.28 2007/05/14 15:43:45EDT apcudmore +** Cleaned up events and disabled debug code for application restart. +** Revision 1.27 2007/05/11 11:59:05EDT apcudmore +** Removed Event IDs 33 and 34. +** They were no longer needed with the revised startup sync code. +** Revision 1.26 2007/05/11 10:15:07EDT rjmcgraw +** Added information to comments for CFE_ES_PERF_STOPCMD_EID +** Revision 1.25 2007/05/11 09:32:54EDT rjmcgraw +** DCR3211:2 Added 3 new perf events for 'in progress' checks +** Revision 1.24 2007/05/09 12:41:24EDT dlkobe +** Added event messages associated with Dump CDS Registry command +*/ +/*************************************************************************/ +#ifndef _cfe_es_events_ +#define _cfe_es_events_ + +/* +** ES task event message ID's. +*/ + +/** \brief 'cFE ES Initialized' +** \event 'cFE ES Initialized' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always automatically issued when the Executive Services +** Task completes its Initialization. +**/ +#define CFE_ES_INIT_INF_EID 1 /* start up message "informational" */ + +/** \brief 'cFE Version \%d.\%d.\%d chksm \%d, OSAL Version \%d.\%d' +** \event 'cFE Version \%d.\%d.\%d chksm \%d, OSAL Version \%d.\%d' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always automatically issued when the Executive Services +** Task completes its Initialization. +** +** The \c Version field identifies the tagged version for the cFE Build, the \c chksm field +** provides the 16-bit checksum of the cFE Build and the \c OSAL \c Version field identifies +** the version of the OS Abstraction Layer on which this particular version of the cFE was built. +**/ +#define CFE_ES_INITSTATS_INF_EID 2 + +/** \brief 'No-op command' +** \event 'No-op command' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always automatically issued in response +** to a cFE Executive Services \link #CFE_ES_NOOP_CC NO-OP command \endlink +**/ +#define CFE_ES_NOOP_INF_EID 3 /* processed command "informational" */ + +/** \brief 'Reset Counters command' +** \event 'Reset Counters command' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always automatically issued in response +** to a cFE Executive Services \link #CFE_ES_RESET_CC Reset Counters command \endlink +**/ +#define CFE_ES_RESET_INF_EID 4 + +/** \brief 'Invoked shell command \%s' +** \event 'Invoked shell command \%s' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always automatically issued in response +** to a cFE Executive Services \link #CFE_ES_SHELL_CMD_CC Shell Command \endlink +** +** The \c 's' string contains the actual shell command string issued. +**/ +#define CFE_ES_SHELL_INF_EID 5 + +/** \brief 'Started \%s from \%s, AppID = \%d' +** \event 'Started \%s from \%s, AppID = \%d' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is automatically issued upon successful completion of +** a cFE Executive Services \link #CFE_ES_START_APP_CC Start Application command \endlink +** +** The first \c 's' string identifies the name of the started Application, the +** second \c 's' string identifies the filename from which the Application was +** loaded and the \c AppId field specifies the Application ID assigned to the +** newly started Application by the cFE Executive Services. +**/ +#define CFE_ES_START_INF_EID 6 + +/** \brief 'Stop Application \%s Initiated.' +** \event 'Stop Application \%s Initiated.' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is issued upon successful processing of the +** cFE Executive Services \link #CFE_ES_STOP_APP_CC Stop Application command \endlink +** Note that when this event is displayed, the Application is not deleted. ES has +** accepted the request to delete the application, and it will be deleted after the app exits +** it's main loop, or times out. +** +** The \c 's' field identifies the name of the Application that will be stopped. +**/ +#define CFE_ES_STOP_DBG_EID 7 + +/** \brief 'Stop Application \%s Completed.' +** \event 'Stop Application \%s Completed.' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is issued when the cFE finishes deleting the cFE Application +** That was started when the \link #CFE_ES_STOP_APP_CC Stop Application command \endlink +** was issued. +** +** The \c 's' field identifies the name of the Application that was stopped. +*/ +#define CFE_ES_STOP_INF_EID 8 + +/** \brief 'Restart Application \%s Initiated.' +** \event 'Restart Application \%s Initiated.' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is issued upon successful processing of the +** cFE Executive Services \link #CFE_ES_RESTART_APP_CC Restart Application command \endlink +** Note that when this event is displayed, the Application is not restarted. ES has +** accepted the request to restart the application, and it will be restarted after the app exits +** it's main loop, or times out. +** +** The \c 's' field identifies the name of the Application that will be restarted. +**/ +#define CFE_ES_RESTART_APP_DBG_EID 9 + +/** \brief 'Restart Application \%s Completed.' +** \event 'Restart Application \%s Completed.' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is issued when the cFE finishes Restarting the cFE Application +** That was started when the \link #CFE_ES_RESTART_APP_CC Restart Application command \endlink +** was issued. +** +** The \c 's' field identifies the name of the Application that was reloaded. +*/ +#define CFE_ES_RESTART_APP_INF_EID 10 + + +/** \brief 'Reload Application \%s Initiated.' +** \event 'Reload Application \%s Initiated.' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is issued upon successful processing of the +** cFE Executive Services \link #CFE_ES_RELOAD_APP_CC Reload Application command \endlink +** Note that when this event is displayed, the Application is not reloaded. ES has +** accepted the request to reload the application, and it will be reloaded after the app exits +** it's main loop, or times out. +** +** +** The \c 's' field identifies the name of the Application that will be reloaded. +**/ +#define CFE_ES_RELOAD_APP_DBG_EID 11 + + +/** \brief 'Reload Application \%s Completed.' +** \event 'Reload Application \%s Completed.' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is issued when the cFE finishes Reloading the cFE Application +** That was started when the \link #CFE_ES_RELOAD_APP_CC Restart Application command \endlink +** was issued. +** +** The \c 's' field identifies the name of the Application that was reloaded. +*/ +#define CFE_ES_RELOAD_APP_INF_EID 12 + +/** \brief 'Exit Application \%s Completed.' +** \event 'Exit Application \%s Completed.' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is issued when the cFE finishes exiting/cleaning up an +** application that called the CFE_ES_ExitApp API with the CFE_ES_APP_EXIT parameter. +** When an App calls this API, the request is recorded and the Executive Services App will +** actually delete cFE Application before issuing this event message. +** +** The \c 's' field identifies the name of the Application that was exited. +*/ +#define CFE_ES_EXIT_APP_INF_EID 13 + +/** \brief 'Exit Application \%s Completed.' +** \event 'Exit Application \%s Completed.' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is issued when the cFE finishes exiting/cleaning up an +** application that called the CFE_ES_ExitApp API with an ERROR condition. +** When an App calls this API, with the CFE_ES_APP_ERROR parameter, it indicates +** that the Application exited due to an error condition. The details of the +** error that occurred should be given by the Application through an event message, +** System Log entry, or both. +** The request is recorded and the Executive Services App will actually delete +** cFE Application before issuing this event message. +** +** The \c 's' field identifies the name of the Application that was exited. +*/ +#define CFE_ES_ERREXIT_APP_INF_EID 14 + + +/** \brief 'Sent \%s application data' +** \event 'Sent \%s application data' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is issued upon successful completion of the +** cFE Executive Services \link #CFE_ES_QUERY_ONE_CC Query One Application command \endlink +** +** The \c 's' field identifies the name of the Application whose Executive Services +** Application information has been telemetered. +**/ +#define CFE_ES_ONE_APP_EID 15 + +/** \brief 'App Info file written to \%s, Entries=\%d, FileSize=\%d' +** \event 'App Info file written to \%s, Entries=\%d, FileSize=\%d' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is issued upon successful completion of the cFE Executive +** Services \link #CFE_ES_QUERY_ALL_CC Query All Applications command \endlink +** +** The \c 's' field identifies the name of the file to which all Executive Services Application +** data has been written. The \c Entries field identifies, in decimal, the number of Applications +** whose data was written and the \c FileSize field gives the total number of bytes written to the +** file. +**/ +#define CFE_ES_ALL_APPS_EID 16 + +/** \brief 'Cleared Executive Services log data' +** \event 'Cleared Executive Services log data' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated upon successful completion of the cFE Executive +** Services \link #CFE_ES_CLEAR_SYSLOG_CC Clear System Log command \endlink +**/ +#define CFE_ES_SYSLOG1_INF_EID 17 + +/** \brief '\%s written:Size=\%d,Entries=\%d' +** \event '\%s written:Size=\%d,Entries=\%d' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated when the System Log has been successfully written +** to a file after receiving the cFE Executive Services \link #CFE_ES_CLEAR_SYSLOG_CC Write Executive +** Services System Log command \endlink +** +** The \c 's' field identifies the name of the file written to, the \c Size field specifies, in decimal, +** the number of bytes written to the file and the \c Entries field identifies the number of System Log +** messages that were written. +**/ +#define CFE_ES_SYSLOG2_EID 18 + +/** \brief 'Cleared mode log data' +** \event 'Cleared mode log data' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated upon successful completion of the cFE Executive +** Services \link #CFE_ES_CLEAR_ERLOG_CC Clear Exception Reset Log command \endlink +**/ +#define CFE_ES_ERLOG1_INF_EID 19 + +/** \brief '\%s written:Size=\%d' +** \event '\%s written:Size=\%d' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated when the Exception Reset Log has been successfully written +** to a file after receiving the cFE Executive Services \link #CFE_ES_WRITE_ERLOG_CC Write Executive +** Services Exception Reset Log command \endlink +** +** The \c 's' field identifies the name of the file written to and the \c Size field specifies, in decimal, +** the number of bytes written to the file. +**/ +#define CFE_ES_ERLOG2_EID 20 + +/** \brief 'Invalid command pipe message ID: 0x\%X' +** \event 'Invalid command pipe message ID: 0x\%X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a message has arrived on +** the cFE Executive Services Application's Message Pipe that has a +** Message ID that is neither #CFE_ES_SEND_HK_MID or #CFE_ES_CMD_MID. +** Most likely, the cFE Software Bus routing table has become corrupt +** and is sending messages targeted for other Applications to the cFE +** Executive Services Application. +** +** The \c ID field in the event message identifies +** the message ID (in hex) that was found in the message. +**/ +#define CFE_ES_MID_ERR_EID 21 /* invalid command packet "error" */ + +/** \brief 'Invalid ground command code: ID = 0x\%X, CC = \%d' +** \event 'Invalid ground command code: ID = 0x\%X, CC = \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a message with the #CFE_ES_CMD_MID +** message ID has arrived but whose Command Code is not one of the command +** codes specified in \link #CFE_ES_NOOP_CC cfe_es.h \endlink. This +** problem is most likely to occur when: +** -# A Message ID meant for another Application became corrupted and was +** set equal to #CFE_ES_CMD_MID. +** -# The Command Code field in the Message became corrupted. +** -# The command database at the ground station has been corrupted. +** +** The \c ID field in the event message specifies the Message ID (in hex) and the +** \c CC field specifies the Command Code (in decimal) found in the message. +**/ +#define CFE_ES_CC1_ERR_EID 22 + +/** \brief 'Invalid cmd length: ID = 0x\%X, CC = \%d, Exp Len = \%d, Len = \%d' +** \event 'Invalid cmd length: ID = 0x\%X, CC = \%d, Exp Len = \%d, Len = \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a message with the #CFE_ES_CMD_MID +** message ID has arrived but whose packet length does not match the expected +** length for the specified command code. +** +** The \c ID field in the event message specifies the Message ID (in hex), the \c CC field +** specifies the Command Code (in decimal), the \c Exp Len field specified the Expected +** Length (in decimal ), and \c Len specifies the message Length (in decimal) +** found in the message. +**/ +#define CFE_ES_LEN_ERR_EID 23 + +/** \brief 'Invalid cFE restart type \%d' +** \event 'Invalid cFE restart type \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is issued when the cFE Executive Services receives a +** \link #CFE_ES_RESTART_CC cFE Restart Command \endlink whose parameter +** identifying the restart type is not equal to either #CFE_ES_PROCESSOR_RESET +** or #CFE_ES_POWERON_RESET. +** +** The 'd' field identifies the numeric, in decimal, of the restart type found +** in the received cFE Restart Command Packet. +**/ +#define CFE_ES_BOOT_ERR_EID 24 /* command specific "error" */ + +/** \brief 'Failed to invoke shell command \%s, rc = \%08X' +** \event 'Failed to invoke shell command \%s, rc = \%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever the cFE Executive Services receives an OS Shell +** command, via the \link #CFE_ES_SHELL_CMD_CC Executive Services Shell Command \endlink, and +** the underlying OS returns an error code. +** +** The 's' field in the message identifies the shell command string that was issued +** and the \c rc field displays the shell's return code, in hex. +**/ +#define CFE_ES_SHELL_ERR_EID 25 + +/** \brief 'Failed to start \%s from \%s, RC = \%08X' +** \event 'Failed to start \%s from \%s, RC = \%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated for an error encountered in response +** to an Executive Services \link #CFE_ES_START_APP_CC Start Application Command \endlink. +** +** This message is a general failure when the command passes the parameter validation, but +** fails when a call to CFE_ES_AppCreate is called. +** +** The \c 's' term identifies the name of the Application that was attempted to start. +** The second \c 's' field specifies the file from which the Application was loaded. +** The \c 'X' field is the return code returned by the CFE_ES_AppCreate. +**/ +#define CFE_ES_START_ERR_EID 26 + +/** \brief 'CFE_ES_StartAppCmd: invalid filename: \%s' +** \event 'CFE_ES_StartAppCmd: invalid filename: \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated for an error encountered in response +** to an Executive Services \link #CFE_ES_START_APP_CC Start Application Command \endlink. +** +** This message reports a command failure when the Start Appplication Command is given +** an invalid filename. ( Either NULL or too short to be a valid cFE file name ). +** +** The \c 's' term identifies the invalid filename that was sent with the command. +**/ +#define CFE_ES_START_INVALID_FILENAME_ERR_EID 27 + +/** \brief 'CFE_ES_StartAppCmd: App Entry Point is NULL.' +** \event 'CFE_ES_StartAppCmd: App Entry Point is NULL.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated for an error encountered in response +** to an Executive Services \link #CFE_ES_START_APP_CC Start Application Command \endlink. +** +** This message reports a command failure when the Start Appplication Command is given +** a NULL Application Entry Point parameter. The command must contain an application entry +** point string. ( Example: "SC_AppMain" ). +** +**/ +#define CFE_ES_START_INVALID_ENTRY_POINT_ERR_EID 28 + +/** \brief 'CFE_ES_StartAppCmd: App Name is NULL.' +** \event 'CFE_ES_StartAppCmd: App Name is NULL.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated for an error encountered in response +** to an Executive Services \link #CFE_ES_START_APP_CC Start Application Command \endlink. +** +** This message reports a command failure when the Start Appplication Command is given +** a NULL Application Name parameter. The command must contain an application name string. +**/ +#define CFE_ES_START_NULL_APP_NAME_ERR_EID 29 + +/** \brief 'CFE_ES_StartAppCmd: Stack size is less than system Minimum: \%d.' +** \event 'CFE_ES_StartAppCmd: Stack size is less than system Minimum: \%d.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated for an error encountered in response +** to an Executive Services \link #CFE_ES_START_APP_CC Start Application Command \endlink. +** +** This message reports a command failure when the Application Stack Size parameter is +** less than the default stack size defined in the cfe_platform_cfg.h file: CFE_ES_DEFAULT_STACK_SIZE. +** +** The \c 'd' term identifies the size of the stack that was given in the command. +**/ +#define CFE_ES_START_STACK_ERR_EID 30 + +/** \brief 'CFE_ES_StartAppCmd: Priority is too large: \%d.' +** \event 'CFE_ES_StartAppCmd: Priority is too large: \%d.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated for an error encountered in response +** to an Executive Services \link #CFE_ES_START_APP_CC Start Application Command \endlink. +** +** This message reports a command failure when the Application priority greater than the +** maximum priority for a Task defined by the OS Abstraction Layer ( 256 ). +** +** The \c 'd' term identifies the priority that was given in the command. +**/ +#define CFE_ES_START_PRIORITY_ERR_EID 31 + +/** \brief 'CFE_ES_StartAppCmd: Invalid Exception Action: \%d.' +** \event 'CFE_ES_StartAppCmd: Invalid Exception Action: \%d.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated for an error encountered in response +** to an Executive Services \link #CFE_ES_START_APP_CC Start Application Command \endlink. +** +** This message reports a command failure when the Application Exception Action parameter is +** invalid. The valid options for this parameter are: 0 = Application will restart on an exception +** 1 = Application cause a processor restart on +** exception. +** +** The \c 'd' term identifies the Exception Action parameter that was given in the command. +**/ +#define CFE_ES_START_EXC_ACTION_ERR_EID 32 + +/** \brief 'Exit Application \%s on Error Failed: CleanUpApp Error 0x\%08X.' +** \event 'Exit Application \%s on Error Failed: CleanUpApp Error 0x\%08X.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when ES is completing the processing of the +** CFE_ES_ExitApp API call with the CFE_ES_APP_ERROR parameter and the call to CFE_ES_CleanUpApp fails. +** At this point the Application will likely be stopped or deleted, but it may be in an unknown state. +** +** The \c 's' field identifies the name of the Application which was attempted to be +** reloaded and the \c RC field identifies the error code, in hex, that will identify +** the precise reason for the failure. +**/ +#define CFE_ES_ERREXIT_APP_ERR_EID 33 + +/** \brief 'Stop Application \%s Failed, RC = 0x\%08X' +** \event 'Stop Application \%s Failed, RC = 0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon receipt of an Executive Services +** \link #CFE_ES_STOP_APP_CC Stop Application Command \endlink which fails. +** +** The \c 's' field identifies the name of the Application which was attempted to be +** stopped and the \c rc field identifies the error code, in hex, that may identify +** the precise reason for the failure. +**/ +#define CFE_ES_STOP_ERR1_EID 35 + +/** \brief 'Stop Application \%s, GetAppIDByName failed. RC = 0x\%08X.' +** \event 'Stop Application \%s, GetAppIDByName failed. RC = 0x\%08X.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon receipt of an Executive Services +** \link #CFE_ES_STOP_APP_CC Stop Application Command \endlink which fails. This message +** is for a specific failure when the call to CFE_ES_GetAppIDByName fails. The application +** will not be deleted at this point. +** +** The \c 's' field identifies the name of the Application which was attempted to be +** stopped and the \c RC field identifies the error code, in hex, that will identify +** the precise reason for the failure. +**/ +#define CFE_ES_STOP_ERR2_EID 36 + +/* +** "Stop Application \%s Failed: CleanUpApp Error 0x\%08X." +*/ + +/** \brief 'Stop Application \%s Failed: CleanUpApp Error 0x\%08X.' +** \event 'Stop Application \%s Failed: CleanUpApp Error 0x\%08X.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon receipt of an Executive Services +** \link #CFE_ES_STOP_APP_CC Stop Application Command \endlink which fails. This message +** is for a specific failure when the call to CFE_ES_GetAppIDByName fails. The application +** will not be deleted at this point. +** +** The \c 's' field identifies the name of the Application which was attempted to be +** stopped and the \c RC field identifies the error code, in hex, that will identify +** the precise reason for the failure. +**/ +#define CFE_ES_STOP_ERR3_EID 37 + + +/** \brief 'Restart Application \%s Failed, RC = 0x\%08X' +** \event 'Restart Application \%s Failed, RC = 0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services \link #CFE_ES_RESTART_APP_CC Restart Application +** Command \endlink fails. +** +** The \c 's' field identifies the name of the Application which was attempted to be +** reset and the \c rc field identifies the error code, in hex, that may identify +** the precise reason for the failure. +**/ +#define CFE_ES_RESTART_APP_ERR1_EID 38 + +/** \brief 'Restart Application \%s, GetAppIDByName failed. RC = 0x\%08X.' +** \event 'Restart Application \%s, GetAppIDByName failed. RC = 0x\%08X.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon receipt of an Executive Services +** \link #CFE_ES_RESTART_APP_CC Restart Application Command \endlink which fails. This message +** is for a specific failure when the call to CFE_ES_GetAppIDByName fails. The application +** will not be restarted at this point. +** +** The \c 's' field identifies the name of the Application which was attempted to be +** restarted and the \c RC field identifies the error code, in hex, that will identify +** the precise reason for the failure. +**/ +#define CFE_ES_RESTART_APP_ERR2_EID 39 + +/* +** "Restart Application \%s Failed: AppCreate Error 0x\%08X." +*/ + +/** \brief 'Restart Application \%s Failed: AppCreate Error 0x\%08X.' +** \event 'Restart Application \%s Failed: AppCreate Error 0x\%08X.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon receipt of an Executive Services +** \link #CFE_ES_RESTART_APP_CC Restart Application Command \endlink which fails. This message +** is for a specific failure when the call to CFE_ES_AppCreate fails. The application +** will not be restarted at this point. +** +** The \c 's' field identifies the name of the Application which was attempted to be +** restarted and the \c RC field identifies the error code, in hex, that will identify +** the precise reason for the failure. +**/ +#define CFE_ES_RESTART_APP_ERR3_EID 40 + + +/** \brief 'Restart Application \%s Failed: CleanUpApp Error 0x\%08X.' +** \event 'Restart Application \%s Failed: CleanUpApp Error 0x\%08X.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon receipt of an Executive Services +** \link #CFE_ES_RESTART_APP_CC Restart Application Command \endlink which fails. This message +** is for a specific failure when the call to CFE_ES_CleanUpApp fails. The application +** will not be restarted at this point, but will likely be deleted or in an unknown state. +** +** The \c 's' field identifies the name of the Application which was attempted to be +** restarted and the \c RC field identifies the error code, in hex, that will identify +** the precise reason for the failure. +**/ +#define CFE_ES_RESTART_APP_ERR4_EID 41 + + +/** \brief 'Failed to reload Application \%s, rc = \%08X' +** \event 'Failed to reload Application \%s, rc = \%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services \link #CFE_ES_RELOAD_APP_CC Reload Application +** Command \endlink fails. +** +** The \c 's' field identifies the name of the Application which was attempted to be +** reloaded and the \c rc field identifies the error code, in hex, that may identify +** the precise reason for the failure. +**/ +#define CFE_ES_RELOAD_APP_ERR1_EID 42 + +/** \brief 'Reload Application \%s, GetAppIDByName failed. RC = 0x\%08X.' +** \event 'Reload Application \%s, GetAppIDByName failed. RC = 0x\%08X.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon receipt of an Executive Services +** \link #CFE_ES_RELOAD_APP_CC Reload Application Command \endlink which fails. This message +** is for a specific failure when the call to CFE_ES_GetAppIDByName fails. The application +** will not be reloaded at this point. +** +** The \c 's' field identifies the name of the Application which was attempted to be +** reloaded and the \c RC field identifies the error code, in hex, that will identify +** the precise reason for the failure. +**/ +#define CFE_ES_RELOAD_APP_ERR2_EID 43 + + +/** \brief 'Reload Application \%s Failed: AppCreate Error 0x\%08X.' +** \event 'Reload Application \%s Failed: AppCreate Error 0x\%08X.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon receipt of an Executive Services +** \link #CFE_ES_RELOAD_APP_CC Reload Application Command \endlink which fails. This message +** is for a specific failure when the call to CFE_ES_AppCreate fails. The application +** will not be reloaded at this point. +** +** The \c 's' field identifies the name of the Application which was attempted to be +** reloaded and the \c RC field identifies the error code, in hex, that will identify +** the precise reason for the failure. +**/ +#define CFE_ES_RELOAD_APP_ERR3_EID 44 + + +/** \brief 'Reload Application \%s Failed: CleanUpApp Error 0x\%08X.' +** \event 'Reload Application \%s Failed: CleanUpApp Error 0x\%08X.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon receipt of an Executive Services +** \link #CFE_ES_RELOAD_APP_CC Reload Application Command \endlink which fails. This message +** is for a specific failure when the call to CFE_ES_CleanUpApp fails. The application +** will not be reloaded at this point, and will likely be deleted or in an unknown state. +** +** The \c 's' field identifies the name of the Application which was attempted to be +** reloaded and the \c RC field identifies the error code, in hex, that will identify +** the precise reason for the failure. +**/ +#define CFE_ES_RELOAD_APP_ERR4_EID 45 + + +/** \brief 'Exit Application \%s Failed: CleanUpApp Error 0x\%08X.' +** \event 'Exit Application \%s Failed: CleanUpApp Error 0x\%08X.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when ES is completing the processing of the +** CFE_ES_ExitApp API call and the call to CFE_ES_CleanUpApp fails. At this point the Application will +** likely be stopped or deleted, but it may be in an unknown state. +** +** The \c 's' field identifies the name of the Application which was attempted to be +** reloaded and the \c RC field identifies the error code, in hex, that will identify +** the precise reason for the failure. +**/ +#define CFE_ES_EXIT_APP_ERR_EID 46 + + +/** \brief 'ES_ProcControlReq: Invalid State (EXCEPTION) Application \%s.' +** \event 'ES_ProcControlReq: Invalid State (EXCEPTION) Application \%s.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when ES is processing it's internal Application table and encounters +** an App with the EXCEPTION state. Because exceptions are supposed to be processed immediately, this is +** an invalid state and should not happen. It may indicate some sort of memory corruption or other problem. +**/ +#define CFE_ES_PCR_ERR1_EID 47 + + +/* +** "CFE_ES_CleanUpApp: Unknown State ( \%d ) Application \%s." +*/ +/** \brief 'ES_ProcControlReq: Unknown State ( \%d ) Application \%s.' +** \event 'ES_ProcControlReq: Unknown State ( \%d ) Application \%s.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when ES is processing it's internal Application table and encounters +** an App with an unknown state. If this message occurs, it might be an indication of a memory corruption +** or other problem. +**/ +#define CFE_ES_PCR_ERR2_EID 48 + +/** \brief 'Failed to send \%s application data, RC = \%08X' +** \event 'Failed to send \%s application data, RC = \%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services \link #CFE_ES_QUERY_ONE_CC Request Application +** Data Command \endlink failed. +** +** The \c 's' field identifies the name of the Application whose data was attempted +** to be telemetered and the \c rc field identifies the error code, in hex, that may identify +** the precise reason for the failure. +**/ +#define CFE_ES_ONE_ERR_EID 49 + +/** \brief 'Failed to send \%s application data: GetAppIDByName Failed, RC = 0x\%08X' +** \event 'Failed to send \%s application data: GetAppIDByName Failed, RC = 0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services \link #CFE_ES_QUERY_ONE_CC Request Application +** Data Command \endlink failed. +** +** The \c 's' field identifies the name of the Application whose data was attempted +** to be telemetered and the \c rc field identifies the error code, in hex, that may identify +** the precise reason for the failure. +**/ +#define CFE_ES_ONE_APPID_ERR_EID 50 + + +/** \brief 'Failed to write App Info file, OS_creat returned \%d' +** \event 'Failed to write App Info file, OS_creat returned \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services \link #CFE_ES_QUERY_ALL_CC Dump Application +** Data Command \endlink fails to create the dump file. +** +** The \c 'd' parameter identifies, in decimal, the error code returned by #OS_creat when the attempt was made +** to create the file. +**/ +#define CFE_ES_OSCREATE_ERR_EID 51 + +/** \brief 'Failed to write App Info file, WriteHdr rtnd \%08X, exp \%d' +** \event 'Failed to write App Info file, WriteHdr rtnd \%08X, exp \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services \link #CFE_ES_QUERY_ALL_CC Dump Application +** Data Command \endlink fails while writing the cFE Standard File Header. +** +** The \c rtnd field contains the error code returned by the #CFE_FS_WriteHeader API. Nominally, the +** returned result should have been equal to the \c exp field (i.e. - sizeof(#CFE_FS_Header_t)). +**/ +#define CFE_ES_WRHDR_ERR_EID 52 + + +/** \brief 'Failed to write App Info file, Task write RC = 0x\%08X, exp \%d' +** \event 'Failed to write App Info file, Task write RC = 0x\%08X, exp \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever an Executive Services \link #CFE_ES_QUERY_ALL_CC Dump Application +** Data Command \endlink fails while writing Application data to the specified file. +** +** The \c rtnd field contains, in hex, the error code returned from the #OS_write API. The expected return +** value is identified, in decimal, in the \c exp field. +**/ +#define CFE_ES_TASKWR_ERR_EID 53 + +/** \brief 'Error creating file \%s, stat=0x\%x' +** \event 'Error creating file \%s, stat=0x\%x' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services \link #CFE_ES_WRITE_SYSLOG_CC Dump System Log +** Command \endlink fails while attempting to create the specified file. +** +** The \c 's' field identifies the name of the file that was attempted to be created and the \c stat field +** specifies, in hex, the error code returned by the #OS_creat API. +**/ +#define CFE_ES_SYSLOG2_ERR_EID 55 + +/** \brief 'Error creating file \%s, stat=0x\%x' +** \event 'Error creating file \%s, stat=0x\%x' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services \link #CFE_ES_WRITE_ERLOG_CC Dump Exception Reset Log +** Command \endlink fails while attempting to create the specified file. +** +** The \c 's' field identifies the name of the file that was attempted to be created and the \c stat field +** specifies, in hex, the error code returned by the #OS_creat API. +**/ +#define CFE_ES_ERLOG2_ERR_EID 56 + +/** \brief 'Start collecting performance data command, trigger mode = %d' +** \event 'Start collecting performance data command, trigger mode = %d' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated in response to receiving an Executive Services +** \link #CFE_ES_PERF_STARTDATA_CC Start Performance Analyzer Data Collection Command \endlink +** +** The \c 'd' field identifies the requested trigger mode. Valid values are #CFE_ES_PerfMode_t CFE_ES_PERF_TRIGGER_START (0), +** #CFE_ES_PerfMode_t CFE_ES_PERF_TRIGGER_CENTER (1), and #CFE_ES_PerfMode_t CFE_ES_PERF_TRIGGER_END (2) +**/ +#define CFE_ES_PERF_STARTCMD_EID 57 + +/** \brief 'Cannot start collecting performance data,perf data write in progress' +** \event 'Cannot start collecting performance data,perf data write in progress' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated in response to receiving an Executive Services +** \link #CFE_ES_PERF_STARTDATA_CC Start Performance Analyzer Data Collection Command \endlink +**/ +#define CFE_ES_PERF_STARTCMD_ERR_EID 58 + + +/** \brief 'Cannot start collecting performance data, trigger mode (%d) out of range (%d to %d)' +** \event 'Cannot start collecting performance data, trigger mode (%d) out of range (%d to %d)' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services \link #CFE_ES_PERF_STARTDATA_CC +** Start Performance Analyzer Data Collection Command \endlink command is received with a bad +** value for the requested trigger mode. +** +** The first \c 'd' field identifies the received trigger mode value. +** The second and third \c 'd' fields specify the valid range of values for the trigger mode. Valid values +** are #CFE_ES_PerfMode_t CFE_ES_PERF_TRIGGER_START (0), #CFE_ES_PerfMode_t CFE_ES_PERF_TRIGGER_CENTER (1), and +** #CFE_ES_PerfMode_t CFE_ES_PERF_TRIGGER_END (2). +**/ +#define CFE_ES_PERF_STARTCMD_TRIG_ERR_EID 59 + + +/** \brief 'Perf Stop Cmd Rcvd,\%s will write \%d entries.\%dmS dly every \%d entries' +** \event 'Perf Stop Cmd Rcvd,\%s will write \%d entries.\%dmS dly every \%d entries' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon receipt of a successful Performance Data Stop +** Command after receiving the cFE Executive Services \link #CFE_ES_PERF_STOPDATA_CC Stop +** Performance Analyzer Data Collection Command \endlink +** +** The \c 's' field identifies the name of the file write task that has begun execution. +** The first \c 'd' identifies the total number of performance entries(in decimal) that will be written to the file. +** A performance data entry is defined by an unsigned 32 bit data point and an unsigned 64 bit time stamp. +** The second \c 'd' identifies the millisecond delay between writes and the +** third \c 'd' identifies the number of entries written (in decimal) between delays. +**/ +#define CFE_ES_PERF_STOPCMD_EID 60 + + +/** \brief 'Stop performance data cmd,Error creating child task RC=0x\%08X' +** \event 'Stop performance data cmd,Error creating child task RC=0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon receipt of an unsuccessful Performance Data Stop +** Command after receiving the cFE Executive Services \link #CFE_ES_PERF_STOPDATA_CC Stop +** Performance Analyzer Data Collection Command \endlink +** +** The \c 'RC' field specifies, in hex, the error code returned by the #CFE_ES_CreateChildTask API +** +**/ +#define CFE_ES_PERF_STOPCMD_ERR1_EID 61 + + +/** \brief 'Stop performance data cmd ignored,perf data write in progress' +** \event 'Stop performance data cmd ignored,perf data write in progress' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon receipt of an unsuccessful Performance Data Stop +** Command after receiving the cFE Executive Services \link #CFE_ES_PERF_STOPDATA_CC Stop +** Performance Analyzer Data Collection Command \endlink +** +**/ +#define CFE_ES_PERF_STOPCMD_ERR2_EID 62 + + +/** \brief 'Set Performance Filter Mask command' +** \event 'Set Performance Filter Mask command' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated in response to receiving an Executive Services +** \link #CFE_ES_PERF_SETFILTERMASK_CC Set Performance Analyzer Filter Mask Command \endlink. +** +**/ +#define CFE_ES_PERF_FILTMSKCMD_EID 63 + +/** \brief 'Error:Performance Filter Mask Index value +** greater than CFE_ES_PERF_32BIT_WORDS_IN_MASK (which is a whole number derived from +** CFE_ES_PERF_MAX_IDS / 32)' +** \event 'Error:Performance Filter Mask Index value +** greater than CFE_ES_PERF_32BIT_WORDS_IN_MASK (which is a whole number derived from +** CFE_ES_PERF_MAX_IDS / 32)' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated in response to receiving an Executive Services +** \link #CFE_ES_PERF_SETFILTERMASK_CC Set Performance Analyzer Filter Mask Command \endlink. +** +**/ +#define CFE_ES_PERF_FILTMSKERR_EID 64 + + +/** \brief 'Set Performance Trigger Mask command' +** \event 'Set Performance Trigger Mask command' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated in response to receiving an Executive Services +** \link #CFE_ES_PERF_SETTRIGMASK_CC Set Performance Analyzer Trigger Mask Command \endlink. +** +**/ +#define CFE_ES_PERF_TRIGMSKCMD_EID 65 + +/** \brief 'Error: Performance Trigger Mask Index value +** greater than CFE_ES_PERF_32BIT_WORDS_IN_MASK (which is a whole number derived from +** CFE_ES_PERF_MAX_IDS / 32)' +** \event 'Error: Performance Trigger Mask Index value +** greater than CFE_ES_PERF_32BIT_WORDS_IN_MASK (which is a whole number derived from +** CFE_ES_PERF_MAX_IDS / 32)' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated in response to receiving an Executive Services +** \link #CFE_ES_PERF_SETTRIGMASK_CC Set Performance Analyzer Trigger Mask Command \endlink. +** +**/ +#define CFE_ES_PERF_TRIGMSKERR_EID 66 + + +/** \brief 'Error creating file \%s, stat=\%d' +** \event 'Error creating file \%s, stat=\%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services +** \link #CFE_ES_PERF_STOPDATA_CC Stop Performance Analyzer Data Collection Command \endlink +** fails to create the associated logic analyzer dump file. +** +** The \c 's' field identifies the name of the file that was attempted to be created and the \c stat field +** specifies, in decimal, the error code returned by the #OS_creat API. +**/ +#define CFE_ES_PERF_LOG_ERR_EID 67 + + +/** \brief '\%s written:Size=\%d,EntryCount=\%d' +** \event '\%s written:Size=\%d,EntryCount=\%d' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated when the Performance Log has been successfully written +** to a file after receiving the cFE Executive Services \link #CFE_ES_PERF_STOPDATA_CC Stop +** Performance Analyzer Data Collection Command \endlink +** +** The \c 's' field identifies the name of the file written to, the \c Size field specifies, in decimal, +** the number of bytes written to the file and the \c EntryCount field identifies the number of data +** entries that were written. +**/ +#define CFE_ES_PERF_DATAWRITTEN_EID 68 + +/** \brief '\%s Failed to Register CDS '\%s', Status=0x\%08X' +** \event '\%s Failed to Register CDS '\%s', Status=0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever an Application calls the #CFE_ES_RegisterCDS API and +** fails to successfully create the desired CDS. +** +** The first \c 's' field identifies the name of the Application which made the API call, the second +** \c 's' field specifies the name of the CDS as requested by the Application and the \c Status field +** provides the error code which identifies in more detail the nature of the failure (See return codes +** for the #CFE_ES_RegisterCDS API). +**/ +#define CFE_ES_CDS_REGISTER_ERR_EID 69 + +/** \brief 'Set OverWriteSysLog Command Received with Mode setting = \%d' +** \event 'Set OverWriteSysLog Command Received with Mode setting = \%d' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon successful completion of an Executive Services \link #CFE_ES_OVERWRITE_SYSLOG_CC +** Set System Log Overwrite Mode Command \endlink. +** +** The \c setting field identifies the newly chosen Overwrite Mode and should be equal to either +** #CFE_ES_LOG_OVERWRITE or #CFE_ES_LOG_DISCARD. +**/ +#define CFE_ES_SYSLOGMODE_EID 70 + +/** \brief 'Set OverWriteSysLog Command: Invalid Mode setting = \%d' +** \event 'Set OverWriteSysLog Command: Invalid Mode setting = \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon unsuccessful completion of an Executive Services \link #CFE_ES_OVERWRITE_SYSLOG_CC +** Set System Log Overwrite Mode Command \endlink. +** +** The \c setting field identifies the illegal Overwrite Mode found in the command message. The mode +** must be either #CFE_ES_LOG_OVERWRITE (0) or #CFE_ES_LOG_DISCARD (1). +**/ +#define CFE_ES_ERR_SYSLOGMODE_EID 71 + +/** \brief 'Reset Processor Reset Count to Zero' +** \event 'Reset Processor Reset Count to Zero' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always generated in response to the Executive Services +** \link #CFE_ES_RESET_PR_COUNT_CC Set Processor Reset Counter to Zero Command \endlink. +**/ +#define CFE_ES_RESET_PR_COUNT_EID 72 + +/** \brief 'Maximum Processor Reset Count set to: \%d' +** \event 'Maximum Processor Reset Count set to: \%d' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always generated in response to the Executive Services +** \link #CFE_ES_RESET_PR_COUNT_CC Set Maximum Processor Reset Limit Command \endlink. +** +** The \c 'd' field identifies, in decimal, the number of Processor Resets that will need +** to occur before a Power-On Reset is automatically performed. +**/ +#define CFE_ES_SET_MAX_PR_COUNT_EID 73 + +/** \brief 'File write,byte cnt err,file \%s,request=\%d,actual=\%d' +** \event 'File write,byte cnt err,file \%s,request=\%d,actual=\%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated in response to any command requesting information to be written +** to a file and whose data is not completely written to the specified file. +** +** The \c file field identifies the filename of the file to which the data failed to write completely, +** the \c request field specifies, in decimal, the number of bytes that were attempted to be written and +** the \c actual field indicates, in decimal, the actual number of bytes written to the file. +**/ +#define CFE_ES_FILEWRITE_ERR_EID 74 + +/** \brief 'Error accessing ER Log,\%s not written.Stat=0x\%08x' +** \event 'Error accessing ER Log,\%s not written.Stat=0x\%08x' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated in response to an Exception Reset Log Dump command and there is +** an error obtaining the contents of the ER Log. +** +** The \c 's' field identifies the filename of the file to which the data failed to write, +** the \c Stat field specifies, in hex, the error status returned from #CFE_PSP_GetResetArea. +**/ +#define CFE_ES_RST_ACCESS_EID 75 + +/** \brief 'Error while deleting '\%s' from CDS, See SysLog.(Err=0x\%08X)' +** \event 'Error while deleting '\%s' from CDS, See SysLog.(Err=0x\%08X)' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services +** \link #CFE_ES_DELETE_CDS_CC Delete CDS Command \endlink +** fails to cleanly remove the specified CDS. +** +** The \c 's' field identifies the name of the CDS that was attempted to be deleted the \c Err field +** specifies, in hex, the error code. +**/ +#define CFE_ES_CDS_DELETE_ERR_EID 76 + +/** \brief 'Unable to locate '\%s' in CDS Registry' +** \event 'Unable to locate '\%s' in CDS Registry' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services +** \link #CFE_ES_DELETE_CDS_CC Delete CDS Command \endlink +** specifies a name for a CDS that cannot be found in the CDS Registry. +** +** The \c 's' field identifies the name of the CDS that was attempted to be deleted. +**/ +#define CFE_ES_CDS_NAME_ERR_EID 77 + +/** \brief 'Successfully removed '\%s' from CDS' +** \event 'Successfully removed '\%s' from CDS' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated when an Executive Services +** \link #CFE_ES_DELETE_CDS_CC Delete CDS Command \endlink +** is successfully completed. +** +** The \c 's' field identifies the name of the CDS that was deleted. +**/ +#define CFE_ES_CDS_DELETED_INFO_EID 78 + +/** \brief 'CDS '\%s' is a Critical Table CDS. Must be deleted via TBL Command' +** \event 'CDS '\%s' is a Critical Table CDS. Must be deleted via TBL Command' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services +** \link #CFE_ES_DELETE_CDS_CC Delete CDS Command \endlink +** specifies a name for a CDS that is a Critical Table image. +** Critical Table images can only be deleted via a Table Services +** command (#CFE_TBL_DELETE_CDS_CC). +** +** The \c 's' field identifies the name of the CDS that was attempted to be deleted. +**/ +#define CFE_ES_CDS_DELETE_TBL_ERR_EID 79 + +/** \brief 'CDS '\%s' not deleted because owning app is active' +** \event 'CDS '\%s' not deleted because owning app is active' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services +** \link #CFE_ES_DELETE_CDS_CC Delete CDS Command \endlink +** specifies a name for a CDS whose prefix name identifies +** an application that is still registered in the system. +** CDSs can only be deleted when their owning applications +** have been removed from the system. +** +** The \c 's' field identifies the name of the CDS that was attempted to be deleted. +**/ +#define CFE_ES_CDS_OWNER_ACTIVE_EID 80 + +/** \brief 'Successfully telemetered memory pool stats for 0x\%08X' +** \event 'Successfully telemetered memory pool stats for 0x\%08X' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated following successful execution of the +** \link #CFE_ES_TLM_POOL_STATS_CC Telemeter Memory Statistics Command \endlink. +**/ +#define CFE_ES_TLM_POOL_STATS_INFO_EID 81 + +/** \brief 'Cannot telemeter memory pool stats. Illegal Handle (0x\%08X)' +** \event 'Cannot telemeter memory pool stats. Illegal Handle (0x\%08X)' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services +** \link #CFE_ES_TLM_POOL_STATS_CC Telemeter Memory Statistics Command \endlink +** specifies a memory pool handle that is invalid. A handle is determined to +** be invalid when any of the following are true: +** -# The handle does not contain a value that is an integral multiple of 4 +** -# The handle does not specify a valid area of memory +** -# The handle does not point to an area of memory that contains the handle itself +** -# The handle does not point to an area of memory whose Size field is an integral multiple of 4 +** -# The handle does not point to an area of memory whose End field is equal to the Start plus the Size +** +** The \c '08X' field identifies the handle that was found in the command. +**/ +#define CFE_ES_INVALID_POOL_HANDLE_ERR_EID 82 + +/** \brief 'Successfully dumped CDS Registry to '\%s':Size=\%d,Entries=\%d' +** \event 'Successfully dumped CDS Registry to '\%s':Size=\%d,Entries=\%d' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated when an Executive Services +** \link #CFE_ES_DUMP_CDS_REG_CC Dump Critical Data Store Registry Command \endlink +** is successfully executed. The specified file should have been created +** and contains the CDS Registry Entries. +** +** The \c 's' field identifies the CDS Registry Dump Filename. +** The first \c 'd' field specifies the size of the file (in bytes) +** The second \c 'd' field specifies the number of CDS Registry Records that were written +**/ +#define CFE_ES_CDS_REG_DUMP_INF_EID 83 + +/** \brief 'Error writing CDS Registry to '\%s', Status=0x\%08X' +** \event 'Error writing CDS Registry to '\%s', Status=0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services +** \link #CFE_ES_DUMP_CDS_REG_CC Dump Critical Data Store Registry Command \endlink +** was being performed and it encountered a filesystem write error while writing +** a CDS Registry record. +** +** The \c 's' field identifies the CDS Registry Dump Filename. +** The \c '08X' field identifies the error code returned from #OS_write that caused the command to abort. +**/ +#define CFE_ES_CDS_DUMP_ERR_EID 84 + +/** \brief 'Error writing cFE File Header to '\%s', Status=0x\%08X' +** \event 'Error writing cFE File Header to '\%s', Status=0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services +** \link #CFE_ES_DUMP_CDS_REG_CC Dump Critical Data Store Registry Command \endlink +** command successfully created the CDS Dump File onboard but encountered an error +** while writing the standard cFE File Header to the file. +** +** The \c 's' field identifies the CDS Registry Dump Filename. +** The \c '08X' field identifies error code returned by the API #CFE_FS_WriteHeader. +**/ +#define CFE_ES_WRITE_CFE_HDR_ERR_EID 85 + +/** \brief 'Error creating CDS dump file '\%s', Status=0x\%08X' +** \event 'Error creating CDS dump file '\%s', Status=0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services +** \link #CFE_ES_DUMP_CDS_REG_CC Dump Critical Data Store Registry Command \endlink +** is unable to create the specified file on the onboard filesystem. +** +** The \c 's' field identifies the CDS Registry Dump Filename. +** The \c '08X' field identifies error code returned by the API #OS_creat. +**/ +#define CFE_ES_CREATING_CDS_DUMP_ERR_EID 86 + + +/** \brief 'Task Info file written to \%s, Entries=\%d, FileSize=\%d' +** \event 'Task Info file written to \%s, Entries=\%d, FileSize=\%d' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is issued upon successful completion of the cFE Executive +** Services \link #CFE_ES_QUERY_ALL_TASKS_CC Query All Tasks command \endlink +** +** The \c 's' field identifies the name of the file to which all Executive Services Task +** data has been written. The \c Entries field identifies, in decimal, the number of Tasks +** whose data was written and the \c FileSize field gives the total number of bytes written to the +** file. +**/ +#define CFE_ES_TASKINFO_EID 87 + + +/** \brief 'Failed to write Task Info file, OS_creat returned \%d' +** \event 'Failed to write Task Info file, OS_creat returned \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services \link #CFE_ES_QUERY_ALL_TASKS_CC Dump Task +** Data Command \endlink fails to create the dump file. +** +** The \c 'd' parameter identifies, in decimal, the error code returned by #OS_creat when the attempt was made +** to create the file. +**/ +#define CFE_ES_TASKINFO_OSCREATE_ERR_EID 88 + +/** \brief 'Failed to write Task Info file, WriteHdr rtnd \%08X, exp \%d' +** \event 'Failed to write Task Info file, WriteHdr rtnd \%08X, exp \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Executive Services \link #CFE_ES_QUERY_ALL_TASKS_CC Dump Task +** Data Command \endlink fails while writing the cFE Standard File Header. +** +** The \c rtnd field contains the error code returned by the #CFE_FS_WriteHeader API. Nominally, the +** returned result should have been equal to the \c exp field (i.e. - sizeof(#CFE_FS_Header_t)). +**/ +#define CFE_ES_TASKINFO_WRHDR_ERR_EID 89 + + +/** \brief 'Failed to write Task Info file, Task write RC = 0x\%08X, exp \%d' +** \event 'Failed to write Task Info file, Task write RC = 0x\%08X, exp \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever an Executive Services \link #CFE_ES_QUERY_ALL_TASKS_CC Dump Tasks +** Data Command \endlink fails while writing Tasks data to the specified file. +** +** The \c rtnd field contains, in hex, the error code returned from the #OS_write API. The expected return +** value is identified, in decimal, in the \c exp field. +**/ +#define CFE_ES_TASKINFO_WR_ERR_EID 90 + + +/** \brief 'Mission %s.%s, %s, %s' +** \event 'Mission %s.%s, %s, %s' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always automatically issued when the Executive Services +** Task completes its Initialization +** +** The \c Mission field identifies the tagged build identifiers and configuration name. +** If available, this will also indicate the revision control identifiers for CFE and OSAL +** that this binary was built with. +**/ +#define CFE_ES_VERSION_INF_EID 91 + +/** \brief 'Build %s %s' +** \event 'Build %s %s' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always automatically issued when the Executive Services +** Task completes its Initialization, and as part of the Noop command. +** +** The \c Build field identifies the build date, time, hostname and user identifier of +** the build host machine for the current running binary. The first string is the +** build date/time, and the second string is formatted as "user@hostname" +** +** By default, if not specified/overridden, the default values of these variables will be: +** BUILDDATE ==> the output of "date +%Y%m%d%H%M" +** HOSTNAME ==> the output of "hostname" +** USER ==> the output of "whoami" +** +** The values can be overridden by setting an environment variable with the names above +** to the value desired for the field when running "make". +**/ +#define CFE_ES_BUILD_INF_EID 92 + + + +#endif /* _cfe_es_events_ */ + +/************************/ +/* End of File Comment */ +/************************/ diff --git a/src/components/interface/cFE/cfe_es_msg.h b/src/components/interface/cFE/cfe_es_msg.h new file mode 100644 index 0000000000..5f912a0cde --- /dev/null +++ b/src/components/interface/cFE/cfe_es_msg.h @@ -0,0 +1,1666 @@ +/* +** File: +** cfe_es_msg.h +** $Id: cfe_es_msg.h 1.13 2014/08/19 13:30:55GMT-05:00 sstrege Exp $ +** +** Copyright (c) 2004-2012, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** +** Purpose: +** cFE Executive Services (ES) Command and Telemetry packet definition file. +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** cFE Flight Software Application Developers Guide +** +** Notes: +** +** +** $Log: cfe_es_msg.h $ +** Revision 1.13 2014/08/19 13:30:55GMT-05:00 sstrege +** Fixed doxygen warning - updated reference to OS_MAX_PRIORITY to MAX_PRIORITY +** Revision 1.12 2012/01/18 16:28:56EST jmdagost +** Replaced Padding HK telemetry points with OSAL revision and mission revision. +** Revision 1.11 2012/01/13 12:32:14EST acudmore +** Changed license text to reflect open source +** Revision 1.10 2012/01/10 13:35:13EST lwalling +** Add output filename to shell command packet structure +** Revision 1.9 2011/01/18 13:42:37EST lwalling +** Fix incorrect structure name in Doxygen comment +** Revision 1.8 2010/11/24 09:18:25EST jmdagost +** Removed unneeded padding byte from housekeeping packet. +** Revision 1.7 2010/11/23 15:29:23EST jmdagost +** Added cFE Mission Revision telemetry point in Housekeeping, changed cFE SubMinor Version to cFE Revision. +** Revision 1.6 2010/11/04 17:16:01EDT jmdagost +** Added TriggerMode parameter to Performance Analyzer Start cmd, updated documentation. +** Revision 1.5 2010/11/04 14:20:20EDT acudmore +** Changed comments to reflect RAM disk path configuration option. +** Revision 1.4 2009/08/04 13:34:17EDT aschoeni +** Added heap information to ES telemetry +** Revision 1.3 2008/12/08 12:06:54EST dkobe +** Updates to correct doxygen errors +** Revision 1.2 2008/06/20 15:40:28EDT apcudmore +** Added support for OSAL based module loader +** - Removed calls and references to the BSP based module loader +** Revision 1.1 2008/04/17 08:05:20EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.16 2007/09/27 15:54:57EDT David Kobe (dlkobe) +** Added doxygen comments for commands and telemetry +** Revision 1.15 2007/09/25 14:38:53EDT David Kobe (dlkobe) +** Added Criticality note to Memory Pool Stats command description. +** Revision 1.14 2007/09/20 10:52:57EDT apcudmore +** Added Query All Tasks command, file definition, events, error codes etc. +** Revision 1.13 2007/06/07 16:03:55EDT dlkobe +** Corrected doxygen comment syntax errors +** Revision 1.12 2007/06/07 13:07:48EDT dlkobe +** Added Command and Telemetry doxygen comments to TIME, EVS and SB +** Revision 1.11 2007/06/02 10:10:13EDT dlkobe +** Added doxygen comments for User's Guides +** Revision 1.10 2007/05/09 12:41:44EDT dlkobe +** Added command structure for Dump CDS Registry Command +** Revision 1.8 2007/05/04 20:07:52EDT dlkobe +** Added command to telemeter memory pool statistics +** Revision 1.7 2007/04/25 11:57:04EDT apcudmore +** Implemented "Back End" of Application Restart and Delete. +** Changes include all ES Cleanup code to delete App and Task Resources. +** Revision 1.6 2007/04/20 14:22:42EDT rjmcgraw +** Renamed performance structs for consistency +** +*/ +/*************************************************************************/ +#ifndef _cfe_es_msg_ +#define _cfe_es_msg_ + +/* +** Includes +*/ +#include "cfe.h" +#include "cfe_es.h" + +/* +** ES task command packet command codes +*/ +/** \name Executive Services Command Codes */ +/** \{ */ +/** \cfeescmd Executive Services No-Op +** +** \par Description +** This command performs no other function than to increment the +** command execution counter. The command may be used to verify +** general aliveness of the Executive Services task. +** +** \cfecmdmnemonic \ES_NOOP +** +** \par Command Structure +** #CFE_ES_NoArgsCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_NOOP_INF_EID informational event message will +** be generated +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - the #CFE_ES_LEN_ERR_EID error event message will be generated +** +** \par Criticality +** None +** +** \sa +*/ +#define CFE_ES_NOOP_CC 0 + +/** \cfeescmd Executive Services Reset Counters +** +** \par Description +** This command resets the following counters within the Executive +** Services housekeeping telemetry: +** - Command Execution Counter +** - Command Error Counter +** +** \cfecmdmnemonic \ES_RESETCTRS +** +** \par Command Structure +** #CFE_ES_NoArgsCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_RESET_INF_EID informational event message will be +** generated +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - the #CFE_ES_LEN_ERR_EID error event message will be generated +** +** \par Criticality +** This command is not inherently dangerous. However, it is +** possible for ground systems and on-board safing procedures +** to be designed such that they react to changes in the counter +** values that are reset by this command. +** +** \sa #CFE_ES_RESET_PR_COUNT_CC +*/ +#define CFE_ES_RESET_CC 1 + +/** \cfeescmd Executive Services Processor / Power-On Reset +** +** \par Description +** This command restarts the cFE in one of two modes. The Power-On Reset +** will cause the cFE to restart as though the power were first applied +** to the processor. The Processor Reset will attempt to retain the contents +** of the volatile disk and the contents of the Critical Data Store. +** NOTE: If a requested Processor Reset should cause the +** Processor Reset Counter (\b \c \ES_PROCRESETCNT) +** to exceed OR EQUAL the limit #CFE_ES_MAX_PROCESSOR_RESETS (which is reported in +** housekeeping telemetry as \b \c \ES_MAXPROCRESETS), +** the command is \b AUTOMATICALLY upgraded to a Power-On Reset. +** +** \cfecmdmnemonic \ES_RESET +** +** \par Command Structure +** #CFE_ES_RestartCmd_t +** +** \par Command Verification +** Successful execution of this command (as a Processor Reset) +** may be verified with the following telemetry: +** - \b \c \ES_PROCRESETCNT - processor reset counter will increment +** - New entries in the Exception Reset Log and System Log can be found
+** NOTE: Verification of a Power-On Reset is shown through the loss of +** data nominally retained through a Processor Reset
+** NOTE: Since the reset of the processor resets the command execution +** counter (\b \c \ES_CMDPC), this counter \b CANNOT be used to verify +** command execution. +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - The \link #CFE_ES_RestartCmd_t.RestartType Restart Type \endlink was +** not a recognized value. +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - the #CFE_ES_BOOT_ERR_EID error event message will be generated +** +** \par Criticality +** This command is, by definition, dangerous. Significant loss of +** data will occur. All processes and the cFE itself will be stopped +** and restarted. With the Power-On reset option, all data on the +** volatile disk and the contents of the Critical Data Store will be +** lost. +** +** \sa #CFE_ES_RESET_PR_COUNT_CC, #CFE_ES_SET_MAX_PR_COUNT_CC +*/ +#define CFE_ES_RESTART_CC 2 + +/** \cfeescmd Executive Services O/S Shell Command +** +** \par Description +** This command passes an ASCII string as a command line to the +** underlying realtime operating system shell. Any response to +** the command is both written to the shell command output file +** and sent as a series of shell command output telemetry packets. +** +** If the shell command output filename argument is empty, then +** #CFE_ES_DEFAULT_SHELL_FILENAME will be used as the filename. +** +** \cfecmdmnemonic \ES_SHELL +** +** \par Command Structure +** #CFE_ES_ShellCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_SHELL_INF_EID informational event message will be +** generated +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - Failure to create the shell command output file +** - The shell command started with ES_ but was not one of the +** recognized cFE shell commands +** - There was an error while performing a #OS_lseek on the shell command output file +** - There was an error while redirecting the shell command response to the +** shell command output file +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - the #CFE_ES_SHELL_ERR_EID error event message will be generated +** - Additional information on the error should be found in the System Log +** +** \par Criticality +** This command should be used with caution. Interfering with the +** operation of the underlying realtime operating system can cause +** significant problems. +** +** \sa +*/ +#define CFE_ES_SHELL_CMD_CC 3 + +/** \cfeescmd Load and Start an Application +** +** \par Description +** This command starts the specified application with the +** specified start address, stack size, etc options. +** +** \cfecmdmnemonic \ES_STARTAPP +** +** \par Command Structure +** #CFE_ES_StartAppCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_START_INF_EID informational event message will be +** generated +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - The specified application filename string is either a NULL string +** or less than four characters in length +** - The specified application entry point is a NULL string +** - The specified application name is a NULL string +** - The specified stack size is less than #CFE_ES_DEFAULT_STACK_SIZE +** - The specified priority is greater than MAX_PRIORITY (as defined in osapi.c) +** - The specified exception action is neither #CFE_ES_APP_EXCEPTION_RESTART_APP (0) or +** #CFE_ES_APP_EXCEPTION_PROC_RESTART (1) +** - The Operating System was unable to load the specified application file +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** This command is not inherently dangerous although system resources +** could be taxed beyond their limits with the starting of erroneous +** or invalid applications. +** +** \sa #CFE_ES_STOP_APP_CC, #CFE_ES_RESTART_APP_CC, #CFE_ES_RELOAD_APP_CC +*/ +#define CFE_ES_START_APP_CC 4 + +/** \cfeescmd Stop and Unload Application +** +** \par Description +** This command halts and removes the specified Application +** from the system. \b NOTE: This command should never be used +** on the Command Ingest application. This would prevent further +** commands from entering the system. If Command Ingest needs to +** be stopped and restarted, use #CFE_ES_RESTART_APP_CC or +** #CFE_ES_RELOAD_APP_CC. +** +** \cfecmdmnemonic \ES_STOPAPP +** +** \par Command Structure +** #CFE_ES_AppNameCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_STOP_DBG_EID debug event message will be +** generated. NOTE: This event message only identifies that the +** stop has been started, not that is has completed. +** - Once the stop has successfully completed, the list of Applications +** and Tasks created in response to the \b \c \ES_WRITEAPPINFO2FILE, +** \b \c \ES_WRITETASKINFO2FILE should no longer contain the +** specified application. +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - The specified application name is not recognized as an active application +** - The specified application is one of the cFE's Core applications (ES, EVS, SB, TBL, TIME) +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** - Additional information on the reason for command failure may be found +** in the System Log +** +** \par Criticality +** This command is not inherently dangerous, however the removal of certain +** applications (e.g. - Spacecraft Attitude and Control) may have a detrimental effect +** on the spacecraft. +** +** \sa #CFE_ES_START_APP_CC, #CFE_ES_RESTART_APP_CC, #CFE_ES_RELOAD_APP_CC +*/ +#define CFE_ES_STOP_APP_CC 5 + +/** \cfeescmd Stops and Restarts an Application +** +** \par Description +** This command halts and restarts the specified Application. +** This command does \b NOT reload the application from the onboard +** filesystem. +** +** \cfecmdmnemonic \ES_RESTARTAPP +** +** \par Command Structure +** #CFE_ES_AppNameCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_RESTART_APP_DBG_EID debug event message will be +** generated. NOTE: This event message only identifies that the +** act of stopping the application has begun, not that is has completed. +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - The specified application name is not recognized as an active application +** - The specified application is one of the cFE's Core applications (ES, EVS, SB, TBL, TIME) +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** - Additional information on the reason for command failure may be found +** in the System Log +** +** \par Criticality +** This command is not inherently dangerous, however the restarting of certain +** applications (e.g. - Spacecraft Attitude and Control) may have a detrimental effect +** on the spacecraft. +** +** \sa #CFE_ES_START_APP_CC, #CFE_ES_STOP_APP_CC, #CFE_ES_RELOAD_APP_CC +*/ +#define CFE_ES_RESTART_APP_CC 6 + +/** \cfeescmd Stops, Unloads, Loads from a File and Restarts an Application +** +** \par Description +** This command halts and removes the specified Application +** from the system. Then it immediately loads the Application from +** the command specified file and restarts it. This command is +** especially useful for restarting a Command Ingest Application +** since once it has been stopped, no further commands can come in +** to restart it. +** +** \cfecmdmnemonic \ES_RELOADAPP +** +** \par Command Structure +** #CFE_ES_AppReloadCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_RELOAD_APP_DBG_EID debug event message will be +** generated. NOTE: This event message only identifies that the +** act of stopping the application has begun, not that is has completed. +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - The specified application name is not recognized as an active application +** - The specified application is one of the cFE's Core applications (ES, EVS, SB, TBL, TIME) +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** - Additional information on the reason for command failure may be found +** in the System Log +** +** \par Criticality +** This command is not inherently dangerous, however the restarting of certain +** applications (e.g. - Spacecraft Attitude and Control) may have a detrimental effect +** on the spacecraft. +** +** \sa #CFE_ES_START_APP_CC, #CFE_ES_STOP_APP_CC, #CFE_ES_RESTART_APP_CC +*/ +#define CFE_ES_RELOAD_APP_CC 7 + +/** \cfeescmd Request Executive Services Information on a Specified Application +** +** \par Description +** This command takes the information kept by Executive Services on the +** specified application and telemeters it to the ground. +** +** \cfecmdmnemonic \ES_QUERYAPP +** +** \par Command Structure +** #CFE_ES_AppNameCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_ONE_APP_EID debug event message will be +** generated. NOTE: This event message only identifies that the +** act of stopping the application has begun, not that is has completed. +** - Receipt of the #CFE_ES_OneAppTlm_t telemetry packet +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - The specified application name is not recognized as an active application +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** None +** +** \sa #CFE_ES_QUERY_ALL_CC, #CFE_ES_QUERY_ALL_TASKS_CC +*/ +#define CFE_ES_QUERY_ONE_CC 8 + +/** \cfeescmd Writes all Executive Services Information on All Applications to a File +** +** \par Description +** This command takes the information kept by Executive Services on all of the +** registered applications and writes it to the specified file. +** +** \cfecmdmnemonic \ES_WRITEAPPINFO2FILE +** +** \par Command Structure +** #CFE_ES_QueryAllCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_ALL_APPS_EID debug event message will be +** generated. +** - The file specified in the command (or the default specified +** by the #CFE_ES_DEFAULT_APP_LOG_FILE configuration parameter) will be +** updated with the lastest information. +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - An Error occurs while trying to write to the file +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** This command is not inherently dangerous. It will create a new +** file in the file system (or overwrite an existing one) and could, +** if performed repeatedly without sufficient file management by the +** operator, fill the file system. +** +** \sa #CFE_ES_QUERY_ONE_CC, #CFE_ES_QUERY_ALL_TASKS_CC +*/ +#define CFE_ES_QUERY_ALL_CC 9 + +/** \cfeescmd Clear Executive Services System Log +** +** \par Description +** This command clears the contents of the Executive Services System Log. +** +** \cfecmdmnemonic \ES_CLEARSYSLOG +** +** \par Command Structure +** #CFE_ES_NoArgsCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_SYSLOG1_INF_EID informational event message will be +** generated. +** - \b \c \ES_SYSLOGBYTEUSED - System Log Bytes Used will go to zero +** - \b \c \ES_SYSLOGENTRIES - Number of System Log Entries will go to zero +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** This command is not dangerous. However, any previously logged data +** will be lost. +** +** \sa #CFE_ES_WRITE_SYSLOG_CC, #CFE_ES_CLEAR_ERLOG_CC, #CFE_ES_WRITE_ERLOG_CC, +** #CFE_ES_OVERWRITE_SYSLOG_CC +*/ +#define CFE_ES_CLEAR_SYSLOG_CC 10 + +/** \cfeescmd Writes contents of Executive Services System Log to a File +** +** \par Description +** This command causes the contents of the Executive Services System Log +** to be written to a log file. +** +** \cfecmdmnemonic \ES_WRITESYSLOG2FILE +** +** \par Command Structure +** #CFE_ES_WriteSyslogCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_SYSLOG2_EID debug event message will be +** generated. +** - The file specified in the command (or the default specified +** by the #CFE_ES_DEFAULT_SYSLOG_FILE configuration parameter) will be +** updated with the lastest information. +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - An Error occurs while trying to write to the file +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** This command is not inherently dangerous. It will create a new +** file in the file system (or overwrite an existing one) and could, +** if performed repeatedly without sufficient file management by the +** operator, fill the file system. +** +** \sa #CFE_ES_CLEAR_SYSLOG_CC, #CFE_ES_CLEAR_ERLOG_CC, #CFE_ES_WRITE_ERLOG_CC, +** #CFE_ES_OVERWRITE_SYSLOG_CC +*/ +#define CFE_ES_WRITE_SYSLOG_CC 11 + +/** \cfeescmd Clears the contents of the Exeception and Reset Log +** +** \par Description +** This command causes the contents of the Executive Services Exception +** and Reset Log to be cleared. +** +** \cfecmdmnemonic \ES_CLEARERLOG +** +** \par Command Structure +** #CFE_ES_NoArgsCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_ERLOG1_INF_EID informational event message will be +** generated. +** - \b \c \ES_ERLOGINDEX - Index into Exception Reset Log goes to zero +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** This command is not dangerous. However, any previously logged data +** will be lost. +** +** \sa #CFE_ES_CLEAR_SYSLOG_CC, #CFE_ES_WRITE_SYSLOG_CC, #CFE_ES_WRITE_ERLOG_CC +*/ +#define CFE_ES_CLEAR_ERLOG_CC 12 + +/** \cfeescmd Writes Exeception and Reset Log to a File +** +** \par Description +** This command causes the contents of the Executive Services Exception +** and Reset Log to be written to the specified file. +** +** \cfecmdmnemonic \ES_WRITEERLOG2FILE +** +** \par Command Structure +** #CFE_ES_WriteERlogCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_ERLOG2_EID debug event message will be +** generated. +** - The file specified in the command (or the default specified +** by the #CFE_ES_DEFAULT_ER_LOG_FILE configuration parameter) will be +** updated with the lastest information. +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - An Error occurs while trying to write to the file +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** This command is not inherently dangerous. It will create a new +** file in the file system (or overwrite an existing one) and could, +** if performed repeatedly without sufficient file management by the +** operator, fill the file system. +** +** \sa #CFE_ES_CLEAR_SYSLOG_CC, #CFE_ES_WRITE_SYSLOG_CC, #CFE_ES_CLEAR_ERLOG_CC +*/ +#define CFE_ES_WRITE_ERLOG_CC 13 + +/** \cfeescmd Start Performance Analyzer +** +** \par Description +** This command causes the Performance Analyzer to begin collecting data using the specified trigger mode. +** +** \cfecmdmnemonic \ES_STARTLADATA +** +** \par Command Structure +** #CFE_ES_PerfStartCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - \b \c \ES_PERFSTATE - Current performance analyzer state will change to +** either WAITING FOR TRIGGER or, if conditions are appropriate fast enough, +** TRIGGERED. +** - \b \c \ES_PERFMODE - Performance Analyzer Mode will change to the commanded trigger mode (TRIGGER START, +** TRIGGER CENTER, or TRIGGER END). +** - \b \c \ES_PERFTRIGCNT - Performance Trigger Count will go to zero +** - \b \c \ES_PERFDATASTART - Data Start Index will go to zero +** - \b \c \ES_PERFDATAEND - Data End Index will go to zero +** - \b \c \ES_PERFDATACNT - Performance Data Counter will go to zero +** - The #CFE_ES_PERF_STARTCMD_EID debug event message will be +** generated. +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - A previous #CFE_ES_PERF_STOPDATA_CC command has not completely finished. +** - An invalid trigger mode is requested. +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** This command is not inherently dangerous but may cause a small increase in CPU +** utilization as the performance analyzer data is collected. +** +** \sa #CFE_ES_PERF_STOPDATA_CC, #CFE_ES_PERF_SETFILTERMASK_CC, #CFE_ES_PERF_SETTRIGMASK_CC +*/ +#define CFE_ES_PERF_STARTDATA_CC 14 + +/** \cfeescmd Stop Performance Analyzer +** +** \par Description +** This command stops the Performance Analyzer from collecting any more data. +** +** \cfecmdmnemonic \ES_STOPLADATA +** +** \par Command Structure +** #CFE_ES_PerfStopCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - \b \c \ES_PERFSTATE - Current performance analyzer state will change to +** IDLE. +** - The #CFE_ES_PERF_STOPCMD_EID debug event message will be +** generated. +** - The file specified in the command (or the default specified +** by the #CFE_ES_DEFAULT_PERF_DUMP_FILENAME configuration parameter) will be +** updated with the lastest information. +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - A previous Stop Performance Analyzer command is still in process +** - An error occurred while spawning the child task responsible for +** dumping the Performance Analyzer data to a file +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** This command is not inherently dangerous. An additional low priority child +** task will be spawned, however, to dump the performance analyzer data to a file. +** +** \sa #CFE_ES_PERF_STARTDATA_CC, #CFE_ES_PERF_SETFILTERMASK_CC, #CFE_ES_PERF_SETTRIGMASK_CC +*/ +#define CFE_ES_PERF_STOPDATA_CC 15 + +/** \cfeescmd Set Performance Analyzer's Filter Masks +** +** \par Description +** This command sets the Performance Analyzer's Filter Masks. +** +** \cfecmdmnemonic \ES_LAFILTERMASK +** +** \par Command Structure +** #CFE_ES_PerfSetFilterMaskCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - \B \C \ES_PERFFLTRMASK - the current performance filter mask +** value(s) should reflect the commanded value +** - The #CFE_ES_PERF_FILTMSKCMD_EID debug event message will be +** generated. +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - The Filter Mask ID number is out of range +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** Changing the filter masks may cause a small change in the Performance +** Analyzer's CPU utilization. +** +** \sa #CFE_ES_PERF_STARTDATA_CC, #CFE_ES_PERF_STOPDATA_CC, #CFE_ES_PERF_SETTRIGMASK_CC +*/ +#define CFE_ES_PERF_SETFILTERMASK_CC 16 + +/** \cfeescmd Set Performance Analyzer's Trigger Masks +** +** \par Description +** This command sets the Performance Analyzer's Trigger Masks. +** +** \cfecmdmnemonic \ES_LATRIGGERMASK +** +** \par Command Structure +** #CFE_ES_PerfSetTrigMaskCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - \b \c \ES_PERFTRIGMASK - the current performance trigger mask +** value(s) should reflect the commanded value +** - The #CFE_ES_PERF_TRIGMSKCMD_EID debug event message will be +** generated. +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - The Trigger Mask ID number is out of range +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** Changing the trigger masks may cause a small change in the Performance +** Analyzer's CPU utilization. +** +** \sa #CFE_ES_PERF_STARTDATA_CC, #CFE_ES_PERF_STOPDATA_CC, #CFE_ES_PERF_SETFILTERMASK_CC +*/ +#define CFE_ES_PERF_SETTRIGMASK_CC 17 + +/** \cfeescmd Set Executive Services System Log Mode to Discard/Overwrite +** +** \par Description +** This command allows the user to configure the Executive Services +** to either discard new System Log messages when it is full or to +** overwrite the oldest messages. +** +** \cfecmdmnemonic \ES_OVERWRITESYSLOGMODE +** +** \par Command Structure +** #CFE_ES_OverWriteSysLogCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - \b \c \ES_SYSLOGMODE - Current System Log Mode should reflect +** the commanded value +** - The #CFE_ES_SYSLOGMODE_EID debug event message will be +** generated. +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - The desired mode is neither #CFE_ES_LOG_OVERWRITE or #CFE_ES_LOG_DISCARD +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** None. (It should be noted that "Overwrite" mode would allow a message +** identifying the cause of a problem to be lost by a subsequent flood of +** additional messages). +** +** \sa #CFE_ES_CLEAR_SYSLOG_CC, #CFE_ES_WRITE_SYSLOG_CC +*/ +#define CFE_ES_OVERWRITE_SYSLOG_CC 18 + +/** \cfeescmd Resets the Processor Reset Counter to Zero +** +** \par Description +** This command allows the user to reset the Processor Reset Counter to zero. +** The Processor Reset Counter counts the number of Processor Resets that +** have occurred so as to identify when a Processor Reset should automatically +** be upgraded to a full Power-On Reset. +** +** \cfecmdmnemonic \ES_RESETPRCNT +** +** \par Command Structure +** #CFE_ES_NoArgsCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - \b \c \ES_PROCRESETCNT - Current number of processor resets will go to zero +** - The #CFE_ES_RESET_PR_COUNT_EID informational event message will be +** generated. +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** This command is not critical. The only impact would be that the system +** would have to have more processor resets before an automatic power-on reset +** occurred. +** +** \sa #CFE_ES_SET_MAX_PR_COUNT_CC, #CFE_ES_RESET_CC +*/ +#define CFE_ES_RESET_PR_COUNT_CC 19 + +/** \cfeescmd Configure the Maximum Number of Processor Resets before a Power-On Reset +** +** \par Description +** This command allows the user to specify the number of Processor Resets that +** are allowed before the next Processor Reset is upgraded to a Power-On Reset. +** +** \cfecmdmnemonic \ES_SETMAXPRCNT +** +** \par Command Structure +** #CFE_ES_SetMaxPRCountCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - \b \c \ES_MAXPROCRESETS - Current maximum number of processor resets +** before an automatic power-on reset will go to the command specified value. +** - The #CFE_ES_SET_MAX_PR_COUNT_EID informational event message will be +** generated. +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** If the operator were to set the Maximum Processor Reset Count to too high a value, +** the processor would require an inordinate number of consecutive processor resets +** before an automatic power-on reset would occur. This could potentially leave the +** spacecraft without any control for a significant amount of time if a processor reset +** fails to clear a problem. +** +** \sa #CFE_ES_RESET_PR_COUNT_CC +*/ +#define CFE_ES_SET_MAX_PR_COUNT_CC 20 + +/** \cfeescmd Delete Critical Data Store +** +** \par Description +** This command allows the user to delete a Critical Data Store that was created +** by an Application that is now no longer executing. +** +** \cfecmdmnemonic \ES_DELETECDS +** +** \par Command Structure +** #CFE_ES_DeleteCDSCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_CDS_DELETED_INFO_EID informational event message will be +** generated. +** - The specified CDS should no longer appear in a CDS Registry dump generated +** upon receipt of the #CFE_ES_DUMP_CDS_REG_CC command +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - The specified CDS is the CDS portion of a Critical Table. See #CFE_TBL_DELETE_CDS_CC. +** - The specified CDS is not found in the CDS Registry +** - The specified CDS is associated with an Application that is still active +** - An error occurred while accessing the CDS memory (see the System Log for more details) +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** This command is not critical because it is not possible to delete a CDS that is +** associated with an active application. However, deleting a CDS does eliminate +** any "history" that an application may be wishing to keep. +** +** \sa #CFE_ES_DUMP_CDS_REG_CC, #CFE_TBL_DELETE_CDS_CC +*/ +#define CFE_ES_DELETE_CDS_CC 21 + +/** \cfeescmd Telemeter Memory Pool Statistics +** +** \par Description +** This command allows the user to obtain a snapshot of the statistics maintained +** for a specified memory pool. +** +** \cfecmdmnemonic \ES_TLMPOOLSTATS +** +** \par Command Structure +** #CFE_ES_TlmPoolStatsCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_TLM_POOL_STATS_INFO_EID debug event message will be +** generated. +** - The \link #CFE_ES_PoolStatsTlm_t Memory Pool Statistics Telemetry Packet \endlink +** is produced +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - The specified handle is not associated with a known memory pool +** - The specified handle caused a processor exception because it improperly +** identified a segment of memory +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** An incorrect Memory Pool Handle value can cause a system crash. +** Extreme care should be taken to ensure the memory handle value +** used in the command is correct. +** +** \sa +*/ +#define CFE_ES_TLM_POOL_STATS_CC 22 + +/** \cfeescmd Dump Critical Data Store Registry to a File +** +** \par Description +** This command allows the user to dump the Critical Data Store +** Registry to an onboard file. +** +** \cfecmdmnemonic \ES_DUMPCDSREG +** +** \par Command Structure +** #CFE_ES_DumpCDSRegCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_CDS_REG_DUMP_INF_EID debug event message will be +** generated. +** - The file specified in the command (or the default specified +** by the #CFE_ES_DEFAULT_CDS_REG_DUMP_FILE configuration parameter) will be +** updated with the lastest information. +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Error occurred while trying to create the dump file +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** This command is not inherently dangerous. It will create a new +** file in the file system (or overwrite an existing one) and could, +** if performed repeatedly without sufficient file management by the +** operator, fill the file system. +** +** \sa #CFE_ES_DELETE_CDS_CC, #CFE_TBL_DELETE_CDS_CC +*/ +#define CFE_ES_DUMP_CDS_REG_CC 23 + +/** \cfeescmd Writes a list of All Executive Services Tasks to a File +** +** \par Description +** This command takes the information kept by Executive Services on all of the +** registered tasks and writes it to the specified file. +** +** \cfecmdmnemonic \ES_WRITETASKINFO2FILE +** +** \par Command Structure +** #CFE_ES_QueryAllTasksCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \ES_CMDPC - command execution counter will +** increment +** - The #CFE_ES_TASKINFO_EID debug event message will be +** generated. +** - The file specified in the command (or the default specified +** by the #CFE_ES_DEFAULT_TASK_LOG_FILE configuration parameter) will be +** updated with the lastest information. +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The command packet length is incorrect +** - An Error occurs while trying to write to the file +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \ES_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** This command is not inherently dangerous. It will create a new +** file in the file system (or overwrite an existing one) and could, +** if performed repeatedly without sufficient file management by the +** operator, fill the file system. +** +** \sa #CFE_ES_QUERY_ALL_CC, CFE_ES_QUERY_ONE_CC +*/ +#define CFE_ES_QUERY_ALL_TASKS_CC 24 + + +/** \} */ + + +/*************************************************************************/ +/********************************/ +/* Command Message Data Formats */ +/********************************/ +/** +** \brief Generic "no arguments" command +** +** This command structure is used for commands that do not have any parameters. +** This includes: +** -# The Housekeeping Request Message +** -# The No-Op Command (For details, see #CFE_ES_NOOP_CC) +** -# The Reset Counters Command (For details, see #CFE_ES_RESET_CC) +*/ +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + +} CFE_ES_NoArgsCmd_t; + +/** +** \brief Reset cFE Command +** +** For command details, see #CFE_ES_RESTART_CC +** +**/ +typedef struct +{ + uint16 RestartType; /**< \brief #CFE_ES_PROCESSOR_RESET=Processor Reset + or #CFE_ES_POWERON_RESET=Power-On Reset */ +} CFE_ES_RestartCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_RestartCmd_Payload_t Payload; +} CFE_ES_RestartCmd_t; + +/** +** \brief Shell Command +** +** For command details, see #CFE_ES_SHELL_CMD_CC +** +**/ +typedef struct +{ + char CmdString[CFE_ES_MAX_SHELL_CMD]; /**< \brief ASCII text string containing shell command + to be executed */ + char OutputFilename[OS_MAX_PATH_LEN]; /**< \brief Filename where shell command output is to + be written */ +} CFE_ES_ShellCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_ShellCmd_Payload_t Payload; +} CFE_ES_ShellCmd_t; + +/** +** \brief Write All ES Application Info for All Applications to File Command +** +** For command details, see #CFE_ES_QUERY_ALL_CC +** +**/ +typedef struct +{ + char QueryAllFileName[OS_MAX_PATH_LEN]; /**< \brief ASCII text string containing full path and + filename of file in which Application data is to be dumped */ +} CFE_ES_QueryAllCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_QueryAllCmd_Payload_t Payload; +} CFE_ES_QueryAllCmd_t; + +/** +** \brief Write All ES Application Info for All Tasks to File Command +** +** For command details, see #CFE_ES_QUERY_ALL_TASKS_CC +** +**/ +typedef struct +{ + char QueryAllFileName[OS_MAX_PATH_LEN]; /**< \brief ASCII text string containing full path and + filename of file in which Application data is to be dumped */ + +} CFE_ES_QueryAllTasksCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_QueryAllTasksCmd_Payload_t Payload; +} CFE_ES_QueryAllTasksCmd_t; + + +/** +** \brief Dump System Log to File Command +** +** For command details, see #CFE_ES_WRITE_SYSLOG_CC +** +**/ +typedef struct +{ + char SysLogFileName[OS_MAX_PATH_LEN]; /**< \brief ASCII text string containing full path and + filename of file in which System Log is to be dumped */ +} CFE_ES_WriteSyslogCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_WriteSyslogCmd_Payload_t Payload; +} CFE_ES_WriteSyslogCmd_t; + +/** +** \brief Dump Exception and Reset Log to File Command +** +** For command details, see #CFE_ES_WRITE_ERLOG_CC +** +**/ +typedef struct +{ + char ERLogFileName[OS_MAX_PATH_LEN]; /**< \brief ASCII text string containing full path and + filename of file in which ER Log is to be dumped */ +} CFE_ES_WriteERlogCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_WriteERlogCmd_Payload_t Payload; +} CFE_ES_WriteERlogCmd_t; + +/** +** \brief Overwrite/Discard System Log Configuration Command +** +** For command details, see #CFE_ES_OVERWRITE_SYSLOG_CC +** +**/ +typedef struct +{ + uint32 Mode; /**< \brief #CFE_ES_LOG_DISCARD=Throw away most recent messages, + #CFE_ES_LOG_OVERWRITE=Overwrite oldest with most recent */ + +} CFE_ES_OverWriteSysLogCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_OverWriteSysLogCmd_Payload_t Payload; +} CFE_ES_OverWriteSysLogCmd_t; + +/** +** \brief Start Application Command +** +** For command details, see #CFE_ES_START_APP_CC +** +**/ +typedef struct +{ + char Application[OS_MAX_API_NAME]; /**< \brief Name of Application to be started */ + char AppEntryPoint[OS_MAX_API_NAME]; /**< \brief Symbolic name of Application's entry point */ + char AppFileName[OS_MAX_PATH_LEN]; /**< \brief Full path and filename of Application's + executable image */ + + uint32 StackSize; /**< \brief Desired stack size for the new application */ + + uint16 ExceptionAction; /**< \brief #CFE_ES_APP_EXCEPTION_RESTART_APP=On exception, + restart Application, + #CFE_ES_APP_EXCEPTION_PROC_RESTART=On exception, + perform a Processor Reset */ + uint16 Priority; /**< \brief The new Applications runtime priority. */ + +} CFE_ES_StartAppCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_StartAppCmd_Payload_t Payload; +} CFE_ES_StartAppCmd_t; + +/** +** \brief Command Structure for Commands requiring just an Application Name +** +** For command details, see #CFE_ES_STOP_APP_CC, #CFE_ES_RESTART_APP_CC, #CFE_ES_QUERY_ONE_CC +** +**/ +typedef struct +{ + char Application[OS_MAX_API_NAME]; /**< \brief ASCII text string containing Application Name */ +} CFE_ES_AppNameCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_AppNameCmd_Payload_t Payload; +} CFE_ES_AppNameCmd_t; + +/** +** \brief Reload Application Command +** +** For command details, see #CFE_ES_RELOAD_APP_CC +** +**/ +typedef struct +{ + char Application[OS_MAX_API_NAME]; /**< \brief ASCII text string containing Application Name */ + char AppFileName[OS_MAX_PATH_LEN]; /**< \brief Full path and filename of Application's + executable image */ +} CFE_ES_AppReloadCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_AppReloadCmd_Payload_t Payload; +} CFE_ES_AppReloadCmd_t; + +/** +** \brief Set Maximum Processor Reset Count Command +** +** For command details, see #CFE_ES_SET_MAX_PR_COUNT_CC +** +**/ +typedef struct +{ + uint16 MaxPRCount; /**< \brief New maximum number of Processor Resets before + an automatic Power-On Reset is performed */ +} CFE_ES_SetMaxPRCountCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_SetMaxPRCountCmd_Payload_t Payload; +} CFE_ES_SetMaxPRCountCmd_t; + +/** +** \brief Delete Critical Data Store Command +** +** For command details, see #CFE_ES_DELETE_CDS_CC +** +**/ +typedef struct +{ + char CdsName[CFE_ES_CDS_MAX_FULL_NAME_LEN]; /**< \brief ASCII text string containing name of CDS to delete */ + +} CFE_ES_DeleteCDSCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_DeleteCDSCmd_Payload_t Payload; +} CFE_ES_DeleteCDSCmd_t; + +/** +** \brief Start Performance Analyzer Command +** +** For command details, see #CFE_ES_PERF_STARTDATA_CC +** +**/ +typedef struct +{ + uint32 TriggerMode; /**< \brief Desired trigger position (Start, Center, End) */ +} CFE_ES_PerfStartCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_PerfStartCmd_Payload_t Payload; +} CFE_ES_PerfStartCmd_t; + +/** +** \brief Stop Performance Analyzer Command +** +** For command details, see #CFE_ES_PERF_STOPDATA_CC +** +**/ +typedef struct +{ + char DataFileName[OS_MAX_PATH_LEN]; /**< \brief ASCII text string of full path and filename + of file Performance Analyzer data is to be written */ +} CFE_ES_PerfStopCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_PerfStopCmd_Payload_t Payload; +} CFE_ES_PerfStopCmd_t; + + +/** +** \brief Set Performance Analyzer Filter Mask Command +** +** For command details, see #CFE_ES_PERF_SETFILTERMASK_CC +** +**/ +typedef struct +{ + uint32 FilterMaskNum; /**< \brief Index into array of Filter Masks */ + uint32 FilterMask; /**< \brief New Mask for specified entry in array of Filter Masks */ + +} CFE_ES_PerfSetFilterMaskCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_PerfSetFilterMaskCmd_Payload_t Payload; +} CFE_ES_PerfSetFilterMaskCmd_t; + +/** +** \brief Set Performance Analyzer Trigger Mask Command +** +** For command details, see #CFE_ES_PERF_SETTRIGMASK_CC +** +**/ +typedef struct +{ + uint32 TriggerMaskNum; /**< \brief Index into array of Trigger Masks */ + uint32 TriggerMask; /**< \brief New Mask for specified entry in array of Trigger Masks */ + +} CFE_ES_PerfSetTrigMaskCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_PerfSetTrigMaskCmd_Payload_t Payload; +} CFE_ES_PerfSetTrigMaskCmd_t; + +/** +** \brief Telemeter Memory Pool Statistics Command +** +** For command details, see #CFE_ES_TLM_POOL_STATS_CC +** +**/ +typedef struct +{ + char Application[OS_MAX_API_NAME]; /**< \brief - RESERVED - should be all zeroes */ + CFE_ES_MemHandle_t PoolHandle; /**< \brief Handle of Pool whose statistics are to be telemetered */ + +} CFE_ES_TlmPoolStatsCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_TlmPoolStatsCmd_Payload_t Payload; +} CFE_ES_TlmPoolStatsCmd_t; + +/** +** \brief Dump CDS Registry Command +** +** For command details, see #CFE_ES_DUMP_CDS_REG_CC +** +**/ +typedef struct +{ + char DumpFilename[OS_MAX_PATH_LEN]; /**< \brief ASCII text string of full path and filename + of file CDS Registry is to be written */ +} CFE_ES_DumpCDSRegCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_ES_DumpCDSRegCmd_Payload_t Payload; + +} CFE_ES_DumpCDSRegCmd_t; + +/*************************************************************************/ +/**********************************/ +/* Telemetry Message Data Formats */ +/**********************************/ +/** +** \cfeestlm Single Application Information Packet +**/ +typedef struct +{ + CFE_ES_AppInfo_t AppInfo; /**< \brief For more information, see #CFE_ES_AppInfo_t */ + +} CFE_ES_OneAppTlm_Payload_t; + +typedef struct +{ + uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; /**< \brief cFE Software Bus Telemetry Message Header */ + CFE_ES_OneAppTlm_Payload_t Payload; +} CFE_ES_OneAppTlm_t; + +/** +** \cfeestlm Memory Pool Statistics Packet +**/ +typedef struct +{ + CFE_ES_MemHandle_t PoolHandle; /**< \cfetlmmnemonic \ES_POOLHANDLE + \brief Handle of memory pool whose stats are being telemetered */ + CFE_ES_MemPoolStats_t PoolStats; /**< \brief For more info, see #CFE_ES_MemPoolStats_t */ +} CFE_ES_PoolStatsTlm_Payload_t; + +typedef struct +{ + uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; /**< \brief cFE Software Bus Telemetry Message Header */ + CFE_ES_PoolStatsTlm_Payload_t Payload; +} CFE_ES_PoolStatsTlm_t; + +/*************************************************************************/ + +/** +** \cfeestlm Executive Services Housekeeping Packet +**/ +typedef struct +{ + uint8 CmdCounter; /**< \cfetlmmnemonic \ES_CMDPC + \brief The ES Application Command Counter */ + uint8 ErrCounter; /**< \cfetlmmnemonic \ES_CMDEC + \brief The ES Application Command Error Counter */ + + uint16 CFECoreChecksum; /**< \cfetlmmnemonic \ES_CKSUM + \brief Checksum of cFE Core Code */ + uint8 CFEMajorVersion; /**< \cfetlmmnemonic \ES_CFEMAJORVER + \brief Major Version Number of cFE */ + uint8 CFEMinorVersion; /**< \cfetlmmnemonic \ES_CFEMINORVER + \brief Minor Version Number of cFE */ + uint8 CFERevision; /**< \cfetlmmnemonic \ES_CFEREVISION + \brief Sub-Minor Version Number of cFE */ + uint8 CFEMissionRevision; /**< \cfetlmmnemonic \ES_CFEMISSIONREV + \brief Mission Version Number of cFE */ + uint8 OSALMajorVersion; /**< \cfetlmmnemonic \ES_OSMAJORVER + \brief OS Abstraction Layer Major Version Number */ + uint8 OSALMinorVersion; /**< \cfetlmmnemonic \ES_OSMINORVER + \brief OS Abstraction Layer Minor Version Number */ + uint8 OSALRevision; /**< \cfetlmmnemonic \ES_OSREVISION + \brief OS Abstraction Layer Revision Number */ + uint8 OSALMissionRevision;/**< \cfetlmmnemonic \ES_OSMISSIONREV + \brief OS Abstraction Layer MissionRevision Number */ + + uint32 SysLogBytesUsed; /**< \cfetlmmnemonic \ES_SYSLOGBYTEUSED + \brief Total number of bytes used in system log */ + uint32 SysLogSize; /**< \cfetlmmnemonic \ES_SYSLOGSIZE + \brief Total size of the system log */ + uint32 SysLogEntries; /**< \cfetlmmnemonic \ES_SYSLOGENTRIES + \brief Number of entries in the system log */ + uint32 SysLogMode; /**< \cfetlmmnemonic \ES_SYSLOGMODE + \brief Write/Overwrite Mode */ + + uint32 ERLogIndex; /**< \cfetlmmnemonic \ES_ERLOGINDEX + \brief Current index of the ER Log (wraps around) */ + uint32 ERLogEntries; /**< \cfetlmmnemonic \ES_ERLOGENTRIES + \brief Number of entries made in the ER Log since the power on */ + + uint32 RegisteredCoreApps; /**< \cfetlmmnemonic \ES_REGCOREAPPS + \brief Number of Applications registered with ES */ + uint32 RegisteredExternalApps; /**< \cfetlmmnemonic \ES_REGEXTAPPS + \brief Number of Applications registered with ES */ + uint32 RegisteredTasks; /**< \cfetlmmnemonic \ES_REGTASKS + \brief Number of Tasks ( main AND child tasks ) registered with ES */ + uint32 RegisteredLibs; /**< \cfetlmmnemonic \ES_REGLIBS + \brief Number of Libraries registered with ES */ + + uint32 ResetType; /**< \cfetlmmnemonic \ES_RESETTYPE + \brief Reset type ( PROCESSOR or POWERON ) */ + uint32 ResetSubtype; /**< \cfetlmmnemonic \ES_RESETSUBTYPE + \brief Reset Sub Type */ + uint32 ProcessorResets; /**< \cfetlmmnemonic \ES_PROCRESETCNT + \brief Number of processor resets since last power on */ + uint32 MaxProcessorResets; /**< \cfetlmmnemonic \ES_MAXPROCRESETS + \brief Max processor resets before a power on is done */ + uint32 BootSource; /**< \cfetlmmnemonic \ES_BOOTSOURCE + \brief Boot source ( as provided from BSP ) */ + + uint32 PerfState; /**< \cfetlmmnemonic \ES_PERFSTATE + \brief Current state of Performance Analyzer */ + uint32 PerfMode; /**< \cfetlmmnemonic \ES_PERFMODE + \brief Current mode of Performance Analyzer */ + uint32 PerfTriggerCount; /**< \cfetlmmnemonic \ES_PERFTRIGCNT + \brief Number of Times Perfomance Analyzer has Triggered */ + uint32 PerfFilterMask[CFE_ES_PERF_MAX_IDS / 32]; /**< \cfetlmmnemonic \ES_PERFFLTRMASK + \brief Current Setting of Performance Analyzer Filter Masks */ + uint32 PerfTriggerMask[CFE_ES_PERF_MAX_IDS / 32]; /**< \cfetlmmnemonic \ES_PERFTRIGMASK + \brief Current Setting of Performance Analyzer Trigger Masks */ + uint32 PerfDataStart; /**< \cfetlmmnemonic \ES_PERFDATASTART + \brief Identifies First Stored Entry in Performance Analyzer Log */ + uint32 PerfDataEnd; /**< \cfetlmmnemonic \ES_PERFDATAEND + \brief Identifies Last Stored Entry in Performance Analyzer Log */ + uint32 PerfDataCount; /**< \cfetlmmnemonic \ES_PERFDATACNT + \brief Number of Entries Put Into the Performance Analyzer Log */ + uint32 PerfDataToWrite; /**< \cfetlmmnemonic \ES_PERFDATA2WRITE + \brief Number of Performance Analyzer Log Entries Left to be Written to Log Dump File */ + uint32 HeapBytesFree; /**< \cfetlmmnemonic \ES_HEAPBYTESFREE + \brief Number of free bytes remaining in the OS heap */ + uint32 HeapBlocksFree; /**< \cfetlmmnemonic \ES_HEAPBLKSFREE + \brief Number of free blocks remaining in the OS heap */ + uint32 HeapMaxBlockSize; /**< \cfetlmmnemonic \ES_HEAPMAXBLK + \brief Number of bytes in the largest free block */ +} CFE_ES_HkPacket_Payload_t; + +typedef struct +{ + uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; /**< \brief cFE Software Bus Telemetry Message Header */ + CFE_ES_HkPacket_Payload_t Payload; + +} CFE_ES_HkPacket_t; + +/** +** \cfeestlm OS Shell Output Packet +**/ +typedef struct +{ + char ShellOutput[CFE_ES_MAX_SHELL_PKT]; /**< \brief ASCII text string containing output from OS Shell + that was received in response to an OS Shell Command */ +} CFE_ES_ShellPacket_Payload_t; + +typedef struct +{ + uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; /**< \brief cFE Software Bus Telemetry Message Header */ + CFE_ES_ShellPacket_Payload_t Payload; +}CFE_ES_ShellPacket_t; + +/*************************************************************************/ + +#endif /* _cfe_es_msg_ */ + +/************************/ +/* End of File Comment */ +/************************/ + diff --git a/src/components/interface/cFE/cfe_es_perfids.h b/src/components/interface/cFE/cfe_es_perfids.h new file mode 100644 index 0000000000..7964453f11 --- /dev/null +++ b/src/components/interface/cFE/cfe_es_perfids.h @@ -0,0 +1,86 @@ +/* +** File: cfe_es_perfids.h +** +** Purpose: This file contains the perf_ids +** +** Copyright (c) 2004-2012, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Design Notes: +** Each performance id is used to identify something that needs to be +** measured. Performance ids are limited to the range of 0 to +** CFE_ES_PERF_MAX_IDS - 1. Any performance ids outside of this range +** will be ignored and will be flagged as an error. Note that +** performance ids 0-31 are reserved for the cFE Core. +** +** References: +** +** $Log: cfe_es_perfids.h $ +** Revision 1.6 2012/01/13 12:32:23GMT-05:00 acudmore +** Changed license text to reflect open source +** Revision 1.5 2012/01/06 14:06:54EST rmcgraw +** DCR16100:2 changed pipe overflow id from 12 to 27 +** Revision 1.4 2012/01/06 09:27:19GMT-05:00 rmcgraw +** DCR16100:1 Added perf markers for msg lim and pipe overflow errors +** Revision 1.3 2010/09/21 15:04:06GMT-05:00 jmdagost +** Make copyright symbol readable. +** Revision 1.2 2010/09/21 16:02:42EDT jmdagost +** Change performance IDs from hexadecimal to decimal. +** Revision 1.1 2008/04/17 08:05:20EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.9 2007/09/24 11:13:39EDT rjmcgraw +** DCR5039 Updated comments +** Revision 1.8 2007/08/31 10:57:18EDT rjmcgraw +** Changes to eliminate perl script +** Revision 1.7 2007/04/24 08:59:04EDT njyanchik +** I added the changes tha LRO requested. They are specified in the DCR text. +** Revision 1.6 2007/04/09 14:43:30EDT rjmcgraw +** Changed names of performance ids to include CFE_ +** Revision 1.5 2006/12/26 15:23:29EST rjmcgraw +** removed SBP performance id +** Revision 1.4 2006/11/20 15:17:00EST dlkobe +** Updated comments to make use of Doxygen utility +** Revision 1.3 2006/06/21 12:13:27GMT-05:00 kkaudra +** Added Markers for TIME ISRs +** Revision 1.2 2006/06/14 09:53:21EDT kkaudra +** moved perf config information to cfe_platform_cfg.h +** Revision 1.1 2006/06/13 15:39:08EDT rjmcgraw +** Initial revision +** +*/ + +#ifndef _cfe_es_perfids_ +#define _cfe_es_perfids_ + + +#define CFE_ES_PERF_EXIT_BIT 31 /**< \brief bit (31) is reserved by the perf utilities */ + +/** \name cFE Performance Monitor IDs (Reserved IDs 0-31) */ +/** \{ */ +#define CFE_ES_MAIN_PERF_ID 1 /**< \brief Performance ID for Executive Services Task */ +#define CFE_EVS_MAIN_PERF_ID 2 /**< \brief Performance ID for Events Services Task */ +#define CFE_TBL_MAIN_PERF_ID 3 /**< \brief Performance ID for Table Services Task */ +#define CFE_SB_MAIN_PERF_ID 4 /**< \brief Performance ID for Software Bus Services Task */ +#define CFE_SB_MSG_LIM_PERF_ID 5 /**< \brief Performance ID for Software Bus Msg Limit Errors */ +#define CFE_SB_PIPE_OFLOW_PERF_ID 27 /**< \brief Performance ID for Software Bus Pipe Overflow Errors */ + + +#define CFE_TIME_MAIN_PERF_ID 6 /**< \brief Performance ID for Time Services Task */ +#define CFE_TIME_TONE1HZISR_PERF_ID 7 /**< \brief Performance ID for 1 Hz Tone ISR */ +#define CFE_TIME_LOCAL1HZISR_PERF_ID 8 /**< \brief Performance ID for 1 Hz Local ISR */ + +#define CFE_TIME_SENDMET_PERF_ID 9 /**< \brief Performance ID for Time ToneSendMET */ +#define CFE_TIME_LOCAL1HZTASK_PERF_ID 10 /**< \brief Performance ID for 1 Hz Local Task */ +#define CFE_TIME_TONE1HZTASK_PERF_ID 11 /**< \brief Performance ID for 1 Hz Tone Task */ + + +/** \} */ + + +#endif /* _cfe_es_perfids_ */ diff --git a/src/components/interface/cFE/cfe_evs.h b/src/components/interface/cFE/cfe_evs.h new file mode 100644 index 0000000000..22b0d2bef7 --- /dev/null +++ b/src/components/interface/cFE/cfe_evs.h @@ -0,0 +1,427 @@ +/* +** +** Filename: cfe_evs.h +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +* +** $Id: cfe_evs.h 1.4 2010/10/26 16:01:08GMT-05:00 jmdagost Exp $ +** +** Title: Event Services API Application Library Header File +** +** Purpose: +** Unit specification for Event services library functions and macros. +** +** Design Notes: +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** +** $Date: 2010/10/26 16:01:08GMT-05:00 $ +** $Revision: 1.4 $ +** $Log: cfe_evs.h $ +** Revision 1.4 2010/10/26 16:01:08GMT-05:00 jmdagost +** Made CFE_EVS_ResetFilter() argument a signed int. +** Revision 1.3 2010/10/04 17:06:06EDT jmdagost +** Cleaned up copyright symbol. +** Revision 1.2 2008/12/08 12:07:11EST dkobe +** Updates to correct doxygen errors +** Revision 1.1 2008/04/17 08:05:21EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.19 2007/09/20 08:37:52EDT njyanchik +** I added the doxygen comments to CFE_EVS_Log_t +** Revision 1.18 2007/07/18 11:53:06EDT njyanchik +** The two structures specified in DCR 4407 were moved to cfe_evs_msg.h +** Revision 1.17 2007/07/12 16:45:13EDT rjmcgraw +** DCR4680:1 Added #defines for more filtering options +** Revision 1.16 2007/06/07 16:03:55EDT dlkobe +** Corrected doxygen comment syntax errors +** Revision 1.15 2007/06/07 13:07:49EDT dlkobe +** Added Command and Telemetry doxygen comments to TIME, EVS and SB +** Revision 1.14 2007/05/23 11:21:58EDT dlkobe +** Added doxygen formatting +** Revision 1.13 2007/05/14 10:26:04EDT apcudmore +** Preserve the EVS Local event log on a processor restart: +** - moved the EVS Log to the ES reset data structure +** - Added a couple of EVS Log related variables into the EVS_Log_t structure +** - Added a routine to the EVS early init to get a pointer to the EVS Log +** - Added code to the EVS housekeeping service routine to copy Log variables into TLM +** Revision 1.12 2007/03/01 11:54:34EST njyanchik +** This cp handles issues 1,6,7,8 as described in the DCR +** Revision 1.11 2006/11/17 16:46:10EST dlkobe +** Updated with Doxygen formatted comments +** Revision 1.10 2006/06/08 13:14:53GMT-05:00 njyanchik +** I added the appropriate legal headers to all of the evs files +** Revision 1.9 2005/11/01 15:27:35EST njyanchik +** Added header for CFE_EVS_SendEventWithAppID function in /evs/cfe_evs.c +** Revision 1.8 2005/10/21 16:02:04EDT kkaudra +** Exposure of the EVS event packet types +** Revision 1.7 2005/09/08 17:47:51EDT sstrege +** Added Event Mask CFE_EVS_EVERY_FOURTH_ONE +** Revision 1.6 2005/08/23 14:10:07EDT kkaudra +** Make Command Code definitions public +**/ + +#ifndef _cfe_evs_ +#define _cfe_evs_ + +/********************************** Include Files ************************************/ +#include "common_types.h" /* Basic data types */ +#include "cfe_time.h" /* Time library function definitions */ +#include "cfe_evs_msg.h" /* EVS command codes and data structures*/ +#include "osapi.h" +#include "cfe_sb.h" + + + + + + +/******************* Macro Definitions ***********************/ + +/* +** The OS_PRINTF macro may be defined by OSAL to enable +** printf-style argument checking. If using a version of OSAL +** that does not define this then define it as a no-op. +*/ +#ifndef OS_PRINTF +#define OS_PRINTF(m,n) +#endif + +/** \name Event Filter Schemes */ +/** \{ */ +#define CFE_EVS_BINARY_FILTER 0 +/** \} */ + +/** \name Common Event Filter Mask Values */ +/** \{ */ +#define CFE_EVS_NO_FILTER 0x0000 /**< \brief Stops any filtering. All messages are sent. */ +#define CFE_EVS_FIRST_ONE_STOP 0xFFFF /**< \brief Sends the first event. All remaining messages are filtered. */ +#define CFE_EVS_FIRST_TWO_STOP 0xFFFE /**< \brief Sends the first 2 events. All remaining messages are filtered. */ +#define CFE_EVS_FIRST_4_STOP 0xFFFC /**< \brief Sends the first 4 events. All remaining messages are filtered. */ +#define CFE_EVS_FIRST_8_STOP 0xFFF8 /**< \brief Sends the first 8 events. All remaining messages are filtered. */ +#define CFE_EVS_FIRST_16_STOP 0xFFF0 /**< \brief Sends the first 16 events. All remaining messages are filtered. */ +#define CFE_EVS_FIRST_32_STOP 0xFFE0 /**< \brief Sends the first 32 events. All remaining messages are filtered. */ +#define CFE_EVS_FIRST_64_STOP 0xFFC0 /**< \brief Sends the first 64 events. All remaining messages are filtered. */ +#define CFE_EVS_EVERY_OTHER_ONE 0x0001 /**< \brief Sends every other event. */ +#define CFE_EVS_EVERY_OTHER_TWO 0x0002 /**< \brief Sends two, filters one, sends two, filters one, etc */ +#define CFE_EVS_EVERY_FOURTH_ONE 0x0003 /**< \brief Sends every fourth event message. All others are filtered. */ +/** \} */ + +/** \name Event Types */ +/** \{ */ +#define CFE_EVS_DEBUG 0x01 /**< \brief Events that are intended only for debugging, not nominal operations */ +#define CFE_EVS_INFORMATION 0x02 /**< \brief Events that identify a state change or action that is not an error */ +#define CFE_EVS_ERROR 0x03 /**< \brief Events that identify an error but are not catastrophic (e.g. - bad command */ +#define CFE_EVS_CRITICAL 0x04 /**< \brief Events that identify errors that are unrecoverable autonomously. */ +/** \} */ + +/** \name Output Ports */ +/** \{ */ +#define CFE_EVS_PORT1 0x01 +#define CFE_EVS_PORT2 0x02 +#define CFE_EVS_PORT3 0x03 +#define CFE_EVS_PORT4 0x04 +/** \} */ + +/****************** Structure Definitions *********************/ + +/** Event message filter defintion structure */ +typedef struct { + uint16 EventID; /**< \brief Numerical event identifier */ + uint16 Mask; /**< \brief Binary filter mask value */ + +} CFE_EVS_BinFilter_t; + +/* Command packet structures */ + + +/****************** Function Prototypes **********************/ + +/** +** \brief Register an application for receiving event services +** +** \par Description +** This routine registers an application with event services and allocates/initializes +** the internal data structures used to support this application's events. An application +** may not send events unless it has called this routine. The routine also accepts a filter +** array structure for applications requiring event filtering. In the current implementation +** of the EVS, only the binary filtering scheme is supported. See section TBD of the cFE +** Application Programmer's Guide for a description of the behavior of binary filters. +** Applications may call #CFE_EVS_Register more than once, but each call will wipe out all +** filters registered by previous calls (filter registration is NOT cumulative). +** +** \par Assumptions, External Events, and Notes: +** Note: Event filters can be added, deleted or modified by ground commands. All filtering +** schemes include a default setting that results in no filtering (such as #CFE_EVS_NO_FILTER +** for binary filters). +** +** Filter Scheme: Binary
+** Code: CFE_EVS_BINARY_FILTER
+** Filter Structure: +** \code +** typedef struct { +** uint16 EventID, +** uint16 Mask ; +** } CFE_EVS_BinFilter_t; +** \endcode +** +** \param[in] Filters Pointer to an array of event message filters, or NULL if no filtering is desired. +** The structure of an event message filter depends on the FilterScheme selected. +** (see Filter Schemes mentioned above) +** +** \param[in] NumFilteredEvents The number of event message filters included in this call. This must be less than +** or equal to the maximum number of events allowed per application (#CFE_EVS_MAX_EVENT_FILTERS). +** +** \param[in] FilterScheme The event filtering scheme that this application will use. For the first implementation of +** the event services, only filter type #CFE_EVS_BINARY_FILTER will be supported. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_EVS_APP_FILTER_OVERLOAD \retdesc \copydoc CFE_EVS_APP_FILTER_OVERLOAD \endcode +** \retcode #CFE_EVS_UNKNOWN_FILTER \retdesc \copydoc CFE_EVS_UNKNOWN_FILTER \endcode +** \retcode #CFE_EVS_APP_ILLEGAL_APP_ID \retdesc \copydoc CFE_EVS_APP_ILLEGAL_APP_ID \endcode +** \retstmt Any of the error codes from #CFE_ES_GetAppID \endstmt +** \endreturns +** +** \sa #CFE_EVS_Unregister +** +**/ +int32 CFE_EVS_Register (void *Filters, /* Pointer to an array of filters */ + uint16 NumFilteredEvents, /* How many elements in the array? */ + uint16 FilterScheme); /* Filtering Algorithm to be implemented */ + +/** +** \brief Cleanup internal structures used by the event manager for the calling Application. +** +** \par Description +** This routine un-registers the calling application from receiving event services +** and removes and deletes the calling applications filters and counters from the +** internal event service filter and counter tables if registered. Applications +** must call this routine as part of their orderly shutdown process. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_EVS_APP_NOT_REGISTERED \retdesc \copydoc CFE_EVS_APP_NOT_REGISTERED \endcode +** \retcode #CFE_EVS_APP_ILLEGAL_APP_ID \retdesc \copydoc CFE_EVS_APP_ILLEGAL_APP_ID \endcode +** \retstmt Any of the error codes from #CFE_ES_GetAppID \endstmt +** \retstmt Any of the error codes from #CFE_ES_PutPoolBuf \endstmt +** \endreturns +** +** \sa #CFE_EVS_Register +** +**/ +int32 CFE_EVS_Unregister( void ); + +/** +** \brief Generate a software event. +** +** \par Description +** This routine generates a software event message. If the EventID is not filtered, +** the event will be sent as a software bus message, optionally logged in the local +** event log, and optionally sent as an ASCII text string out the enabled output port(s). +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] EventID A numeric literal used to uniquely identify an application event. +** The \c EventID is defined and supplied by the application sending the event. +** +** \param[in] EventType A numeric literal used to classify an event, one of: +** \arg #CFE_EVS_DEBUG +** \arg #CFE_EVS_INFORMATION +** \arg #CFE_EVS_ERROR +** \arg #CFE_EVS_CRITICAL +** +** \param[in] Spec A pointer to a null terminated text string describing the output format +** for the event. This is the same type of format string used for the ANSI +** \c printf function. Nominally the post-conversion string is limited to 80 +** characters, but this limit is configurable through the parameter +** #CFE_EVS_MAX_MESSAGE_LENGTH. Characters beyond the limit will be truncated. +** Do not use floating point conversions (%f, %e, %E, %g, and %G) in the format +** string unless your application will be running in a system that supports +** floating point arithmetic. Do not use non-printable characters (\\t, \\n, etc.) +** in the format string; they will mess up the formatting when the events are +** displayed on the ground system. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_EVS_APP_NOT_REGISTERED \retdesc \copydoc CFE_EVS_APP_NOT_REGISTERED \endcode +** \retcode #CFE_EVS_APP_ILLEGAL_APP_ID \retdesc \copydoc CFE_EVS_APP_ILLEGAL_APP_ID \endcode +** \retstmt Any of the error codes from #CFE_ES_GetAppID \endstmt +** \retstmt Any of the error codes from #CFE_SB_SendMsg \endstmt +** \endreturns +** +** \sa #CFE_EVS_SendEventWithAppID, #CFE_EVS_SendTimedEvent +** +**/ +int32 CFE_EVS_SendEvent (uint16 EventID, + uint16 EventType, + const char *Spec, ... ) OS_PRINTF(3,4); + + +/** +** \brief Generate a software event given the specified Application ID. +** +** \par Description +** This routine generates a software event message. If the EventID is not filtered, +** the event will be sent as a software bus message, optionally logged in the local +** event log, and optionally sent as an ASCII text string out the enabled output port(s). +** Note that this function should really only be used from within an API in order to +** preserve the context of an Application's event. In general, #CFE_EVS_SendEvent should be used. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] EventID A numeric literal used to uniquely identify an application event. +** The \c EventID is defined and supplied by the application sending the event. +** +** \param[in] EventType A numeric literal used to classify an event, one of: +** \arg #CFE_EVS_DEBUG +** \arg #CFE_EVS_INFORMATION +** \arg #CFE_EVS_ERROR +** \arg #CFE_EVS_CRITICAL +** +** \param[in] AppID The Application ID from which the event message should appear. +** +** \param[in] Spec A pointer to a null terminated text string describing the output format +** for the event. This is the same type of format string used for the ANSI +** \c printf function. Nominally the post-conversion string is limited to 80 +** characters, but this limit is configurable through the parameter +** #CFE_EVS_MAX_MESSAGE_LENGTH. Characters beyond the limit will be truncated. +** Do not use floating point conversions (%f, %e, %E, %g, and %G) in the format +** string unless your application will be running in a system that supports +** floating point arithmetic. Do not use non-printable characters (\\t, \\n, etc.) +** in the format string; they will mess up the formatting when the events are +** displayed on the ground system. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_EVS_APP_NOT_REGISTERED \retdesc \copydoc CFE_EVS_APP_NOT_REGISTERED \endcode +** \retcode #CFE_EVS_APP_ILLEGAL_APP_ID \retdesc \copydoc CFE_EVS_APP_ILLEGAL_APP_ID \endcode +** \retstmt Any of the error codes from #CFE_ES_GetAppID \endstmt +** \retstmt Any of the error codes from #CFE_SB_SendMsg \endstmt +** \endreturns +** +** \sa #CFE_EVS_SendEvent, #CFE_EVS_SendTimedEvent +** +**/ +int32 CFE_EVS_SendEventWithAppID (uint16 EventID, + uint16 EventType, + uint32 AppID, + const char *Spec, ... ) OS_PRINTF(4,5); + + +/** +** \brief Generate a software event with a specific time tag. +** +** \par Description +** This routine is the same as CFE_EVS_SendEvent except that the caller specifies the event time +** instead of having the EVS use the current spacecraft time. This routine should be used in +** situations where an error condition is detected at one time, but the event message is reported +** at a later time. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] Time The time to include in the event. This will usually be a time returned +** by the function #CFE_TIME_GetTime(). +** +** \param[in] EventID A numeric literal used to uniquely identify an application event. +** The \c EventID is defined and supplied by the application sending the event. +** +** \param[in] EventType A numeric literal used to classify an event, one of: +** \arg #CFE_EVS_DEBUG +** \arg #CFE_EVS_INFORMATION +** \arg #CFE_EVS_ERROR +** \arg #CFE_EVS_CRITICAL +** +** \param[in] Spec A pointer to a null terminated text string describing the output format +** for the event. This is the same type of format string used for the ANSI +** \c printf function. Nominally the post-conversion string is limited to 80 +** characters, but this limit is configurable through the parameter +** #CFE_EVS_MAX_MESSAGE_LENGTH. Characters beyond the limit will be truncated. +** Do not use floating point conversions (%f, %e, %E, %g, and %G) in the format +** string unless your application will be running in a system that supports +** floating point arithmetic. Do not use non-printable characters (\\t, \\n, etc.) +** in the format string; they will mess up the formatting when the events are +** displayed on the ground system. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_EVS_APP_NOT_REGISTERED \retdesc \copydoc CFE_EVS_APP_NOT_REGISTERED \endcode +** \retcode #CFE_EVS_APP_ILLEGAL_APP_ID \retdesc \copydoc CFE_EVS_APP_ILLEGAL_APP_ID \endcode +** \retstmt Any of the error codes from #CFE_ES_GetAppID \endstmt +** \retstmt Any of the error codes from #CFE_SB_SendMsg \endstmt +** \endreturns +** +** \sa #CFE_EVS_SendEvent, #CFE_EVS_SendEventWithAppID +** +**/ +int32 CFE_EVS_SendTimedEvent (CFE_TIME_SysTime_t Time, + uint16 EventID, + uint16 EventType, + const char *Spec, ... ) OS_PRINTF(4,5); + + +/** +** \brief Resets the calling application's event filter for a single event ID. +** +** \par Description +** The effect of resetting an event filter depends on the filter scheme. +** The #CFE_EVS_BINARY_FILTER scheme resets the filter counter for the specified Event ID. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] EventID A numeric literal used to uniquely identify an application event. +** The \c EventID is defined and supplied by the application sending the event. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_EVS_APP_NOT_REGISTERED \retdesc \copydoc CFE_EVS_APP_NOT_REGISTERED \endcode +** \retcode #CFE_EVS_APP_ILLEGAL_APP_ID \retdesc \copydoc CFE_EVS_APP_ILLEGAL_APP_ID \endcode +** \retstmt Any of the error codes from #CFE_ES_GetAppID \endstmt +** \endreturns +** +** \sa #CFE_EVS_ResetAllFilters +** +**/ +int32 CFE_EVS_ResetFilter (int16 EventID); + + +/** +** \brief Resets all of the calling application's event filters. +** +** \par Description +** This routine resets all the calling application's event filter counters to zero, providing a +** quick and convenient method for resetting event filters. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_EVS_APP_NOT_REGISTERED \retdesc \copydoc CFE_EVS_APP_NOT_REGISTERED \endcode +** \retcode #CFE_EVS_APP_ILLEGAL_APP_ID \retdesc \copydoc CFE_EVS_APP_ILLEGAL_APP_ID \endcode +** \retstmt Any of the error codes from #CFE_ES_GetAppID \endstmt +** \endreturns +** +** \sa #CFE_EVS_ResetFilter +** +**/ +int32 CFE_EVS_ResetAllFilters ( void ); + + + +#endif /* _cfe_evs_ */ diff --git a/src/components/interface/cFE/cfe_evs_events.h b/src/components/interface/cFE/cfe_evs_events.h new file mode 100644 index 0000000000..383c870e5f --- /dev/null +++ b/src/components/interface/cFE/cfe_evs_events.h @@ -0,0 +1,704 @@ +/* +** +** Filename: cfe_evs_events.h +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA’s Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** +** $Id: cfe_evs_events.h 1.7 2011/06/02 17:06:44GMT-05:00 lwalling Exp $ +** +** Purpose: +** cFE Event Services (EVS) Event IDs +** +** Design Notes: +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** $Date: 2011/06/02 17:06:44GMT-05:00 $ +** $Revision: 1.7 $ +** $Log: cfe_evs_events.h $ +** Revision 1.7 2011/06/02 17:06:44GMT-05:00 lwalling +** Updated text and descriptions for Write Application Data to File command events +** Revision 1.6 2011/06/01 17:38:43EDT lwalling +** Update Write Log File and Set Log Mode command events +** Revision 1.5 2011/05/23 15:40:20EDT lwalling +** Update descriptions for event log command events when event log is disabled +** Revision 1.4 2010/10/04 15:25:17EDT jmdagost +** Cleaned up copyright symbol. +** Revision 1.3 2009/07/31 19:54:05EDT aschoeni +** added length check error message and changed reported bitmask lengths +** Revision 1.2 2009/07/28 17:16:33EDT aschoeni +** Added event message when filtering limit is reached. +** Revision 1.1 2008/04/17 08:05:21EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.13 2007/07/18 15:48:00EDT njyanchik +** Jonathan added text into each error event in the two functions that write files (WriteLog and WriteAppData), as well as updated the doxygen comments in the header file +** Revision 1.11 2007/06/02 10:10:12EDT dlkobe +** Added doxygen comments for User's Guides +** Revision 1.10 2007/05/23 11:21:59EDT dlkobe +** Added doxygen formatting +** Revision 1.9 2007/05/07 10:42:03EDT njyanchik +** I added a sending of an Event message from EVS on the first time an EVS-unregistered +** application tries to send an event message. A system log message is also written +** Revision 1.8 2007/03/05 14:08:43EST njyanchik +** This CP fixes the fact that there were multiple event messages using the same event ID, but +** using different (but similar) event text. The issue was fixed by making all the text generic, and +** providing a command code parameter that specified what command the message was comming +** from. +*/ + +#ifndef _cfe_evs_events_ +#define _cfe_evs_events_ + +/* Event Service event ID's */ + +/** \brief 'No-op command' +** \event 'No-op command' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always automatically issued in response +** to a cFE Event Services \link #CFE_EVS_NO_OPERATION_CC NO-OP command \endlink +**/ +#define CFE_EVS_NOOP_EID 0 /* Noop event identifier */ + +/** \brief 'cFE EVS Initialized' +** \event 'cFE EVS Initialized' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always automatically issued when the Event Services +** Task completes its Initialization. +**/ +#define CFE_EVS_STARTUP_EID 1 + +/** \brief 'Write Log File Command Error: OS_write = 0x\%08X, filename = \%s' +** \event 'Write Log File Command Error: OS_write = 0x\%08X, filename = \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a filesystem error occurred while writing the contents of the +** event message log to a file. +** +** The message text identifies the event log filename and specifies the return value, in hex, +** from the system function call. The expected return value is the number of bytes written, +** which in this case should be equal to the size of a #CFE_EVS_Packet_t structure. Error +** codes are negative. +**/ +#define CFE_EVS_ERR_WRLOGFILE_EID 2 + +/** \brief 'Write Log File Command Error: OS_creat = 0x\%08X, filename = \%s' +** \event 'Write Log File Command Error: OS_creat = 0x\%08X, filename = \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a filesystem error occurred when attempting to create the file +** that is to hold the event message log. +** +** The message text identifies the event log filename and specifies the return value, in hex, +** from the system function call. The expected return value is a file handle, which in this case +** should be a relatively small positive number. Error codes are negative. +**/ +#define CFE_EVS_ERR_CRLOGFILE_EID 3 + +/** \brief 'Invalid command packet, Message ID = 0x\%08X' +** \event 'Invalid command packet, Message ID = 0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a message has arrived on +** the cFE Event Services Application's Message Pipe that has a +** Message ID that is neither #CFE_EVS_CMD_MID or #CFE_EVS_SEND_HK_MID. +** Most likely, the cFE Software Bus routing table has become corrupt +** and is sending messages targeted for other Applications to the cFE +** Event Services Application. +** +** The \c ID field in the event message identifies +** the message ID (in hex) that was found in the message. +**/ +#define CFE_EVS_ERR_MSGID_EID 5 + +/** \brief '\%s Event ID \%d not registered for filtering: CC = \%lu' +** \event '\%s Event ID \%d not registered for filtering: CC = \%lu' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when the specified command identifies an Application and Event ID combination +** that is not found in the Events Registry. +** +** The \c \%s string contains the command specified Application Name the \c Event \c ID field +** identifies the command specified EventID (in decimal) that was not found in the Events Registry. +** The \c CC field specifies the Command Code whose processing generated the event message. It can +** be equal to either #CFE_EVS_SET_FILTER_CC, #CFE_EVS_RESET_FILTER_CC, or #CFE_EVS_DELETE_EVENT_FILTER_CC. +**/ +#define CFE_EVS_ERR_EVTIDNOREGS_EID 6 + +/** \brief '\%s not registered with EVS: CC = \%lu' +** \event '\%s not registered with EVS: CC = \%lu' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when the specified command identifies an Application that has not been +** registered with the cFE Event Services. +** +** The \c CC field contains the Command Code whose processing resulted in the generation of the event message. +** Possible values are #CFE_EVS_SET_FILTER_CC, #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC, #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC, +** #CFE_EVS_ENABLE_APP_EVENTS_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC, #CFE_EVS_RESET_APP_COUNTER_CC, #CFE_EVS_RESET_FILTER_CC, +** #CFE_EVS_RESET_ALL_FILTERS_CC, #CFE_EVS_ADD_EVENT_FILTER_CC, or #CFE_EVS_DELETE_EVENT_FILTER_CC. +**/ +#define CFE_EVS_ERR_APPNOREGS_EID 7 + +/** \brief 'Illegal application ID \%d retrieved for \%s: CC = \%lu' +** \event 'Illegal application ID \%d retrieved for \%s: CC = \%lu' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when the specified command identifies an Application whose name is +** found in the Events Registry but does not appear to be properly registered with the cFE Executive Services. +** +** The \c CC field contains the Command Code whose processing resulted in the generation of the event message. +** Possible values are #CFE_EVS_SET_FILTER_CC, #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC, #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC, +** #CFE_EVS_ENABLE_APP_EVENTS_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC, #CFE_EVS_RESET_APP_COUNTER_CC, #CFE_EVS_RESET_FILTER_CC, +** #CFE_EVS_RESET_ALL_FILTERS_CC, #CFE_EVS_ADD_EVENT_FILTER_CC, or #CFE_EVS_DELETE_EVENT_FILTER_CC. +**/ +#define CFE_EVS_ERR_ILLAPPIDRANGE_EID 8 + +/** \brief 'Unable to retrieve application ID for \%s: CC = \%lu' +** \event 'Unable to retrieve application ID for \%s: CC = \%lu' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when the specified command contains an Application name that is +** apparently found in the Events Registry but does not appear to be registered with the cFE Executive Services. +** +** The \c CC field contains the Command Code whose processing resulted in the generation of the event message. +** Possible values are #CFE_EVS_SET_FILTER_CC, #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC, #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC, +** #CFE_EVS_ENABLE_APP_EVENTS_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC, #CFE_EVS_RESET_APP_COUNTER_CC, #CFE_EVS_RESET_FILTER_CC, +** #CFE_EVS_RESET_ALL_FILTERS_CC, #CFE_EVS_ADD_EVENT_FILTER_CC, or #CFE_EVS_DELETE_EVENT_FILTER_CC. +**/ +#define CFE_EVS_ERR_NOAPPIDFOUND_EID 9 + +/** \brief 'Set Event Format Mode Command: Invalid Event Format Mode = 0x\%02x' +** \event 'Set Event Format Mode Command: Invalid Event Format Mode = 0x\%02x' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a "Set Event Format Mode" command +** message has arrived and the #CFE_EVS_ModeCmd_t::Mode field is equal to +** neither #CFE_EVS_SHORT_FORMAT or #CFE_EVS_LONG_FORMAT. These are the +** only allowed values for the mode field. +** +** The \c Mode field in the event message identifies +** the Mode value (in hex) that was found in the message. +**/ +#define CFE_EVS_ERR_ILLEGALFMTMOD_EID 10 + +/** \brief 'Add Filter Command: number of registered filters has reached max = \%d' +** \event 'Add Filter Command: number of registered filters has reached max = \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon receipt of an "Add Filter" command +** and the specified Application has already reached the maximum number of +** filters allowed (#CFE_EVS_MAX_EVENT_FILTERS). +** +** The \c max field in the event message identifies the maximum number of +** event filters allowed per Application. This value should be equal to +** the configuration parameter #CFE_EVS_MAX_EVENT_FILTERS. +**/ +#define CFE_EVS_ERR_MAXREGSFILTER_EID 11 + +/** \brief 'Write App Data Command Error: OS_write = 0x\%08X, filename = \%s' +** \event 'Write App Data Command Error: OS_write = 0x\%08X, filename = \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a filesystem error occurred while writing the contents of the +** event registry to a file. +** +** The message text identifies the registry filename and specifies the return value, in hex, +** from the system function call. The expected return value is the number of bytes written, +** which in this case should be equal to the size of a #CFE_EVS_AppDataFile_t structure. Error +** codes are negative. +**/ +#define CFE_EVS_ERR_WRDATFILE_EID 12 + +/** \brief 'Write App Data Command Error: OS_creat = 0x\%08X, filename = \%s' +** \event 'Write App Data Command Error: OS_creat = 0x\%08X, filename = \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a filesystem error occurred when attempting to create the file +** that is to hold the event registry data. +** +** The message text identifies the registry filename and specifies the return value, in hex, +** from the system function call. The expected return value is a file handle, which in this case +** should be a relatively small positive number. Error codes are negative. +**/ +#define CFE_EVS_ERR_CRDATFILE_EID 13 + +/** \brief 'Invalid command code -- ID = 0x\%08x, CC = \%d' +** \event 'Invalid command code -- ID = 0x\%08x, CC = \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a message with the #CFE_EVS_CMD_MID +** message ID has arrived but whose Command Code is not one of the specified +** accepted command codes specified. This problem is most likely to occur when: +** -# A Message ID meant for another Application became corrupted and was +** set equal to #CFE_EVS_CMD_MID. +** -# The Command Code field in the Message became corrupted. +** -# The command database at the ground station has been corrupted. +** +** The \c ID field in the event message specifies the Message ID (in hex) and the +** \c CC field specifies the Command Code (in decimal) found in the message. +**/ +#define CFE_EVS_ERR_CC_EID 15 + +/** \brief 'Reset Counters Command Received' +** \event 'Reset Counters Command Received' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is always automatically issued in response +** to a cFE Event Services Reset Counters command +**/ +#define CFE_EVS_RSTCNT_EID 16 + +/** \brief 'Set Filter Mask Command Received with AppName=\%s, EventID=0x\%08x, Mask=0x\%04x' +** \event 'Set Filter Mask Command Received with AppName=\%s, EventID=0x\%08x, Mask=0x\%04x' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is issued upon successful processing of a Set Filter Mask command. +** +** The \c AppName field identifies the Application whose Filter Mask has been changed. +** The \c EventID field identifies the Event whose Filter Mask has been changed. +** The \c Mask field identifies the new Mask value associated with the specified event. +**/ +#define CFE_EVS_SETFILTERMSK_EID 17 + +/** \brief 'Enable Ports Command Received with Port Bit Mask = 0x\%02x' +** \event 'Enable Ports Command Received with Port Bit Mask = 0x\%02x' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is issued upon successful processing of the "Enable Ports" command. +** +** The \c Mask field identifies the ports that are enabled. +** Mask bits are defined by #CFE_EVS_PORT1_BIT, #CFE_EVS_PORT2_BIT, #CFE_EVS_PORT3_BIT and #CFE_EVS_PORT4_BIT. +**/ +#define CFE_EVS_ENAPORT_EID 18 + +/** \brief 'Disable Ports Command Received with Port Bit Mask = 0x\%02x' +** \event 'Disable Ports Command Received with Port Bit Mask = 0x\%02x' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is issued upon successful processing of the "Disable Ports" command. +** +** The \c Mask field identifies (in hex) the ports are to be disabled. +** Mask bits are defined by #CFE_EVS_PORT1_BIT, #CFE_EVS_PORT2_BIT, #CFE_EVS_PORT3_BIT and #CFE_EVS_PORT4_BIT. +**/ +#define CFE_EVS_DISPORT_EID 19 + +/** \brief 'Enable Event Type Command Received with Event Type Bit Mask = 0x\%02x' +** \event 'Enable Event Type Command Received with Event Type Bit Mask = 0x\%02x' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is issued upon successful processing of the "Enable Event Type" command. +** +** The \c Mask field identifies the Event Types that are enabled. +** Mask bits are defined by #CFE_EVS_DEBUG_BIT, #CFE_EVS_INFORMATION_BIT, +** #CFE_EVS_ERROR_BIT and #CFE_EVS_CRITICAL_BIT. +**/ +#define CFE_EVS_ENAEVTTYPE_EID 20 + +/** \brief 'Disable Event Type Command Received with Event Type Bit Mask = 0x\%02x' +** \event 'Disable Event Type Command Received with Event Type Bit Mask = 0x\%02x' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is issued upon successful processing of the "Disable Event Type" command. +** +** The \c Mask field identifies the Event Types that are disabled. +** Mask bits are defined by #CFE_EVS_DEBUG_BIT, #CFE_EVS_INFORMATION_BIT, +** #CFE_EVS_ERROR_BIT and #CFE_EVS_CRITICAL_BIT. +**/ +#define CFE_EVS_DISEVTTYPE_EID 21 + +/** \brief 'Set Event Format Mode Command Received with Mode = 0x\%02x' +** \event 'Set Event Format Mode Command Received with Mode = 0x\%02x' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon successful completion of the "Set Event Format Mode" command. +** +** The \c Mode field contains the newly chosen Event Format Mode (specified in hex). Acceptable values +** for this parameter are: #CFE_EVS_SHORT_FORMAT or #CFE_EVS_LONG_FORMAT +**/ +#define CFE_EVS_SETEVTFMTMOD_EID 22 + +/** \brief 'Enable App Event Type Command Received with AppName = \%s, EventType Bit Mask = 0x\%02x' +** \event 'Enable App Event Type Command Received with AppName = \%s, EventType Bit Mask = 0x\%02x' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon successful completion of the "Enable Application Event Types" command. +** +** The \c AppName field identifies the Application whose Event Type Enable status has changed and the +** \c Mask field specifies (in hex) the Event Types that have been enabled. +** Mask bits are defined by #CFE_EVS_DEBUG_BIT, #CFE_EVS_INFORMATION_BIT, +** #CFE_EVS_ERROR_BIT and #CFE_EVS_CRITICAL_BIT. +**/ +#define CFE_EVS_ENAAPPEVTTYPE_EID 23 + +/** \brief 'Disable App Event Type Command Received with AppName = \%s, EventType Bit Mask = 0x\%02x' +** \event 'Disable App Event Type Command Received with AppName = \%s, EventType Bit Mask = 0x\%02x' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon successful completion of the "Disable Application Event Types" command. +** +** The \c AppName field identifies the Application whose Event Type Disable status has changed and the +** \c Mask field specifies (in hex) the Event Types that have been disabled. +** Mask bits are defined by #CFE_EVS_DEBUG_BIT, #CFE_EVS_INFORMATION_BIT, +** #CFE_EVS_ERROR_BIT and #CFE_EVS_CRITICAL_BIT. +**/ +#define CFE_EVS_DISAPPENTTYPE_EID 24 + +/** \brief 'Enable App Events Command Received with AppName = \%s' +** \event 'Enable App Events Command Received with AppName = \%s' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon successful completion of the "Enable Application Events" command. +** +** The \c AppName field identifies the Application whose Events have been Enabled. +**/ +#define CFE_EVS_ENAAPPEVT_EID 25 + +/** \brief 'Disable App Events Command Received with AppName = \%s' +** \event 'Disable App Events Command Received with AppName = \%s' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon successful completion of the "Disable Application Events" command. +** +** The \c AppName field identifies the Application whose Events have been Disabled. +**/ +#define CFE_EVS_DISAPPEVT_EID 26 + +/** \brief 'Reset Event Counter Command Received with AppName = \%s' +** \event 'Reset Event Counter Command Received with AppName = \%s' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon successful completion of the "Reset Application Event Counter" command. +** +** The \c AppName field identifies the Application whose Event Counter has been reset. +**/ +#define CFE_EVS_RSTEVTCNT_EID 27 + +/** \brief 'Reset Filter Command Received with AppName = \%s, EventID = 0x\%08x' +** \event 'Reset Filter Command Received with AppName = \%s, EventID = 0x\%08x' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon successful completion of the "Reset Application Event Message Filter" command. +** +** The \c AppName field identifies the Application whose Event Message Filter has been reset and +** the \c EventID field identifies the specific event message whose filter has been reset. +**/ +#define CFE_EVS_RSTFILTER_EID 28 + +/** \brief 'Reset All Filters Command Received with AppName = \%s' +** \event 'Reset All Filters Command Received with AppName = \%s' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon successful completion of the "Reset Application Event Message Filters" command. +** +** The \c AppName field identifies the Application whose entire set of Event Filters has been reset. +**/ +#define CFE_EVS_RSTALLFILTER_EID 29 + +/** \brief 'Add Filter Command Received with AppName = \%s, EventID = 0x\%08x, Mask = 0x\%04x' +** \event 'Add Filter Command Received with AppName = \%s, EventID = 0x\%08x, Mask = 0x\%04x' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon successful completion of the "Add Filter" command. +** +** The \c AppName field identifies the Application who is getting the new filter, the \c EventID field +** identifies the Event Identifier, in hex, that is getting the filter, and the \c Mask field specifies, in hex, +** what the binary filter mask has been set to. +**/ +#define CFE_EVS_ADDFILTER_EID 30 + +/** \brief 'Delete Filter Command Received with AppName = \%s, EventID = 0x\%08x' +** \event 'Delete Filter Command Received with AppName = \%s, EventID = 0x\%08x' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon successful completion of the "Delete Filter" command. +** +** The \c AppName field identifies the Application who is getting the filter removed, the \c EventID field +** identifies the Event Identifier, in hex, whose filter is being deleted. +**/ +#define CFE_EVS_DELFILTER_EID 31 + +/** \brief 'Write App Data Command: \%d application data entries written to \%s' +** \event 'Write App Data Command: \%d application data entries written to \%s' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon successful completion of the +** \link #CFE_EVS_FILE_WRITE_APP_DATA_CC "Write Event Services Application Information to File" \endlink command. +** +** The message text identifies the event log filename and specifies the number, in decimal, +** of events written to the file. +**/ +#define CFE_EVS_WRDAT_EID 32 + +/** \brief 'Write Log File Command: \%d event log entries written to \%s' +** \event 'Write Log File Command: \%d event log entries written to \%s' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon successful completion of the +** \link #CFE_EVS_FILE_WRITE_LOG_DATA_CC "Write Event Log to File" \endlink command. +** +** The message text identifies the event log filename and specifies the number, in decimal, +** of events written to the file. +**/ +#define CFE_EVS_WRLOG_EID 33 + +/** \brief 'Set Log Mode Command: Event Log is Disabled' +** \event 'Set Log Mode Command: Event Log is Disabled' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon receipt of a "Set Log Mode" +** command when the use of the Event Log has been disabled. To enable +** the Event Log, the cFE code must be compiled for the target with +** the \b CFE_EVS_LOG_ON macro defined. The EVS task must also succeed +** during task initialization in acquiring a pointer to the cFE reset +** area and in the creation of a serializing semaphore to control +** access to the Event Log. +**/ +#define CFE_EVS_NO_LOGSET_EID 34 + +/** \brief 'Clear Log Command: Event Log is Disabled' +** \event 'Clear Log Command: Event Log is Disabled' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon receipt of a "Clear Log" +** command when the use of the Event Log has been disabled. To enable +** the Event Log, the cFE code must be compiled for the target with +** the \b CFE_EVS_LOG_ON macro defined. The EVS task must also succeed +** during task initialization in acquiring a pointer to the cFE reset +** area and in the creation of a serializing semaphore to control +** access to the Event Log. +**/ +#define CFE_EVS_NO_LOGCLR_EID 35 + +/** \brief 'Write Log Command: Event Log is Disabled' +** \event 'Write Log Command: Event Log is Disabled' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon receipt of a "Write Log" +** command when the use of the Event Log has been disabled. To enable +** the Event Log, the cFE code must be compiled for the target with +** the \b CFE_EVS_LOG_ON macro defined. The EVS task must also succeed +** during task initialization in acquiring a pointer to the cFE reset +** area and in the creation of a serializing semaphore to control +** access to the Event Log. +**/ +#define CFE_EVS_NO_LOGWR_EID 36 + +/** \brief 'Add Filter Command:AppName = \%s, EventID = 0x\%08x is already registered for filtering' +** \event 'Add Filter Command:AppName = \%s, EventID = 0x\%08x is already registered for filtering' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an "Add Filter" command was received specifying an Event ID that has already +** had a filter added. +** +** The \c AppName field identifies the Application whose filter was to be added and the \c EventID field identifies, +** in hex, the Event ID that the command was trying to add a filter for. +**/ +#define CFE_EVS_EVT_FILTERED_EID 37 + +/** \brief 'Set Log Mode Command Error: Log Mode = \%d' +** \event 'Set Log Mode Command Error: Log Mode = \%d' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated when a "Set Log Mode" command is completed successfully. +** +** The event text identifies the Log Mode command argument. Valid Log Mode command +** arguments are: #CFE_EVS_LOG_OVERWRITE or #CFE_EVS_LOG_DISCARD. +**/ +#define CFE_EVS_LOGMODE_EID 38 + +/** \brief 'Set Log Mode Command Error: Log Mode = \%d' +** \event 'Set Log Mode Command Error: Log Mode = \%d +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a "Set Log Mode" command is received that specifies +** an invalid Log Mode command argument. +** +** The event text identifies the invalid Log Mode command argument. Valid Log Mode command +** arguments are: #CFE_EVS_LOG_OVERWRITE or #CFE_EVS_LOG_DISCARD. +**/ +#define CFE_EVS_ERR_LOGMODE_EID 39 + +/** \brief 'Bit Mask = 0x\%X out of range: CC = \%lu' +** \event 'Bit Mask = 0x\%X out of range: CC = \%lu' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when the bit mask passed in is equal to zero or greater than 0x0F, because a +** bit mask of zero does nothing, and a bitmask of greater than 0x0F is invalid. +**/ +#define CFE_EVS_ERR_INVALID_BITMASK_EID 40 + +/** \brief 'App \%s not registered with Event Services. Unable to send event' +** \event 'App \%s not registered with Event Services. Unable to send event' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an event message has been requested to be sent by an Application that +** has not registered itself with cFE Event Services. +**/ +#define CFE_EVS_ERR_UNREGISTERED_EVS_APP 41 + +/** \brief 'Max filter count reached, AppName = \%s, EventID = 0x\%08x: Filter locked until reset' +** \event 'Max filter count reached, AppName = \%s, EventID = 0x\%08x: Filter locked until reset' +** +** \par Type: INFORMATIONAL +** +** \par Cause: +** +** This event message is generated when the filtering count for a specific App and Event ID reaches #CFE_EVS_MAX_FILTER_COUNT +** The filtered event will no longer be received until the reset counter is reset via a +** \link #CFE_EVS_RESET_FILTER_CC "Reset an Event Filter for an Application" \endlink or a +** \link #CFE_EVS_RESET_ALL_FILTERS_CC "Reset All Event Filters for an Application" \endlink +** +** The \c AppName field identifies the Application and the \c EventID field identifies, in hex, the Event ID +** for the filter whose maxium was reached. +**/ +#define CFE_EVS_FILTER_MAX_EID 42 + +/** \brief 'Invalid cmd length: ID = 0x\%X, CC = \%d, Exp Len = \%d, Len = \%d' +** \event 'Invalid cmd length: ID = 0x\%X, CC = \%d, Exp Len = \%d, Len = \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a message with the #CFE_EVS_CMD_MID +** message ID has arrived but whose packet length does not match the expected +** length for the specified command code. +** +** The \c ID field in the event message specifies the Message ID (in hex), the \c CC field +** specifies the Command Code (in decimal), the \c Exp Len field specified the Expected +** Length (in decimal ), and \c Len specifies the message Length (in decimal) +** found in the message. +**/ +#define CFE_EVS_LEN_ERR_EID 43 + +#endif /* _cfe_evs_events_ */ + diff --git a/src/components/interface/cFE/cfe_evs_msg.h b/src/components/interface/cFE/cfe_evs_msg.h new file mode 100644 index 0000000000..cdbeab9601 --- /dev/null +++ b/src/components/interface/cFE/cfe_evs_msg.h @@ -0,0 +1,1188 @@ +/* +** +** Filename: cfe_evs_msg.h +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA’s Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +* +** $Id: cfe_evs_msg.h 1.6 2012/01/10 15:26:15GMT-05:00 jmdagost Exp $ +** +** Title: Event Services Message definition header file Header File +** +** Purpose: +** Unit specification for Event services command codes and data structures. +** +** Design Notes: +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** +** $Date: 2012/01/10 15:26:15GMT-05:00 $ +** $Revision: 1.6 $ +** $Log: cfe_evs_msg.h $ +** Revision 1.6 2012/01/10 15:26:15GMT-05:00 jmdagost +** Changed command codes to start at zero for no-op (consistent with other apps). +** Revision 1.5 2011/05/23 15:42:27EDT lwalling +** Change unused 32 bit MemPoolHandle to 8 bit LogEnabled and three 8 bit spares +** Revision 1.4 2010/10/04 15:25:19EDT jmdagost +** Cleaned up copyright symbol. +** Revision 1.3 2009/07/31 19:52:03EDT aschoeni +** padded commands to be even number of bytes +** Revision 1.2 2009/03/04 12:12:38EST rmcgraw +** DCR4715:1 Added bit information to event type cmds and port cmds +** Revision 1.1 2008/04/17 08:05:21EDT ruperera +** Member moved from tlserver to tlserver3 +** Revision 1.10 2007/09/18 14:46:46EDT njyanchik +** Check in the telemetry comments +** Revision 1.9 2007/09/18 14:02:18EDT njyanchik +** add command doxygen comments +** Revision 1.8 2007/07/18 14:09:56EDT njyanchik +** moved 12 #defines to cfe_evs_msg.h because they are needed for commands +** Revision 1.7 2007/07/18 11:53:05EDT njyanchik +** The two structures specified in DCR 4407 were moved to cfe_evs_msg.h +** Revision 1.6 2007/06/07 13:07:45EDT dlkobe +** Added Command and Telemetry doxygen comments to TIME, EVS and SB +** Revision 1.5 2007/05/16 15:32:23EDT dlkobe +** Corrected circular data type dependency +** Revision 1.4 2007/05/16 15:13:38EDT dlkobe +** Added MemPoolHandle members to HK packet +** Revision 1.3 2007/04/27 12:31:05EDT njyanchik +** I changed EVS and TIME to not have a telemetry counter for SB pipe reads in +** the main loop. Instead, I have added a syslog message to state the problem +** Revision 1.2 2007/04/11 10:59:55EDT njyanchik +** Remove the TaskDelay in the main loop for EVS. I also added a counter in +** telemtry that will notify the ground of an error in reading the command pipe. +** Revision 1.1 2007/03/01 11:53:54EST njyanchik +** Initial revision +** Member added to cfe project on tlserver +*/ +#ifndef _cfe_evs_msg_ +#define _cfe_evs_msg_ + +/********************************** Include Files ************************************/ +#include "common_types.h" /* Basic data types */ +#include "cfe_time.h" /* Time library function definitions */ +#include "osapi.h" +#include "cfe_sb.h" +#include "cfe_es.h" + + +/** \name Event Services Command Codes */ +/** \{ */ + +/** \cfeevscmd Event Services No-Op +** +** \par Description +** This command performs no other function than to increment the +** command execution counter. The command may be used to verify +** general aliveness of the Event Services task. +** +** \cfecmdmnemonic \EVS_NOOP +** +** \par Command Structure +** #CFE_TBL_NoArgsCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The #CFE_EVS_NOOP_EID informational event message will +** be generated +** +** \par Error Conditions +** There are no error conditions for this command. If the Event +** Services receives the command, the event is sent (although it +** may be filtered by EVS itself) and the counter is incremented +** unconditionally. +** +** \par Criticality +** None +** +** \sa +*/ +#define CFE_EVS_NO_OPERATION_CC 0 + +/** \cfeevscmd Event Services Reset Counters +** +** \par Description +** This command resets the following counters within the Event +** Services housekeeping telemetry: +** - Command Execution Counter (\EVS_CMDPC) +** - Command Error Counter (\EVS_CMDEC) +** +** \cfecmdmnemonic \EVS_RESETCTRS +** +** \par Command Structure +** #CFE_TBL_NoArgsCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The #CFE_EVS_RSTCNT_EID debug event message will be +** generated +** +** \par Error Conditions +** There are no error conditions for this command. If the Event +** Services receives the command, the event is sent (although it +** may be filtered by EVS) and the counter is incremented +** unconditionally. +** +** \par Criticality +** This command is not inherently dangerous. However, it is +** possible for ground systems and on-board safing procedures +** to be designed such that they react to changes in the counter +** values that are reset by this command. +** +** \sa #CFE_EVS_RESET_APP_COUNTER_CC +*/ +#define CFE_EVS_RESET_COUNTERS_CC 1 + +/** \cfeevscmd Enable Event Type +** +** \par Description +** This command enables the command specified Event Type allowing event +** messages of this type to be sent through Event Service. An Event Type +** is defined to be a classification of an Event Message such as debug, +** informational, error and critical. This command is a global enable of a +** particular event type, it applies to all applications. +** +** \cfecmdmnemonic \EVS_ENAEVENTTYPE +** +** \par Command Structure +** #CFE_EVS_BitMaskCmd_t +** The following bit positions apply to structure member named 'BitMask'. +** Bit 0 - Debug +** Bit 1 - Informational +** Bit 2 - Error +** Bit 3 - Critical +** A one in a bit position means the event type will be enabled (or unfiltered). +** A zero in a bit position means the filtering state is unchanged. +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_ENAEVTTYPE_EID debug message +** +** \par Error Conditions +** This command may fail for the following reason(s): +** +** Invalid Event Type selection +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** Enabling an event type is not particularly hazardous, as the result may +** be turning on necessary event messages and communication to the ground +** system. However, inappropriately enabling an event type could result +** in flooding of the system. +** +** \sa #CFE_EVS_DISABLE_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC, +** #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENTS_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC +*/ +#define CFE_EVS_ENABLE_EVENT_TYPE_CC 2 + +/** \cfeevscmd Disable Event Type +** +** \par Description +** This command disables the command specified Event Type preventing event +** messages of this type to be sent through Event Service. An Event Type +** is defined to be a classification of an Event Message such as debug, +** informational, error and critical. This command is a global disable of a +** particular event type, it applies to all applications. +** +** \cfecmdmnemonic \EVS_DISEVENTTYPE +** +** \par Command Structure +** #CFE_EVS_BitMaskCmd_t +** The following bit positions apply to structure member named 'BitMask'. +** Bit 0 - Debug +** Bit 1 - Informational +** Bit 2 - Error +** Bit 3 - Critical +** A one in a bit position means the event type will be disabled (or filtered). +** A zero in a bit position means the filtering state is unchanged. +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** +** - \b \c \EVS_CMDPC - command execution counter will +** increment + - The generation of #CFE_EVS_DISEVTTYPE_EID debug message +** +** \par Error Conditions +** This command may fail for the following reason(s): +** +** - Invalid Event Type selection + +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** Disabling an event type is not particularly hazardous, as the result +** may be shutting off unnecessary event messages and possible event +** flooding of the system. However, inappropriately disabling an event +** type could result in a loss of critical information and missed +** behavior for the ground system. +** +** \sa #CFE_EVS_ENABLE_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC, +** #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENTS_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC +*/ +#define CFE_EVS_DISABLE_EVENT_TYPE_CC 3 + +/** \cfeevscmd Set Event Format Mode +** +** \par Description +** This command sets the event format mode to the command specified value. +** The event format mode may be either short or long. A short event format +** detaches the Event Data from the event message and only includes the +** following information in the event packet: Processor ID, Application ID, +** Event ID, and Event Type. Refer to section 5.3.3.4 for a description of +** the Event Service event packet contents. Event Data is defined to be data +** describing an Event that is supplied to the cFE Event Service. ASCII text +** strings are used as the primary format for Event Data because heritage +** ground systems use string compares as the basis for their automated alert +** systems. Two systems, ANSR and SERS were looked at for interface +** definitions. The short event format is used to accommodate experiences +** with limited telemetry bandwidth. The long event format includes all event +** information included within the short format along with the Event Data. +** +** \cfecmdmnemonic \EVS_SETEVTFMT +** +** \par Command Structure +** #CFE_EVS_ModeCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_SETEVTFMTMOD_EID debug message +** +** \par Error Conditions +** This command may fail for the following reason(s): +** Invalid SB message (command) length +** Invalid MODE selection +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** +** \par Criticality +** Setting the event format mode is not particularly hazardous, as the +** result may be saving necessary bandwidth. However, inappropriately +** setting the event format mode could result in a loss of information +** and missed behavior for the ground system +** \sa +*/ +#define CFE_EVS_SET_EVENT_FORMAT_MODE_CC 4 + +/** \cfeevscmd Enable Application Event Type +** +** \par Description +** This command enables the command specified event type for the command +** specified application, allowing the application to send event messages +** of the command specified event type through Event Service. An Event +** Type is defined to be a classification of an Event Message such as +** debug, informational, critical, and error. +** Note: In order for this command to take effect, applications must be +** registered for Event Service. +** +** \cfecmdmnemonic \EVS_ENAAPPEVTTYPE +** +** \par Command Structure +** #CFE_EVS_AppNameBitMaskCmd_t +** The following bit positions apply to structure member named 'BitMask'. +** Bit 0 - Debug +** Bit 1 - Informational +** Bit 2 - Error +** Bit 3 - Critical +** A one in a bit position means the event type will be enabled (or +** unfiltered) for the specified application. +** A zero in a bit position means the filtering state is unchanged for +** the specified application. +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_ENAAPPEVTTYPE_EID debug event message +** +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Invalid Event Type Selection +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** +** \par Criticality +** Enabling an application¿s event type is not particularly hazardous, as +** the result may be turning on necessary event messages and +** communication to the ground system. However, inappropriately enabling +** an application's event type could result in flooding of the ground system. +** +** \sa #CFE_EVS_ENABLE_EVENT_TYPE_CC, #CFE_EVS_DISABLE_EVENT_TYPE_CC, +** #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENTS_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC +*/ +#define CFE_EVS_ENABLE_APP_EVENT_TYPE_CC 5 + +/** \cfeevscmd Disable Application Event Type +** +** \par Description +** This command disables the command specified event type for the command +** specified application, preventing the application from sending event +** messages of the command specified event type through Event Service. +** An Event Type is defined to be a classification of an Event Message such +** as debug, informational, critical, and error. Note: In order for this +** command to take effect, applications must be registered for Event Service. +** +** \cfecmdmnemonic \EVS_DISAPPEVTTYPE +** +** \par Command Structure +** #CFE_EVS_AppNameBitMaskCmd_t +** The following bit positions apply to structure member named 'BitMask'. +** Bit 0 - Debug +** Bit 1 - Informational +** Bit 2 - Error +** Bit 3 - Critical +** A one in a bit position means the event type will be disabled (or +** filtered) for the specified application. +** A zero in a bit position means the filtering state is unchanged for +** the specified application. +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_DISAPPENTTYPE_EID debug event message +** - The clearing of the Active Flag in \link #CFE_EVS_AppDataFile_t::ActiveFlag The Active Flag in EVS App Data File \endlink +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Invalid Event Type Selection +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** Disabling an application's event type is not particularly hazardous, +** as the result may be shutting off unnecessary event messages and +** possible event flooding of the system. However, inappropriately +** disabling an application's event type could result in a loss of critical +** information and missed behavior for the ground system. +** +** \sa #CFE_EVS_ENABLE_EVENT_TYPE_CC, #CFE_EVS_DISABLE_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC, +** #CFE_EVS_ENABLE_APP_EVENTS_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC +*/ +#define CFE_EVS_DISABLE_APP_EVENT_TYPE_CC 6 + +/** \cfeevscmd Enable Event Services for an Application +** +** \par Description +** This command enables the command specified application to send events +** through the Event Service. Note: In order for this command to take +** effect, applications must be registered for Event Service. +** +** \cfecmdmnemonic \EVS_ENAAPPEVGEN +** +** \par Command Structure +** #CFE_EVS_AppNameCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_ENAAPPEVT_EID debug event message +** - The setting of the Active Flag in \link #CFE_EVS_AppDataFile_t::ActiveFlag The Active Flag in EVS App Data File \endlink +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Invalid SB message (command) length +** - Application selected is not registered to receive Event Service +** - Application ID is out of range +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** Enabling an application¿s events is not particularly hazardous, +** as the result may be turning on necessary event messages and +** communication to the ground system. However, inappropriately enabling +** an application's events could result in flooding of the ground system. +** +** \sa #CFE_EVS_ENABLE_EVENT_TYPE_CC, #CFE_EVS_DISABLE_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC, +** #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC +*/ +#define CFE_EVS_ENABLE_APP_EVENTS_CC 7 + +/** \cfeevscmd Disable Event Services for an Application +** +** \par Description +** This command disables the command specified application from sending +** events through Event Service. Note: In order for this command to take +** effect, applications must be registered for Event Service. +** +** \cfecmdmnemonic \EVS_DISAPPEVGEN +** +** \par Command Structure +** #CFE_EVS_AppNameCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_DISAPPEVT_EID debug event message +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Invalid SB message (command) length +** - Application selected is not registered to receive Event Service +** - Application ID is out of range +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** Disabling an application's events is not particularly hazardous, as the +** result may be shutting off unnecessary event messages and possible event +** flooding of the system. However, inappropriately disabling an +** application's events could result in a loss of critical information and +** missed behavior for the ground system. +** +** \sa #CFE_EVS_ENABLE_EVENT_TYPE_CC, #CFE_EVS_DISABLE_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC, +** #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENTS_CC +*/ +#define CFE_EVS_DISABLE_APP_EVENTS_CC 8 + +/** \cfeevscmd Reset Application Event Counters +** +** \par Description +** This command sets the command specified application's event counter to zero. +** Note: In order for this command to take effect, applications must be registered +** for Event Service. +** +** \cfecmdmnemonic \EVS_RSTAPPCTRS +** +** \par Command Structure +** #CFE_EVS_AppNameCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_RSTEVTCNT_EID debug event message +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Invalid SB message (command) length +** - Application selected is not registered to receive Event Service +** - Application ID is out of range +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** This command is not inherently dangerous. However, it is possible for +** ground systems and on-board safing procedures to be designed such that +** they react to changes in the counter value that is reset by this command. +** +** \sa #CFE_EVS_RESET_COUNTERS_CC +*/ +#define CFE_EVS_RESET_APP_COUNTER_CC 9 + +/** \cfeevscmd Set Application Event Filter +** +** \par Description +** This command sets the command specified application's event filter mask +** to the command specified value for the command specified event. Note: +** In order for this command to take effect, applications must be +** registered for Event Service. +** +** \cfecmdmnemonic \EVS_SETBINFLTRMASK +** +** \par Command Structure +** #CFE_EVS_AppNameEventIDMaskCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_SETFILTERMSK_EID debug event message +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Invalid SB message (command) length +** - Application selected is not registered to receive Event Service +** - Application ID is out of range +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** Setting an application¿s event filter mask is not particularly hazardous, +** as the result may be shutting off unnecessary event messages and possible +** event flooding of the system. However, inappropriately setting an +** application's event filter mask could result in a loss of critical +** information and missed behavior for the ground system or flooding of the +** ground system. +** +** \sa #CFE_EVS_RESET_FILTER_CC, #CFE_EVS_RESET_ALL_FILTERS_CC, #CFE_EVS_ADD_EVENT_FILTER_CC, #CFE_EVS_DELETE_EVENT_FILTER_CC +*/ +#define CFE_EVS_SET_FILTER_CC 10 + +/** \cfeevscmd Enable Event Services Output Ports +** +** \par Description +** This command enables the command specified port to output event messages +** +** \cfecmdmnemonic \EVS_ENAPORT +** +** \par Command Structure +** #CFE_EVS_BitMaskCmd_t +** The following bit positions apply to structure member named 'BitMask'. +** Bit 0 - Port 1 +** Bit 1 - Port 2 +** Bit 2 - Port 3 +** Bit 3 - Port 4 +** A one in a bit position means the port will be enabled. +** A zero in a bit position means the port state is unchanged. +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_ENAPORT_EID debug event message +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Invalid SB message (command) length +** - Invalid PORT selection +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** None. +** +** \sa #CFE_EVS_DISABLE_PORTS_CC +*/ +#define CFE_EVS_ENABLE_PORTS_CC 11 + +/** \cfeevscmd Disable Event Services Output Ports +** +** \par Description +** This command disables the specified port from outputting event messages. +** +** \cfecmdmnemonic \EVS_DISPORT +** +** \par Command Structure +** #CFE_EVS_BitMaskCmd_t +** The following bit positions apply to structure member named 'BitMask'. +** Bit 0 - Port 1 +** Bit 1 - Port 2 +** Bit 2 - Port 3 +** Bit 3 - Port 4 +** A one in a bit position means the port will be disabled. +** A zero in a bit position means the port state is unchanged. +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_DISPORT_EID debug event message +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Invalid SB message (command) length +** - Invalid PORT selection +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** None. +** +** \sa #CFE_EVS_ENABLE_PORTS_CC +*/ +#define CFE_EVS_DISABLE_PORTS_CC 12 + +/** \cfeevscmd Reset an Event Filter for an Application +** +** \par Description +** This command resets the command specified application's event filter for +** the command specified event ID. Note: In order for this command to take +** effect, applications must be registered for Event Service. +** +** \cfecmdmnemonic \EVS_RSTBINFLTRCTR +** +** \par Command Structure +** #CFE_EVS_AppNameEventIDCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_RSTFILTER_EID debug event message +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Invalid SB message (command) length +** - Application selected is not registered to receive Event Service +** - Application ID is out of range +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** None. +** +** \sa #CFE_EVS_SET_FILTER_CC, #CFE_EVS_RESET_ALL_FILTERS_CC, #CFE_EVS_ADD_EVENT_FILTER_CC, #CFE_EVS_DELETE_EVENT_FILTER_CC +*/ +#define CFE_EVS_RESET_FILTER_CC 13 + +/** \cfeevscmd Reset All Event Filters for an Application +** +** \par Description +** This command resets all of the command specified applications event +** filters. Note: In order for this command to take effect, applications +** must be registered for Event Service. +** +** \cfecmdmnemonic \EVS_RSTALLFLTRS +** +** \par Command Structure +** #CFE_EVS_AppNameCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_RSTALLFILTER_EID debug event message +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Invalid SB message (command) length +** - Application selected is not registered to receive Event Service +** - Application ID is out of range +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** None. +** +** \sa #CFE_EVS_SET_FILTER_CC, #CFE_EVS_RESET_FILTER_CC, #CFE_EVS_ADD_EVENT_FILTER_CC, #CFE_EVS_DELETE_EVENT_FILTER_CC +*/ +#define CFE_EVS_RESET_ALL_FILTERS_CC 14 + +/** \cfeevscmd Add Application Event Filter +** +** \par Description +** This command adds the given filter for the given application identifier and event identifier. +** Note: In order for this command to take effect, applications +** must be registered for Event Service. +** +** \cfecmdmnemonic \EVS_ADDEVTFLTR +** +** \par Command Structure +** #CFE_EVS_AppNameEventIDMaskCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_ADDFILTER_EID debug event message +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Invalid SB message (command) length +** - Application selected is not registered to receive Event Service +** - Application ID is out of range +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** None. +** +** \sa #CFE_EVS_SET_FILTER_CC, #CFE_EVS_RESET_FILTER_CC, #CFE_EVS_RESET_ALL_FILTERS_CC, #CFE_EVS_DELETE_EVENT_FILTER_CC +*/ +#define CFE_EVS_ADD_EVENT_FILTER_CC 15 + +/** \cfeevscmd Delete Application Event Filter +** +** \par Description +** This command removes the given filter for the given application identifier and event identifier. +** Note: In order for this command to take effect, applications +** must be registered for Event Service. +** +** \cfecmdmnemonic \EVS_DELEVTFLTR +** +** \par Command Structure +** #CFE_EVS_AppNameEventIDMaskCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_DELFILTER_EID debug event message +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Invalid SB message (command) length +** - Application selected is not registered to receive Event Service +** - Application ID is out of range +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** None. +** +** \sa #CFE_EVS_SET_FILTER_CC, #CFE_EVS_RESET_FILTER_CC, #CFE_EVS_RESET_ALL_FILTERS_CC, #CFE_EVS_ADD_EVENT_FILTER_CC +*/ +#define CFE_EVS_DELETE_EVENT_FILTER_CC 16 + +/** \cfeevscmd Write Event Services Application Information to File +** +** \par Description +** This command writes all application data to a file for all applications that +** have registered with the EVS. The application data includes the Application ID, +** Active Flag, Event Count, Event Types Active Flag, and Filter Data. +** +** \cfecmdmnemonic \EVS_WRITEAPPDATA2FILE +** +** \par Command Structure +** #CFE_EVS_AppDataCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_WRDAT_EID debug event message +** - The generation of the file written to +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Invalid SB message (command) length +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** Writing a file is not particularly hazardous, but if proper file management is not +** taken, then the file system can fill up if this command is used repeatedly. +** +** \sa #CFE_EVS_FILE_WRITE_LOG_DATA_CC, #CFE_EVS_SET_LOG_MODE_CC +*/ +#define CFE_EVS_FILE_WRITE_APP_DATA_CC 17 + +/** \cfeevscmd Write Event Log to File +** +** \par Description +** This command requests the Event Service to generate a file containing +** the contents of the local event log. +** +** \cfecmdmnemonic \EVS_WRITELOG2FILE +** +** \par Command Structure +** #CFE_EVS_LogFileCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_WRLOG_EID debug event message +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Invalid SB message (command) length +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** Writing a file is not particularly hazardous, but if proper file management is not +** taken, then the file system can fill up if this command is used repeatedly. +** +** \sa #CFE_EVS_FILE_WRITE_APP_DATA_CC, #CFE_EVS_SET_LOG_MODE_CC, #CFE_EVS_CLEAR_LOG_CC +*/ +#define CFE_EVS_FILE_WRITE_LOG_DATA_CC 18 + +/** \cfeevscmd Set Logging Mode +** +** \par Description +** This command sets the logging mode to the command specified value. +** +** \cfecmdmnemonic \EVS_SETLOGMODE +** +** \par Command Structure +** #CFE_EVS_ModeCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** - The generation of #CFE_EVS_LOGMODE_EID debug event message +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Invalid SB message (command) length +** - Invalid MODE selected +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** Setting the event logging mode is not particularly hazardous, as the +** result may be saving valuable event data. However, inappropriately +** setting the log mode could result in a loss of critical information. +** Note: the event log is a back-up log to the on-board recorder. +** +** \sa #CFE_EVS_FILE_WRITE_LOG_DATA_CC, #CFE_EVS_CLEAR_LOG_CC +*/ +#define CFE_EVS_SET_LOG_MODE_CC 19 + +/** \cfeevscmd Clear Event Log +** +** \par Description +** This command clears the contents of the local event log. +** +** \cfecmdmnemonic \EVS_CLRLOG +** +** \par Command Structure +** #CFE_TBL_NoArgsCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \EVS_CMDPC - command execution counter will +** increment +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Invalid SB message (command) length +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \EVS_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** Clearing the local event log is not particularly hazardous, as the +** result may be making available space to record valuable event data. +** However, inappropriately clearing the local event log could result +** in a loss of critical information. Note: the event log is a back-up +** log to the on-board recorder. +** +** \sa #CFE_EVS_FILE_WRITE_LOG_DATA_CC, #CFE_EVS_SET_LOG_MODE_CC +*/ +#define CFE_EVS_CLEAR_LOG_CC 20 +/** \} */ + + +/* Event Message Format Modes */ +#define CFE_EVS_SHORT_FORMAT 0 +#define CFE_EVS_LONG_FORMAT 1 + +/* Event Type bit masks */ +#define CFE_EVS_DEBUG_BIT 0x0001 +#define CFE_EVS_INFORMATION_BIT 0x0002 +#define CFE_EVS_ERROR_BIT 0x0004 +#define CFE_EVS_CRITICAL_BIT 0x0008 + +/* Output Port bit masks */ +#define CFE_EVS_PORT1_BIT 0x0001 +#define CFE_EVS_PORT2_BIT 0x0002 +#define CFE_EVS_PORT3_BIT 0x0004 +#define CFE_EVS_PORT4_BIT 0x0008 + +/* EVS Log Modes */ +#define CFE_EVS_LOG_OVERWRITE 0 +#define CFE_EVS_LOG_DISCARD 1 + +/****************** Structure Definitions *********************/ + +/** +** \brief Write Event Log to File Command +** +** For command details, see #CFE_EVS_FILE_WRITE_LOG_DATA_CC +** +**/ +typedef struct { + char LogFilename[OS_MAX_PATH_LEN]; /**< \brief Filename where log data is to be written */ +} CFE_EVS_LogFileCmd_Payload_t; + +typedef struct { + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + CFE_EVS_LogFileCmd_Payload_t Payload; +} CFE_EVS_LogFileCmd_t; + +/** +** \brief Write Event Services Application Information to File Command +** +** For command details, see #CFE_EVS_FILE_WRITE_APP_DATA_CC +** +**/ +typedef struct { + char AppDataFilename[OS_MAX_PATH_LEN]; /**< \brief Filename where applicaton data is to be written */ +} CFE_EVS_AppDataCmd_Payload_t; + +typedef struct { + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + CFE_EVS_AppDataCmd_Payload_t Payload; +} CFE_EVS_AppDataCmd_t; + +/** +** \brief Set Event Format Mode or Set Log Mode Commands +** +** For command details, see #CFE_EVS_SET_EVENT_FORMAT_MODE_CC and/or #CFE_EVS_SET_LOG_MODE_CC +** +**/ +typedef struct { + uint8 Mode; /**< \brief Mode to use in the command*/ + uint8 Spare; /**< \brief Pad to even byte*/ +} CFE_EVS_ModeCmd_Payload_t; + +typedef struct { + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + CFE_EVS_ModeCmd_Payload_t Payload; +} CFE_EVS_ModeCmd_t; + +/** +** \brief Enable/Disable Events or Ports Commands +** +** For command details, see #CFE_EVS_ENABLE_EVENT_TYPE_CC, #CFE_EVS_DISABLE_EVENT_TYPE_CC, +** #CFE_EVS_ENABLE_PORTS_CC and/or #CFE_EVS_DISABLE_PORTS_CC +** +**/ +typedef struct { + uint8 BitMask; /**< \brief BitMask to use in the command */ + uint8 Spare; /**< \brief Pad to even byte*/ +} CFE_EVS_BitMaskCmd_Payload_t; + +typedef struct { + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + CFE_EVS_BitMaskCmd_Payload_t Payload; +} CFE_EVS_BitMaskCmd_t; + +/** +** \brief Enable/Disable Application Events or Reset One or All Filter Counters +** +** For command details, see #CFE_EVS_ENABLE_APP_EVENTS_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC, +** #CFE_EVS_RESET_APP_COUNTER_CC and/or #CFE_EVS_RESET_ALL_FILTERS_CC +** +**/ +typedef struct { + char AppName[OS_MAX_API_NAME]; /**< \brief Application name to use in the command*/ +} CFE_EVS_AppNameCmd_Payload_t; + +typedef struct { + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + CFE_EVS_AppNameCmd_Payload_t Payload; +} CFE_EVS_AppNameCmd_t; + +/** +** \brief Reset an Event Filter for an Application +** +** For command details, see #CFE_EVS_RESET_FILTER_CC +** +**/ +typedef struct { + char AppName[OS_MAX_API_NAME]; /**< \brief Application name to use in the command*/ + uint16 EventID; /**< \brief Event ID to use in the command*/ +} CFE_EVS_AppNameEventIDCmd_Payload_t; + +typedef struct { + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + CFE_EVS_AppNameEventIDCmd_Payload_t Payload; +} CFE_EVS_AppNameEventIDCmd_t; + +/** +** \brief Enable/Disable an Event Type for an Application +** +** For command details, see #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC and/or #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC +** +**/ +typedef struct { + char AppName[OS_MAX_API_NAME]; /**< \brief Application name to use in the command*/ + uint8 BitMask; /**< \brief BitMask to use in the command*/ + uint8 Spare; /**< \brief Pad to even byte*/ +} CFE_EVS_AppNameBitMaskCmd_Payload_t; + +typedef struct { + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + CFE_EVS_AppNameBitMaskCmd_Payload_t Payload; +} CFE_EVS_AppNameBitMaskCmd_t; + +/** +** \brief Set, Add or Delete an Event Filter for an Application +** +** For command details, see #CFE_EVS_SET_FILTER_CC, #CFE_EVS_ADD_EVENT_FILTER_CC +** and/or #CFE_EVS_DELETE_EVENT_FILTER_CC +** +**/ +typedef struct { + char AppName[OS_MAX_API_NAME]; /**< \brief Application name to use in the command*/ + uint16 EventID; /**< \brief Event ID to use in the command*/ + uint16 Mask; /**< \brief Mask to use in the command */ +} CFE_EVS_AppNameEventIDMaskCmd_Payload_t; + +typedef struct { + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + CFE_EVS_AppNameEventIDMaskCmd_Payload_t Payload; +} CFE_EVS_AppNameEventIDMaskCmd_t; + +/*************************************************************************/ +/**********************************/ +/* Telemetry Message Data Formats */ +/**********************************/ +typedef struct { + uint32 AppID; /**< \cfetlmmnemonic \EVS_APPID + \brief Numerical application identifier */ + uint16 AppMessageSentCounter; /**< \cfetlmmnemonic \EVS_APPMSGSENTC + \brief Application message sent counter */ + uint8 AppEnableStatus; /**< \cfetlmmnemonic \EVS_APPENASTAT + \brief Application event service enable status */ + uint8 Padding; /**< \cfetlmmnemonic \EVS_SPARE2ALIGN3 + \brief Padding for 32 bit boundary */ + +} CFE_EVS_AppTlmData_t; + + +/** +** \cfeevstlm Event Services Housekeeping Telemetry Packet +**/ +typedef struct { + uint8 CommandCounter; /**< \cfetlmmnemonic \EVS_CMDPC + \brief EVS Command Counter */ + uint8 CommandErrCounter; /**< \cfetlmmnemonic \EVS_CMDEC + \brief EVS Command Error Counter */ + uint8 MessageFormatMode; /**< \cfetlmmnemonic \EVS_MSGFMTMODE + \brief Event message format mode (short/long) */ + uint8 MessageTruncCounter; /**< \cfetlmmnemonic \EVS_MSGTRUNC + \brief Event message truncation counter */ + + uint8 UnregisteredAppCounter; /**< \cfetlmmnemonic \EVS_UNREGAPPC + \brief Unregistered application message send counter */ + uint8 OutputPort; /**< \cfetlmmnemonic \EVS_OUTPUTPORT + \brief Output port mask */ + uint8 LogFullFlag; /**< \cfetlmmnemonic \EVS_LOGFULL + \brief Local event log full flag */ + uint8 LogMode; /**< \cfetlmmnemonic \EVS_LOGMODE + \brief Local event logging mode (overwrite/discard) */ + + uint16 MessageSendCounter; /**< \cfetlmmnemonic \EVS_MSGSENTC + \brief Event message send counter */ + uint16 LogOverflowCounter; /**< \cfetlmmnemonic \EVS_LOGOVERFLOWC + \brief Local event log overflow counter */ + + uint8 LogEnabled; /**< \cfetlmmnemonic \EVS_LOGENABLED + \brief Current event log enable/disable state */ + uint8 Spare1; /**< \cfetlmmnemonic \EVS_HK_SPARE1 + \brief Padding for 32 bit boundary */ + uint8 Spare2; /**< \cfetlmmnemonic \EVS_HK_SPARE2 + \brief Padding for 32 bit boundary */ + uint8 Spare3; /**< \cfetlmmnemonic \EVS_HK_SPARE3 + \brief Padding for 32 bit boundary */ + + CFE_EVS_AppTlmData_t AppData[CFE_ES_MAX_APPLICATIONS]; /**< \cfetlmmnemonic \EVS_APP + \brief Array of registered application table data */ + +} CFE_EVS_TlmPkt_Payload_t; + +typedef struct { + uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; + CFE_EVS_TlmPkt_Payload_t Payload; +} CFE_EVS_TlmPkt_t; + +/** Telemetry packet structures */ + +typedef struct { + char AppName[OS_MAX_API_NAME]; /**< \cfetlmmnemonic \EVS_APPNAME + \brief Application name */ + uint16 EventID; /**< \cfetlmmnemonic \EVS_EVENTID + \brief Numerical event identifier */ + uint16 EventType; /**< \cfetlmmnemonic \EVS_EVENTTYPE + \brief Numerical event type identifier */ + uint32 SpacecraftID; /**< \cfetlmmnemonic \EVS_SCID + \brief Spacecraft identifier */ + uint32 ProcessorID; /**< \cfetlmmnemonic \EVS_PROCESSORID + \brief Numerical processor identifier */ + +} CFE_EVS_PacketID_t; + + +/** +** \cfeevstlm Event Message Telemetry Packet +**/ +typedef struct { + CFE_EVS_PacketID_t PacketID; /**< \brief Event packet information */ + char Message[CFE_EVS_MAX_MESSAGE_LENGTH]; /**< \cfetlmmnemonic \EVS_EVENT + \brief Event message string */ + uint8 Spare1; /**< \cfetlmmnemonic \EVS_SPARE1 + \brief Structure padding */ + uint8 Spare2; /**< \cfetlmmnemonic \EVS_SPARE2 + \brief Structure padding */ +} CFE_EVS_Packet_Payload_t; + +typedef struct { + uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; + CFE_EVS_Packet_Payload_t Payload; +} CFE_EVS_Packet_t; + + +#define CFE_EVS_HK_TLM_LNGTH sizeof(CFE_EVS_TlmPkt_t) + + +#endif + + + diff --git a/src/components/interface/cFE/cfe_fs.h b/src/components/interface/cFE/cfe_fs.h new file mode 100644 index 0000000000..64d388fa5f --- /dev/null +++ b/src/components/interface/cFE/cfe_fs.h @@ -0,0 +1,363 @@ +/* +** $Id: cfe_fs.h 1.4 2010/10/25 16:50:16GMT-05:00 jmdagost Exp $ +** +** Purpose: cFE File Services (FS) library API header file +** +** Author: S.Walling/Microtel +** +** $Log: cfe_fs.h $ +** Revision 1.4 2010/10/25 16:50:16GMT-05:00 jmdagost +** Added assumption to CFE_FS_ExtractFilenameFromPath() +** Revision 1.3 2008/08/28 08:41:10EDT apcudmore +** Fixed CFS name ( CFS-->CFE ) +** Revision 1.2 2008/06/20 15:40:26EDT apcudmore +** Added support for OSAL based module loader +** - Removed calls and references to the BSP based module loader +** Revision 1.1 2008/04/17 08:05:22EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.15 2007/09/20 14:47:24EDT apcudmore +** Changed CFE_FS_SB_QUERYALLTASKS_SUBTYPE back to CFE_FS_ES_QUERYALLTASKS_SUBTYPE +** Revision 1.14 2007/09/20 13:17:52EDT David Kobe (dlkobe) +** Added documentation for each File SubType identifier +** Revision 1.13 2007/09/20 10:52:52EDT apcudmore +** Added Query All Tasks command, file definition, events, error codes etc. +** Revision 1.12 2007/05/23 11:21:57EDT dlkobe +** Added doxygen formatting +** Revision 1.11 2007/05/09 12:43:03EDT dlkobe +** Added CFE_FS_ES_CDS_REG_SUBTYPE sub type to support Dump CDS Registry Command +** Revision 1.10 2007/03/29 08:58:09EST rjmcgraw +** Added shell subtype define +** Revision 1.9 2007/03/28 15:18:24EST rjmcgraw +** Moved file related defines from cfe_tbl.h to cfe_fs.h +** Revision 1.8 2007/03/16 15:12:13EST dlkobe +** Swapped parameter list for CFE_FS_ReadHeader API. +** Revision 1.7 2006/11/17 16:46:11GMT-05:00 dlkobe +** Updated with Doxygen formatted comments +** Revision 1.6 2006/07/25 14:37:50GMT-05:00 njyanchik +** It turns out the both the FS app and the OSAL were incorrect where file +** descriptors are concerned. File descriptors should be int32 across the board. +** +*/ + +/* +** Ensure that header is included only once... +*/ +#ifndef _cfe_fs_ +#define _cfe_fs_ + + +/* +** Required header files... +*/ +#include "common_types.h" +#include "cfe_time.h" + + + +/******************* Macro Definitions ***********************/ +#define CFE_FS_HDR_DESC_MAX_LEN 32 /**< \brief Max length of description field in a standard cFE File Header */ + +#define CFE_FS_FILE_CONTENT_ID 0x63464531 /**< \brief Magic Number for cFE compliant files (= 'cFE1') */ + +/** \name Standard cFE File Subtype Identifiers */ +/** \{ */ +#define CFE_FS_ES_ERLOG_SUBTYPE 1 /**< \brief Executive Services Exception/Reset Log Type */ + /**< Executive Services Exception/Reset Log File + which is generated in response to a + \link #CFE_ES_WRITE_ERLOG_CC \ES_WRITEERLOG2FILE \endlink + command. */ +#define CFE_FS_ES_SYSLOG_SUBTYPE 2 /**< \brief Executive Services System Log Type */ + /**< Executive Services System Log File which is + generated in response to a + \link #CFE_ES_WRITE_SYSLOG_CC \ES_WRITESYSLOG2FILE \endlink + command. */ +#define CFE_FS_ES_QUERYALL_SUBTYPE 3 /**< \brief Executive Services Information on All Applications File */ + /**< Executive Services Information on All + Applications File which is generated in response to a + \link #CFE_ES_QUERY_ALL_CC \ES_WRITEAPPINFO2FILE \endlink + command. */ +#define CFE_FS_ES_PERFDATA_SUBTYPE 4 /**< \brief Executive Services Performance Data File */ + /**< Executive Services Performance Analyzer Data File + which is generated in response to a + \link #CFE_ES_PERF_STOPDATA_CC \ES_STOPLADATA \endlink + command. */ +#define CFE_FS_ES_SHELL_SUBTYPE 5 /**< \brief Executive Services Shell Response File */ + /**< Executive Services Shell Response Data File + which is generated in response to a + \link #CFE_ES_SHELL_CMD_CC \ES_SHELL \endlink + command. */ +#define CFE_FS_ES_CDS_REG_SUBTYPE 6 /**< \brief Executive Services Critical Data Store Registry Dump File */ + /**< Executive Services Critical Data Store Registry Dump File + which is generated in response to a + \link #CFE_ES_DUMP_CDS_REG_CC \ES_DUMPCDSREG \endlink + command. */ +#define CFE_FS_TBL_REG_SUBTYPE 9 /** \brief Table Services Registry Dump File */ + /**< Table Services Registry Dump File + which is generated in response to a + \link #CFE_TBL_DUMP_REG_CC \TBL_WRITEREG2FILE \endlink + command. */ +#define CFE_FS_TBL_IMG_SUBTYPE 8 /**< \brief Table Services Table Image File */ + /**< Table Services Table Image File + which is generated either on the ground or in response to a + \link #CFE_TBL_DUMP_CC \TBL_DUMP \endlink command. */ +#define CFE_FS_EVS_APPDATA_SUBTYPE 15 /**< \brief Event Services Application Data Dump File */ + /**< Event Services Application Data Dump File + which is generated in response to a + \link #CFE_EVS_FILE_WRITE_APP_DATA_CC \EVS_WRITEAPPDATA2FILE \endlink + command. */ +#define CFE_FS_EVS_EVENTLOG_SUBTYPE 16 /**< \brief Event Services Local Event Log Dump File */ + /**< Event Services Local Event Log Dump File + which is generated in response to a + \link #CFE_EVS_FILE_WRITE_LOG_DATA_CC \EVS_WRITELOG2FILE \endlink + command. */ +#define CFE_FS_SB_PIPEDATA_SUBTYPE 20 /**< \brief Software Bus Pipe Data Dump File */ + /**< Software Bus Pipe Data Dump File + which is generated in response to a + \link #CFE_SB_SEND_PIPE_INFO_CC \SB_WRITEPIPE2FILE \endlink + command. */ +#define CFE_FS_SB_ROUTEDATA_SUBTYPE 21 /**< \brief Software Bus Message Routing Data Dump File */ + /**< Software Bus Message Routing Data Dump File + which is generated in response to a + \link #CFE_SB_SEND_ROUTING_INFO_CC \SB_WRITEROUTING2FILE \endlink + command. */ +#define CFE_FS_SB_MAPDATA_SUBTYPE 22 /**< \brief Software Bus Message Mapping Data Dump File */ + /**< Software Bus Message Mapping Data Dump File + which is generated in response to a + \link #CFE_SB_SEND_MAP_INFO_CC \SB_WRITEMAP2FILE \endlink + command. */ +#define CFE_FS_ES_QUERYALLTASKS_SUBTYPE 23 /**< \brief Executive Services Query All Tasks Data File */ + /**< Executive Services Query All Tasks Data File + which is generated in response to a + \link #CFE_ES_QUERY_ALL_TASKS_CC \ES_WRITETASKINFO2FILE \endlink + command. */ +/** \} */ + +/** +** \brief Standard cFE File header structure definition +*/ +typedef struct +{ + uint32 ContentType; /**< \brief Identifies the content type (='cFE1'=0x63464531)*/ + uint32 SubType; /**< \brief Type of \c ContentType, if necessary */ + /**< Standard SubType definitions can be found + \link #CFE_FS_ES_ERLOG_SUBTYPE here \endlink */ + uint32 Length; /**< \brief Length of primary header */ + uint32 SpacecraftID; /**< \brief Spacecraft that generated the file */ + uint32 ProcessorID; /**< \brief Processor that generated the file */ + uint32 ApplicationID; /**< \brief Application that generated the file */ + + uint32 TimeSeconds; /**< \brief File creation timestamp (seconds) */ + uint32 TimeSubSeconds; /**< \brief File creation timestamp (sub-seconds) */ + + char Description[CFE_FS_HDR_DESC_MAX_LEN]; /**< \brief File description */ + +} CFE_FS_Header_t; + + +/* +** File header access functions... +*/ + +/*****************************************************************************/ +/** +** \brief Read the contents of the Standard cFE File Header +** +** \par Description +** This API will fill the specified #CFE_FS_Header_t variable with the +** contents of the Standard cFE File Header of the file identified by +** the given File Descriptor. +** +** \par Assumptions, External Events, and Notes: +** -# The File has already been successfully opened using #OS_open and +** the caller has a legitimate File Descriptor. +** +** \param[in] FileDes File Descriptor obtained from a previous call to #OS_open +** that is associated with the file whose header is to be read. +** +** \param[in] Hdr Pointer to a variable of type #CFE_FS_Header_t that will be +** filled with the contents of the Standard cFE File Header. +** +** \param[out] *Hdr Contents of the Standard cFE File Header for the specified file. +** +** \returns +** \retstmt Any of the return codes specified for #OS_lseek or #OS_read \endstmt +** \endreturns +** +** \sa #CFE_FS_WriteHeader +** +******************************************************************************/ +int32 CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, int32 FileDes); + +/*****************************************************************************/ +/** +** \brief Initializes the contents of the Standard cFE File Header +** +** \par Description +** This API will clear the specified #CFE_FS_Header_t variable and +** initialize the description field with the specified value +** +** \param[in] Hdr Pointer to a variable of type #CFE_FS_Header_t that will be +** cleared and initialized +** +** \sa #CFE_FS_WriteHeader +** +******************************************************************************/ +void CFE_FS_InitHeader(CFE_FS_Header_t *Hdr, const char *Description, uint32 SubType); + +/*****************************************************************************/ +/** +** \brief Write the specified Standard cFE File Header to the specified file +** +** \par Description +** This API will output the specified #CFE_FS_Header_t variable, with some +** fields automatically updated, to the specified file as the Standard cFE +** File Header. This API will automatically populate the following fields +** in the specified #CFE_FS_Header_t: +** +** -# \link #CFE_FS_Header_t::ContentType \c ContentType \endlink - Filled with 0x63464531 ('cFE1') +** -# \link #CFE_FS_Header_t::Length \c Length \endlink - Filled with the sizeof(CFE_FS_Header_t) +** -# \link #CFE_FS_Header_t::SpacecraftID \c SpacecraftID \endlink - Filled with the Spacecraft ID +** -# \link #CFE_FS_Header_t::ProcessorID \c ProcessorID \endlink - Filled with the Processor ID +** -# \link #CFE_FS_Header_t::ApplicationID \c ApplicationID \endlink - Filled with the Application ID +** -# \link #CFE_FS_Header_t::TimeSeconds \c TimeSeconds \endlink - Filled with the Time, in seconds, as obtained by #CFE_TIME_GetTime +** -# \link #CFE_FS_Header_t::TimeSubSeconds \c TimeSubSeconds \endlink - Filled with the Time, subseconds, as obtained by #CFE_TIME_GetTime +** +** +** \par Assumptions, External Events, and Notes: +** -# The File has already been successfully opened using #OS_open and +** the caller has a legitimate File Descriptor. +** -# The \c SubType field has been filled appropriately by the Application. +** -# The \c Description field has been filled appropriately by the Application. +** +** \param[in] FileDes File Descriptor obtained from a previous call to #OS_open +** that is associated with the file whose header is to be read. +** +** \param[in] Hdr Pointer to a variable of type #CFE_FS_Header_t that will be +** filled with the contents of the Standard cFE File Header. +** +** \param[out] *Hdr Contents of the Standard cFE File Header for the specified file. +** +** \returns +** \retstmt Any of the return codes specified for #OS_lseek or #OS_write \endstmt +** \endreturns +** +** \sa #CFE_FS_ReadHeader +** +******************************************************************************/ +int32 CFE_FS_WriteHeader(int32 FileDes, CFE_FS_Header_t *Hdr); + +/*****************************************************************************/ +/** +** \brief Modifies the Time Stamp field in the Standard cFE File Header for the specified file +** +** \par Description +** This API will modify the \link #CFE_FS_Header_t::TimeSeconds timestamp \endlink found +** in the Standard cFE File Header of the specified file. The timestamp will be replaced +** with the time specified by the caller. +** +** \par Assumptions, External Events, and Notes: +** -# The File has already been successfully opened using #OS_open and +** the caller has a legitimate File Descriptor. +** -# The \c NewTimestamp field has been filled appropriately by the Application. +** +** \param[in] FileDes File Descriptor obtained from a previous call to #OS_open +** that is associated with the file whose header is to be read. +** +** \param[in] NewTimestamp A #CFE_TIME_SysTime_t data structure containing the desired time +** to be put into the file's Standard cFE File Header. +** +** \returns +** \retstmt Any of the return codes specified for #OS_lseek or #OS_write \endstmt +** \endreturns +** +** \sa +** +******************************************************************************/ +int32 CFE_FS_SetTimestamp(int32 FileDes, CFE_TIME_SysTime_t NewTimestamp); + + +/*****************************************************************************/ +/** +** \brief Determines if a file is a Gzip/compressed file. +** +** \par Description +** This API will check the filename and return TRUE if the file is +** a gzip file. The check is currently based on the filename, so the +** zipped files should use the ".gz" extention. +** +** \par Assumptions, External Events, and Notes: +** -# A gzipped file will use the ".gz" filename extention. +** +** \param[in] FileName The name of the file. +** +** \returns +** \retstmt TRUE if the file has the ".gz" extention and FALSE otherwise. \endstmt +** \endreturns +** +** \sa +** +******************************************************************************/ +boolean CFE_FS_IsGzFile(const char *FileName); + +/*****************************************************************************/ +/** +** \brief Extracts the filename from a unix style path and filename string. +** +** \par Description +** This API will take the original unix path/filename combination and +** extract the base filename. Example: Given the path/filename : "/cf/apps/myapp.o.gz" +** this function will return the filename: "myapp.o.gz". +** +** \par Assumptions, External Events, and Notes: +** -# The paths and filenames used here are the standard unix style +** filenames separated by "/" characters. +** -# The extracted filename is no longer than #OS_MAX_PATH_LEN +** +** \param[in] OriginalPath The original path. +** \param[out] FileNameOnly The filename that is extracted from the path. +** +** \returns +** \retstmt CFE_SUCCESS if the filename was extracted from the path \endstmt +** \endreturns +** +** \sa +** +******************************************************************************/ +int32 CFE_FS_ExtractFilenameFromPath(const char *OriginalPath, char *FileNameOnly); + +/*****************************************************************************/ +/** +** \brief Decompresses the source file to the destination file. +** +** \par Description +** This API will decompress the source file to the file specified by +** the destination file. The file must be compressed using the "gzip" +** utility. This utility is available on most unix workstations, Mac OS X, +** Cygwin, and MinGW for Windows. More information can be found at +** http://www.gzip.org/ +** +** \par Assumptions, External Events, and Notes: +** -# The paths and filenames used here are cfe compliant file names. +** -# The source file is compressed with the "gzip" utility. +** -# The destination file does not exist, or can be overwritten. +** +** \param[in] SourceFile The "gzipped" file to decompress. +** \param[out] DestinationFile The path/filename to write the decompressed or +** "gunzipped" file to. +** +** \returns +** \retstmt CFE_SUCCESS if the file was decompressed sucessfully. \endstmt +** \endreturns +** +** \sa +** +******************************************************************************/ +int32 CFE_FS_Decompress( const char * SourceFile, const char * DestinationFile ); + + +#endif /* _cfe_fs_ */ + +/************************/ +/* End of File Comment */ +/************************/ diff --git a/src/components/interface/cFE/cfe_mission_cfg.h b/src/components/interface/cFE/cfe_mission_cfg.h new file mode 100644 index 0000000000..7c990459d5 --- /dev/null +++ b/src/components/interface/cFE/cfe_mission_cfg.h @@ -0,0 +1,477 @@ +/****************************************************************************** +** File: cfe_mission_cfg.h +** +** Purpose: +** This header file contains the mission configuration parameters and +** typedefs with mission scope. +** +** Author: R.McGraw/SSI +** +** Notes: +** +** $Log: cfe_mission_cfg.h $ +** Revision 1.9 2011/11/30 15:13:24GMT-05:00 jmdagost +** Changed definitions to be TRUE/FALSE instead of commenting/uncommenting them. +** Revision 1.8 2011/02/03 15:20:10EST lwalling +** Added definition for CFE_SB_PACKET_TIME_FORMAT and list of supported selections +** Revision 1.7 2009/06/26 10:17:13EDT rmcgraw +** DCR8290:6 Comment changes +** Revision 1.6 2009/02/26 17:45:07EST rmcgraw +** Member moved from ../fsw/build/inc/ to ../fsw/mission_inc/ +** Revision 1.5 2009/02/26 17:45:07ACT rmcgraw +** DCR6805:1 Added comments to reflect SB cfg paramater limits +** Revision 1.4 2008/12/08 12:07:02EST dkobe +** Updates to correct doxygen errors +** Revision 1.3 2008/11/19 08:45:22EST wfmoleski +** The changes are as follows: +** added 6 #defines (2 for each cpu) that indicate the APPID_BASE for cmds and tlm. +** Revision 1.2 2008/07/07 14:09:42EDT apcudmore +** Removed FS Message ID defines from system config files. +** Revision 1.1 2008/04/17 08:02:33EDT ruperera +** Initial revision +** Member added to /fsw/build/inc/project.pj +** Revision 1.21 2007/09/19 15:21:16EDT rjmcgraw +** DCR4488 Removed all SB network message numbers and message ids +** Revision 1.20 2007/09/12 16:06:11EDT David Kobe (dlkobe) +** Moved the definitions of CFE_ES_CRC_xx to the cfe_mission_cfg.h file and deleted TBL Services +** CRC #define statement. +** Revision 1.19 2007/09/12 09:46:03EDT David Kobe (dlkobe) +** Added doxygen comments to commands and some configuration parameters +** Revision 1.18 2007/06/08 11:12:47EDT rjmcgraw +** Added doxygen comments +** Revision 1.17 2007/05/04 20:07:53EDT dlkobe +** Added command to telemeter memory pool statistics +** Revision 1.16 2007/04/19 15:43:48EDT rjmcgraw +** Removed SBP related #defines +** Revision 1.15 2007/02/23 09:11:33EST njyanchik +** Added CFE_ES_SHELL_TLM_MSG +** Revision 1.14 2006/12/28 16:25:40EST rjmcgraw +** Added msg numbers for new SB subscription pkts +** Revision 1.13 2006/12/26 15:13:37EST rjmcgraw +** Comment changes in networking defines +** Revision 1.12 2006/11/28 11:28:30EST mobartholomew +** Updated cfe_mission_cfg to reference valid CRC type +** Revision 1.11 2006/11/09 15:30:07EST rjmcgraw +** Added #define for CFE_SPACECRAFT_ID +** Revision 1.10 2006/10/30 12:53:13EST dlkobe +** Baseline Critical Data Store Implementation +** +******************************************************************************/ + +#ifndef _cfe_mission_cfg_ +#define _cfe_mission_cfg_ + + +/** +** \cfemissioncfg Spacecraft ID +** +** \par Description: +** This defines the value that is returned by the call to +** CFE_PSP_GetSpacecraftId. +** +** \par Limits +** The cFE does not place a limit on this configuration paramter. +** CCSDS allocates 8 bits for this field in the standard VCDU. +*/ +#define CFE_SPACECRAFT_ID 0x42 + + +/** +** \cfemissioncfg Spacecraft ID +** +** \par Description: +** Dictates the message format used by the cFE. +** +** \par Limits +** All versions of the cFE currently support only CCSDS as the message format +*/ +#define MESSAGE_FORMAT_IS_CCSDS + + +/** \name Packet timestamp format identifiers */ +/** \{ */ +#define CFE_SB_TIME_32_16_SUBS 1 /**< \brief 32 bits seconds + 16 bits subseconds (units = 2^^-16) */ +#define CFE_SB_TIME_32_32_SUBS 2 /**< \brief 32 bits seconds + 32 bits subseconds (units = 2^^-32) */ +#define CFE_SB_TIME_32_32_M_20 3 /**< \brief 32 bits seconds + 20 bits microsecs + 12 bits reserved */ +/** \} */ + +/** +** \cfemissioncfg Packet Timestamp Format Selection +** +** \par Description: +** Defines the size, format and contents of the telemetry packet timestamp. +** +** \par Limits +** Must be defined as one of the supported formats listed above +*/ +#define CFE_SB_PACKET_TIME_FORMAT CFE_SB_TIME_32_16_SUBS + + +/** +** \cfesbcfg Maximum SB Message Size +** +** \par Description: +** The following definition dictates the maximum message size allowed on +** the software bus. SB checks the pkt length field in the header of all +** messages sent. If the pkt length field indicates the message is larger +** than this define, SB sends an event and rejects the send. +** +** +** \par Limits +** This parameter has a lower limit of 6 (CCSDS primary header size), +** and an upper limit (including headers) of 32768 bytes. +*/ +#define CFE_SB_MAX_SB_MSG_SIZE 32768 + + +/** +** \cfetimecfg Default Time Format +** +** \par Description: +** The following definitions select either UTC or TAI as the default +** (mission specific) time format. Although it is possible for an +** application to request time in a specific format, most callers +** should use CFE_TIME_GetTime(), which returns time in the default +** format. This avoids having to modify each individual caller +** when the default choice is changed. +** +** +** \par Limits +** if CFE_TIME_CFG_DEFAULT_TAI is defined as TRUE then CFE_TIME_CFG_DEFAULT_UTC must be +** defined as FALSE. +** if CFE_TIME_CFG_DEFAULT_TAI is defined as FALSE then CFE_TIME_CFG_DEFAULT_UTC must be +** defined as TRUE. +*/ +#define CFE_TIME_CFG_DEFAULT_TAI TRUE +#define CFE_TIME_CFG_DEFAULT_UTC FALSE + + +/** +** \cfetimecfg Default Time Format +** +** \par Description: +** The following definition enables the use of a simulated time at +** the tone signal using a software bus message. +** +** +** \par Limits +** Not Applicable +*/ +#define CFE_TIME_CFG_FAKE_TONE TRUE + + +/** +** \cfetimecfg Default Time and Tone Order +** +** \par Description: +** Time Services may be configured to expect the time at the tone +** data packet to either precede or follow the tone signal. If the +** time at the tone data packet follows the tone signal, then the +** data within the packet describes what the time "was" at the tone. +** If the time at the tone data packet precedes the tone signal, then +** the data within the packet describes what the time "will be" at +** the tone. One, and only one, of the following symbols must be set to TRUE: +** - CFE_TIME_AT_TONE_WAS +** - CFE_TIME_AT_TONE_WILL_BE +** Note: If Time Services is defined as using a simulated tone signal +** (see #CFE_TIME_CFG_FAKE_TONE above), then the tone data packet +** must follow the tone signal. +** +** \par Limits +** Either CFE_TIME_AT_TONE_WAS or CFE_TIME_AT_TONE_WILL_BE must be set to TRUE. +** They may not both be TRUE and they may not both be FALSE. +*/ +#define CFE_TIME_AT_TONE_WAS TRUE +#define CFE_TIME_AT_TONE_WILL_BE FALSE + +/** +** \cfetimecfg Min and Max Time Elapsed +** +** \par Description: +** Based on the definition of Time and Tone Order +** (CFE_TIME_AT_TONE_WAS/WILL_BE) either the "time at the tone" signal or +** data packet will follow the other. This definition sets the valid window +** of time for the second of the pair to lag behind the first. Time +** Services will invalidate both the tone and packet if the second does not +** arrive within this window following the first. +** +** For example, if the data packet follows the tone, it might be valid for +** the data packet to arrive between zero and 100,000 micro-seconds after +** the tone. But, if the tone follows the the packet, it might be valid +** only if the packet arrived between 200,000 and 700,000 micro-seconds +** before the tone. +** +** Note: units are in micro-seconds +** +** +** \par Limits +** 0 to 999,999 decimal +*/ +#define CFE_TIME_MIN_ELAPSED 0 +#define CFE_TIME_MAX_ELAPSED 200000 + + +/** +** \cfetimecfg Default Time Values +** +** \par Description: +** Default time values are provided to avoid problems due to time +** calculations performed after startup but before commands can be +** processed. For example, if the default time format is UTC then +** it is important that the sum of MET and STCF always exceed the +** value of Leap Seconds to prevent the UTC time calculation +** (time = MET + STCF - Leap Seconds) from resulting in a negative +** (very large) number.

+** Some past missions have also created known (albeit wrong) default +** timestamps. For example, assume the epoch is defined as Jan 1, 1970 +** and further assume the default time values are set to create a timestamp +** of Jan 1, 2000. Even though the year 2000 timestamps are wrong, it +** may be of value to keep the time within some sort of bounds acceptable +** to the software.

+** Note: Sub-second units are in micro-seconds (0 to 999,999) and +** all values must be defined +** +** \par Limits +** Not Applicable +*/ +#define CFE_TIME_DEF_MET_SECS 1000 +#define CFE_TIME_DEF_MET_SUBS 0 + +#define CFE_TIME_DEF_STCF_SECS 1000000 +#define CFE_TIME_DEF_STCF_SUBS 0 + +#define CFE_TIME_DEF_LEAPS 32 + +#define CFE_TIME_DEF_DELAY_SECS 0 +#define CFE_TIME_DEF_DELAY_SUBS 1000 + + +/** +** \cfetimecfg Default EPOCH Values +** +** \par Description: +** Default ground time epoch values +** Note: these values are used only by the CFE_TIME_Print() API function +** +** \par Limits +** Year - must be within 136 years +** Day - Jan 1 = 1, Feb 1 = 32, etc. +** Hour - 0 to 23 +** Minute - 0 to 59 +** Second - 0 to 59 +*/ +#define CFE_TIME_EPOCH_YEAR 1980 +#define CFE_TIME_EPOCH_DAY 1 +#define CFE_TIME_EPOCH_HOUR 0 +#define CFE_TIME_EPOCH_MINUTE 0 +#define CFE_TIME_EPOCH_SECOND 0 + + +/** +** \cfetimecfg Time File System Factor +** +** \par Description: +** Define the s/c vs file system time conversion constant... +** +** Note: this value is intended for use only by CFE TIME API functions to +** convert time values based on the ground system epoch (s/c time) to +** and from time values based on the file system epoch (fs time). +** +** FS time = S/C time + factor +** S/C time = FS time - factor +** +** Worksheet: +** +** S/C epoch = Jan 1, 2005 (LRO ground system epoch) +** FS epoch = Jan 1, 1980 (vxWorks DOS file system epoch) +** +** Delta = 25 years, 0 days, 0 hours, 0 minutes, 0 seconds +** +** Leap years = 1980, 1984, 1988, 1992, 1996, 2000, 2004 +** (divisible by 4 -- except if by 100 -- unless also by 400) +** +** 1 year = 31,536,000 seconds +** 1 day = 86,400 seconds +** 1 hour = 3,600 seconds +** 1 minute = 60 seconds +** +** 25 years = 788,400,000 seconds +** 7 extra leap days = 604,800 seconds +** +** total delta = 789,004,800 seconds +** +** \par Limits +** Not Applicable +*/ +#define CFE_TIME_FS_FACTOR 789004800 + + +/** +** \cfeescfg Maximum Length of CDS Name +** +** \par Description: +** Indicates the maximum length (in characers) of the CDS name ('CDSName') +** portion of a Full CDS Name of the following form: +** "ApplicationName.CDSName" +** +** +** \par Limits +** Not Applicable +*/ +#define CFE_ES_CDS_MAX_NAME_LENGTH 16 + + + +/** +** \cfeevscfg Maximum Event Message Length +** +** \par Description: +** Indicates the maximum length (in characers) of the formatted text +** string portion of an event message +** +** \par Limits +** Not Applicable +*/ +#define CFE_EVS_MAX_MESSAGE_LENGTH 122 + + +/** \name Checksum/CRC algorithm identifiers */ +/** \{ */ +#define CFE_ES_CRC_8 1 /**< \brief CRC ( 8 bit additive - returns 32 bit total) (Currently not implemented) */ +#define CFE_ES_CRC_16 2 /**< \brief CRC (16 bit additive - returns 32 bit total) */ +#define CFE_ES_CRC_32 3 /**< \brief CRC (32 bit additive - returns 32 bit total) (Currently not implemented) */ +/** \} */ + +/** +** \cfeescfg Mission Default CRC algorithm +** +** \par Description: +** Indicates the which CRC algorithm should be used as the default +** for verifying the contents of Critical Data Stores and when calculating +** Table Image data integrity values. +** +** \par Limits +** Currently only CFE_ES_CRC_16 is supported (see #CFE_ES_CRC_16) +*/ +#define CFE_ES_DEFAULT_CRC CFE_ES_CRC_16 + + +/** +** \cfetblcfg Maximum Table Name Length +** +** \par Description: +** Indicates the maximum length (in characers) of the table name +** ('TblName') portion of a Full Table Name of the following +** form: "ApplicationName.TblName" +** +** \par Limits +** Not Applicable +*/ +#define CFE_TBL_MAX_NAME_LENGTH 16 + + +/** +** \cfemissioncfg cFE Message ID Base Numbers +** +** \par Description: +** Message Id base numbers for the cFE messages +** NOTE: cFE MsgIds are the sum of the base numbers and the portable msg +** numbers. +** +** \par Limits +** Must be less than CFE_SB_HIGHEST_VALID_MSGID +*/ +#define CFE_CMD_MID_BASE_CPU1 0x1800 +#define CFE_TLM_MID_BASE_CPU1 0x0800 +#define CFE_CMD_APPID_BASE_CPU1 1 +#define CFE_TLM_APPID_BASE_CPU1 0 + +#define CFE_CMD_MID_BASE_CPU2 0x1820 +#define CFE_TLM_MID_BASE_CPU2 0x0820 +#define CFE_CMD_APPID_BASE_CPU2 33 +#define CFE_TLM_APPID_BASE_CPU2 32 + +#define CFE_CMD_MID_BASE_CPU3 0x1840 +#define CFE_TLM_MID_BASE_CPU3 0x0840 +#define CFE_CMD_APPID_BASE_CPU3 65 +#define CFE_TLM_APPID_BASE_CPU3 64 + +#define CFE_CMD_MID_BASE_GLOB 0x1860 +#define CFE_TLM_MID_BASE_GLOB 0x0860 + + + +/** +** \cfemissioncfg cFE Portable Message Numbers for Commands +** +** \par Description: +** Portable message numbers for the cFE command messages +** NOTE: cFE MsgIds are the sum of the base numbers and the portable msg +** numbers. +** +** \par Limits +** Not Applicable +*/ +#define CFE_EVS_CMD_MSG 1 + /* Offset 2 is available */ +#define CFE_SB_CMD_MSG 3 +#define CFE_TBL_CMD_MSG 4 +#define CFE_TIME_CMD_MSG 5 +#define CFE_ES_CMD_MSG 6 + +#define CFE_ES_SEND_HK_MSG 8 +#define CFE_EVS_SEND_HK_MSG 9 + /* Offset 10 is available */ +#define CFE_SB_SEND_HK_MSG 11 +#define CFE_TBL_SEND_HK_MSG 12 +#define CFE_TIME_SEND_HK_MSG 13 + +#define CFE_TIME_TONE_CMD_MSG 16 +#define CFE_TIME_1HZ_CMD_MSG 17 + + +/** +** \cfemissioncfg cFE Portable Message Numbers for Global Messages +** +** \par Description: +** Portable message numbers for the cFE global messages +** NOTE: cFE MsgIds are the sum of the base numbers and the portable msg +** numbers. +** +** \par Limits +** Not Applicable +*/ +#define CFE_TIME_DATA_CMD_MSG 0 +#define CFE_TIME_FAKE_CMD_MSG 1 +#define CFE_TIME_SEND_CMD_MSG 2 + + +/** +** \cfemissioncfg cFE Portable Message Numbers for Telemetry +** +** \par Description: +** Portable message numbers for the cFE telemetry messages +** NOTE: cFE MsgIds are the sum of the base numbers and the portable msg +** numbers. +** +** \par Limits +** Not Applicable +*/ +#define CFE_ES_HK_TLM_MSG 0 +#define CFE_EVS_HK_TLM_MSG 1 + /* Offset 2 is available */ +#define CFE_SB_HK_TLM_MSG 3 +#define CFE_TBL_HK_TLM_MSG 4 +#define CFE_TIME_HK_TLM_MSG 5 +#define CFE_TIME_DIAG_TLM_MSG 6 + +#define CFE_EVS_EVENT_MSG_MSG 8 +#define CFE_SB_STATS_TLM_MSG 10 +#define CFE_ES_APP_TLM_MSG 11 +#define CFE_TBL_REG_TLM_MSG 12 +#define CFE_SB_ALLSUBS_TLM_MSG 13 +#define CFE_SB_ONESUB_TLM_MSG 14 +#define CFE_ES_SHELL_TLM_MSG 15 +#define CFE_ES_MEMSTATS_TLM_MSG 16 + +#endif diff --git a/src/components/interface/cFE/cfe_platform_cfg.h b/src/components/interface/cFE/cfe_platform_cfg.h new file mode 100644 index 0000000000..a2e7e66648 --- /dev/null +++ b/src/components/interface/cFE/cfe_platform_cfg.h @@ -0,0 +1,1857 @@ +/****************************************************************************** +** File: cfe_platform_cfg.h +** +** Purpose: +** This header file contains the platform configuration parameters. +** +** Author: R.McGraw/SSI +** +** $Log: cfe_platform_cfg.h $ +** Revision 1.35 2014/09/09 13:59:50GMT-05:00 lwalling +** Describe effects of removing Table Services from CFE on definition of CFE_ES_MAX_BLOCK_SIZE +** Revision 1.34 2014/08/21 15:29:47EDT rmcgraw +** DCR22696:1 Added #define CFE_ES_EXCEPTION_FUNCTION +** Revision 1.33 2014/08/19 15:01:27EDT sstrege +** Updated reference to OS_BSPGetUserReservedArea to CFE_PSP_GetUserReservedArea +** Revision 1.32 2014/04/14 11:51:41EDT lwalling +** Created platform config definitions for Time 1HZ and Time TONE task priorities and stack sizes +** Revision 1.31 2012/01/18 16:36:58EST jmdagost +** Changed filename reference in cFE Mission Revision comment. +** Revision 1.30 2012/01/06 17:15:22EST lwalling +** Changed default shell output filename from CmdString.out to ShellCmd.out +** Revision 1.29 2011/12/27 16:39:03EST lwalling +** Include mission config file from platform config file +** Revision 1.28 2011/12/21 15:07:51EST lwalling +** Add table file verification definitions for spacecraft ID and processor ID +** Revision 1.27 2011/11/30 15:13:23EST jmdagost +** Changed definitions to be TRUE/FALSE instead of commenting/uncommenting them. +** Revision 1.26 2011/01/18 16:06:04EST lwalling +** Make sending 1hz command packet a configuration option +** Revision 1.25 2010/11/23 15:26:32EST jmdagost +** Added mission-specific revision number definition (4th digit in cFE version number) +** Revision 1.24 2010/11/23 12:10:40EST jmdagost +** Increased SB Max block size to accommodate change in SB. +** Revision 1.23 2010/11/08 16:18:29EST acudmore +** Updated RAM disk path comments +** Revision 1.22 2010/11/08 14:55:13EST aschoeni +** Moved CFE_SB_DEFAULT_MSG_LIMIT from cfe_sb_priv to cfe_platform_cfg +** Revision 1.21 2010/11/08 12:30:11EST acudmore +** Updated CFE_ES_MAX_PROCESSOR_RESETS to 2 ( rather than 5 ) +** Revision 1.20 2010/11/05 15:54:31EDT aschoeni +** Added Generic Counter API to ES +** Revision 1.19 2010/11/04 16:41:46EDT aschoeni +** Added optional sender information storage +** Revision 1.18 2010/11/04 12:48:46EDT acudmore +** Added RAM disk mount path configuration item. +** Revision 1.17 2010/10/27 16:34:42EDT jmdagost +** Changed EVS default log mode from 0 (overwrite) to 1 (discard) +** Revision 1.16 2010/10/26 16:29:28EDT jmdagost +** Deleted unnecessary CFE_ES_MAX_SHELL_CMD_SIZE +** Revision 1.15 2010/10/20 12:43:12EDT jmdagost +** Added reference to CFE_ES_PoolCreateNoSem in documentation. +** Revision 1.14 2009/07/31 14:07:08EDT aschoeni +** Added note to parameters which may affect USER_RESERVED_MEM +** Revision 1.13 2009/07/30 19:22:49EDT jmdagost +** Updated doxygen comments for CFE_TBL_MAX_CRITICAL_TABLES +** Revision 1.12 2009/07/28 18:04:45EDT jmdagost +** Increased default number of registered CDS blocks +** Revision 1.11 2009/07/28 17:16:23EDT jmdagost +** Added initial filter mask and trigger mask definitions. +** Revision 1.10 2009/02/26 17:42:26EST rmcgraw +** Member moved from cfe_platform_cfg.h in project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/platform_inc/project.pj to cfe_platform_cfg.h in project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/platform_inc/cpu1/project.pj. +** Revision 1.9 2009/02/26 17:42:26ACT rmcgraw +** Member moved from cfe_platform_cfg.h in project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/build/cpu1/inc/project.pj to cfe_platform_cfg.h in project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/platform_inc/project.pj. +** Revision 1.8 2009/02/26 17:42:26ACT rmcgraw +** DCR6805:1 Added comments to reflect SB cfg paramater limits +** Revision 1.7 2009/02/11 15:02:33EST rmcgraw +** DCR6269:1 Added SB mem pool block sizes +** Revision 1.6 2008/12/08 12:07:15EST dkobe +** Updates to correct doxygen errors +** Revision 1.5 2008/09/02 10:28:41EDT apcudmore +** Changed Ram Disk NUM_SECTORS back to 4096 +** Revision 1.4 2008/08/06 22:42:32EDT dkobe +** Added CFE_TIME_RegisterSynchCallback, CFE_TIME_UnregisterSynchCallback and CFE_TIME_CleanUpApp +** Revision 1.2 2008/07/25 12:49:08EDT dkobe +** Updated CFE_TBL_MAX_DBL_TABLE_SIZE and CFE_TBL_SNGL_TABLE_SIZE to 16K +** Revision 1.1 2008/07/22 16:51:57EDT apcudmore +** Member moved to .../fsw/build/cpu1/inc +** Revision 1.1 2008/04/17 08:01:30EDT ruperera +** Member moved from cfe project on tlserver to cfe project on tlserver3 +** Revision 1.6 2008/02/13 15:46:52EST rjmcgraw +** DCR6754:1 Removed CFE_SB_EVENT_LOG_ENTRIES +** Revision 1.5 2007/09/25 10:04:36EDT apcudmore +** Created new config parameter for default filename for Query All Tasks cmd. +** Revision 1.4 2007/09/20 11:19:09EDT apcudmore +** Removed vxWorks boot line and IP address from config file. They are no longer being used. +** +******************************************************************************/ + +#ifndef _cfe_platform_cfg_ +#define _cfe_platform_cfg_ + +/* +** Allow reference to CFE_SPACECRAFT_ID (see CFE_TBL_VALID_ definitions below) +*/ +#include "cfe_mission_cfg.h" + +/* +** CPU Id for target Processor +*/ +#define CFE_CPU_ID 1 + +/* +** CPU Name for target Processor +*/ +#define CFE_CPU_NAME "CPU1" + +/** +** \cfesbcfg Maximum Number of Unique Message IDs SB Routing Table can hold +** +** \par Description: +** Dictates the maximum number of unique MsgIds the SB routing table will hold. +** This constant has a direct affect on the size of SB's tables and arrays. +** Keeping this count as low as possible will save memory. +** To see the run-time, high-water mark and the current utilization figures +** regarding this parameter, send an SB command to 'Send Statistics Pkt'. +** +** \par Limits +** This parameter has a lower limit of 1 and an upper limit of 1024. +** +*/ +#define CFE_SB_MAX_MSG_IDS 256 + + +/** +** \cfesbcfg Maximum Number of Unique Pipes SB Routing Table can hold +** +** \par Description: +** Dictates the maximum number of unique Pipes the SB routing table will hold. +** This constant has a direct affect on the size of SB's tables and arrays. +** Keeping this count as low as possible will save memory. +** To see the run-time, high-water mark and the current utilization figures +** regarding this parameter, send an SB command to 'Send Statistics Pkt'. +** +** \par Limits +** This parameter has a lower limit of 1 and an upper limit of 255. +** This parameter must also be less than or equal to OS_MAX_QUEUES +** +*/ +#define CFE_SB_MAX_PIPES 64 + + +/** +** \cfesbcfg Maximum Number of unique local destinations a single MsgId can have +** +** \par Description: +** Dictates the maximum number of unique local destinations a single MsgId can +** have. +** +** \par Limits +** This parameter has a lower limit of 1 and an upper limit of 64. +** +*/ +#define CFE_SB_MAX_DEST_PER_PKT 16 + + +/** +** \cfesbcfg Default Subscription Message Limit +** +** \par Description: +** Dictates the default Message Limit when using the #CFE_SB_Subscribe API. This will +** limit the number of messages with a specific message ID that can be received through +** a subscription. This only changes the default; other message limits can be set on a per +** subscription basis using #CFE_SB_SubscribeEx . +** +** \par Limits +** This parameter has a lower limit of 4 and an upper limit of 65535. +** +*/ +#define CFE_SB_DEFAULT_MSG_LIMIT 4 + + +/** +** \cfesbcfg Size of the SB buffer memory pool +** +** \par Description: +** Dictates the size of the SB memory pool. For each message the SB +** sends, the SB dynamically allocates from this memory pool, the memory needed +** to process the message. The memory needed to process each message is msg +** size + msg descriptor(#CFE_SB_BufferD_t). This memory pool is also used +** to allocate destination descriptors (#CFE_SB_DestinationD_t) during the +** subscription process. +** To see the run-time, high-water mark and the current utilization figures +** regarding this parameter, send an SB command to 'Send Statistics Pkt'. +** Some memory statistics have been added to the SB housekeeping packet. +** NOTE: It is important to monitor these statistics to ensure the desired +** memory margin is met. +** +** \par Limits +** This parameter has a lower limit of 512 and an upper limit 4.29G bytes. +** +*/ +#define CFE_SB_BUF_MEMORY_BYTES 524288 + + +/** +** \cfesbcfg Maximum depth allowed when creating an SB pipe +** +** \par Description: +** The value of this constant dictates the maximum pipe depth that an +** application may request. The pipe depth is given as a paramter in the +** #CFE_SB_CreatePipe API. +** +** \par Limits +** This parameter has a lower limit of 1 and an upper limit of 65535. +*/ +#define CFE_SB_MAX_PIPE_DEPTH 256 + + +/** +** \cfesbcfg Highest Valid Message Id +** +** \par Description: +** The value of this constant dictates the size of the SB message map. The SB +** messsage map is a lookup table that provides the routing table index for +** fast access into the routing table.The default setting of 0x1FFF was chosen +** to save memory for CCSDS implementations where the CCSDS Version number +** (3 MSB's of MsgId) would remain constant throughout the mission. This +** reduces the message map from 128Kbytes to 16Kbytes.See CFE_FSW_DCR 504 for +** more details. +** +** \par Limits +** This parameter has a lower limit of 1 and an upper limit of 0xFFFF. +*/ +#define CFE_SB_HIGHEST_VALID_MSGID 0x1FFF + + +/** +** \cfesbcfg Default Routing Information Filename +** +** \par Description: +** The value of this constant defines the filename used to store the software +** bus routing information. This filename is used only when no filename is +** specified in the command. +** +** \par Limits +** The length of each string, including the NULL terminator cannot exceed the +** #OS_MAX_PATH_LEN value. +*/ +#define CFE_SB_DEFAULT_ROUTING_FILENAME "/ram/cfe_sb_route.dat" + + +/** +** \cfesbcfg Default Pipe Information Filename +** +** \par Description: +** The value of this constant defines the filename used to store the software +** bus pipe information. This filename is used only when no filename is +** specified in the command. +** +** \par Limits +** The length of each string, including the NULL terminator cannot exceed the +** #OS_MAX_PATH_LEN value. +*/ +#define CFE_SB_DEFAULT_PIPE_FILENAME "/ram/cfe_sb_pipe.dat" + + +/** +** \cfesbcfg Default Message Map Filename +** +** \par Description: +** The value of this constant defines the filename used to store the software +** bus message map information. This filename is used only when no filename is +** specified in the command. The message map is a lookup table (array of 16bit +** words) that has an element for each possible MsgId value and holds the +** routing table index for that MsgId. The Msg Map provides fast access to the +** destinations of a message. +** +** \par Limits +** The length of each string, including the NULL terminator cannot exceed the +** #OS_MAX_PATH_LEN value. +*/ +#define CFE_SB_DEFAULT_MAP_FILENAME "/ram/cfe_sb_msgmap.dat" + + +/** +** \cfesbcfg SB Event Filtering +** +** \par Description: +** This group of configuration paramters dictates what SB events will be +** filtered through EVS. The filtering will begin after the SB task initializes +** and stay in effect until a cmd to EVS changes it. +** This allows the operator to set limits on the number of event messages that +** are sent during system initialization. +** NOTE: Set all unused event values and mask values to zero +** +** \par Limits +** This filtering applies only to SB events. +** These parameters have a lower limit of 0 and an upper limit of 65535. +*/ +#define CFE_SB_FILTERED_EVENT1 CFE_SB_SEND_NO_SUBS_EID +#define CFE_SB_FILTER_MASK1 CFE_EVS_FIRST_4_STOP + +#define CFE_SB_FILTERED_EVENT2 CFE_SB_DUP_SUBSCRIP_EID +#define CFE_SB_FILTER_MASK2 CFE_EVS_FIRST_4_STOP + +#define CFE_SB_FILTERED_EVENT3 CFE_SB_MSGID_LIM_ERR_EID +#define CFE_SB_FILTER_MASK3 CFE_EVS_FIRST_16_STOP + +#define CFE_SB_FILTERED_EVENT4 CFE_SB_Q_FULL_ERR_EID +#define CFE_SB_FILTER_MASK4 CFE_EVS_FIRST_16_STOP + +#define CFE_SB_FILTERED_EVENT5 0 +#define CFE_SB_FILTER_MASK5 CFE_EVS_NO_FILTER + +#define CFE_SB_FILTERED_EVENT6 0 +#define CFE_SB_FILTER_MASK6 CFE_EVS_NO_FILTER + +#define CFE_SB_FILTERED_EVENT7 0 +#define CFE_SB_FILTER_MASK7 CFE_EVS_NO_FILTER + +#define CFE_SB_FILTERED_EVENT8 0 +#define CFE_SB_FILTER_MASK8 CFE_EVS_NO_FILTER + + +/** +** \cfeescfg Define SB Memory Pool Block Sizes +** +** \par Description: +** Software Bus Memory Pool Block Sizes +** +** \par Limits +** These sizes MUST be increasing and MUST be an integral multiple of 4. +** The number of block sizes defined cannot exceed +** #CFE_ES_MAX_MEMPOOL_BLOCK_SIZES +*/ +#define CFE_SB_MEM_BLOCK_SIZE_01 8 +#define CFE_SB_MEM_BLOCK_SIZE_02 16 +#define CFE_SB_MEM_BLOCK_SIZE_03 20 +#define CFE_SB_MEM_BLOCK_SIZE_04 36 +#define CFE_SB_MEM_BLOCK_SIZE_05 64 +#define CFE_SB_MEM_BLOCK_SIZE_06 96 +#define CFE_SB_MEM_BLOCK_SIZE_07 128 +#define CFE_SB_MEM_BLOCK_SIZE_08 160 +#define CFE_SB_MEM_BLOCK_SIZE_09 256 +#define CFE_SB_MEM_BLOCK_SIZE_10 512 +#define CFE_SB_MEM_BLOCK_SIZE_11 1024 +#define CFE_SB_MEM_BLOCK_SIZE_12 2048 +#define CFE_SB_MEM_BLOCK_SIZE_13 4096 +#define CFE_SB_MEM_BLOCK_SIZE_14 8192 +#define CFE_SB_MEM_BLOCK_SIZE_15 16384 +#define CFE_SB_MEM_BLOCK_SIZE_16 32768 +#define CFE_SB_MAX_BLOCK_SIZE (CFE_SB_MAX_SB_MSG_SIZE + 40) + +/** +** \cfesbcfg Define Default Sender Information Storage Mode +** +** \par Description: +** Defines the default mode for the storing of sender information when sending +** a software bus message. If set to 1, the sender information will be stored. +** If set to 0, the sender information will not be stored. +** +** \par Limits +** There is a lower limit of 0 and an upper limit of 1 on this configuration +** paramater. +*/ +#define CFE_SB_DEFAULT_REPORT_SENDER 1 + + +/** +** \cfetimecfg Time Server or Time Client Selection +** +** \par Description: +** This configuration parameter selects whether the Time task functions as a +** time "server" or "client". A time server generates the "time at the tone" +** packet which is received by time clients. +** +** \par Limits +** Enable one, and only one by defining either CFE_TIME_CFG_SERVER or +** CFE_TIME_CFG_CLIENT AS TRUE. The other must be defined as FALSE. +*/ +#define CFE_TIME_CFG_SERVER TRUE +#define CFE_TIME_CFG_CLIENT FALSE + +/** +** \cfetimecfg Local MET or Virtual MET Selection for Time Servers +** +** \par Description: +** Depending on the specific hardware system configuration, it may be possible +** for Time Servers to read the "local" MET from a h/w register rather than +** having to track the MET as the count of tone signal interrupts (virtual MET) +** +** Time Clients must be defined as using a virtual MET. Also, a Time Server +** cannot be defined as having both a h/w MET and an external time source (they +** both cannot synchronize to the same tone). +** +** Note: "disable" this define (set to FALSE) only for Time Servers with local hardware +** that supports a h/w MET that is synchronized to the tone signal !!! +** +** \par Limits +** Only applies if #CFE_TIME_CFG_SERVER is set to TRUE. +*/ +#define CFE_TIME_CFG_VIRTUAL TRUE + + +/** +** \cfetimecfg Include or Exclude the Primary/Redundant Tone Selection Cmd +** +** \par Description: +** Depending on the specific hardware system configuration, it may be possible +** to switch between a primary and redundant tone signal. If supported by +** hardware, this definitions will enable command interfaces to select the +** active tone signal. Both Time Clients and Time Servers support this feature. +** Note: Set the CFE_TIME_CFG_SIGNAL define to TRUE to enable tone signal commands. +** +** \par Limits +** Not Applicable +*/ +#define CFE_TIME_CFG_SIGNAL FALSE + + +/** +** \cfetimecfg Include or Exclude the Internal/External Time Source Selection Cmd +** +** \par Description: +** By default, Time Servers maintain time using an internal MET which may be a +** h/w register or software counter, depending on available hardware. The +** following definition enables command interfaces to switch between an +** internal MET, or external time data received from one of several supported +** external time sources. Only a Time Server may be configured to use external +** time data. +** Note: Set the CFE_TIME_CFG_SOURCE define to TRUE to include the Time Source +** Selection Command (command allows selection between the internal +** or external time source). Then choose the external source with the +** CFE_TIME_CFG_SRC_??? define. +** +** \par Limits +** Only applies if #CFE_TIME_CFG_SERVER is set to TRUE. +*/ +#define CFE_TIME_CFG_SOURCE FALSE + + +/** +** \cfetimecfg Choose the External Time Source for Server only +** +** \par Description: +** If #CFE_TIME_CFG_SOURCE is set to TRUE, then one of the following external time +** source types must also be set to TRUE. Do not set any of the external time +** source types to TRUE unless #CFE_TIME_CFG_SOURCE is set to TRUE. +** +** \par Limits +** -# If #CFE_TIME_CFG_SOURCE is set to TRUE then one and only one of the following +** three external time sources can and must be set TRUE: +** #CFE_TIME_CFG_SRC_MET, #CFE_TIME_CFG_SRC_GPS, #CFE_TIME_CFG_SRC_TIME +** -# Only applies if #CFE_TIME_CFG_SERVER is set to TRUE. +*/ +#define CFE_TIME_CFG_SRC_MET FALSE +#define CFE_TIME_CFG_SRC_GPS FALSE +#define CFE_TIME_CFG_SRC_TIME FALSE + + +/** +** \cfetimecfg Define the Max Delta Limits for Time Servers using an Ext Time Source +** +** \par Description: +** If #CFE_TIME_CFG_SOURCE is set to TRUE and one of the external time sources is +** also set to TRUE, then the delta time limits for range checking is used. +** +** When a new time value is received from an external source, the value is +** compared against the "expected" time value. If the delta exceeds the +** following defined amount, then the new time data will be ignored. This range +** checking is only performed after the clock state has been commanded to +** "valid". Until then, external time data is accepted unconditionally. +** +** \par Limits +** Applies only if both #CFE_TIME_CFG_SERVER and #CFE_TIME_CFG_SOURCE are set +** to TRUE. +*/ +#define CFE_TIME_MAX_DELTA_SECS 0 +#define CFE_TIME_MAX_DELTA_SUBS 500000 + + +/** +** \cfetimecfg Define the Local Clock Rollover Value in seconds and subseconds +** +** \par Description: +** Specifies the capability of the local clock. Indicates the time at which +** the local clock rolls over. +** +** \par Limits +** Not Applicable +*/ +#define CFE_TIME_MAX_LOCAL_SECS 27 +#define CFE_TIME_MAX_LOCAL_SUBS 0 + + +/** +** \cfetimecfg Define Timing Limits From One Tone To The Next +** +** \par Description: +** Defines limits to the timing of the 1Hz tone signal. A tone signal is valid +** only if it arrives within one second (plus or minus the tone limit) from +** the previous tone signal.Units are microseconds as measured with the local +** clock. +** +** \par Limits +** Not Applicable +*/ +#define CFE_TIME_CFG_TONE_LIMIT 20000 + + + +/** +** \cfetimecfg Define Time to Start Flywheel Since Last Tone +** +** \par Description: +** Define time to enter flywheel mode (in seconds since last tone data update) +** Units are microseconds as measured with the local clock. +** +** \par Limits +** Not Applicable +*/ +#define CFE_TIME_CFG_START_FLY 2 + + +/** +** \cfetimecfg Define Periodic Time to Update Local Clock Tone Latch +** +** \par Description: +** Define Periodic Time to Update Local Clock Tone Latch. Applies only when +** in flywheel mode. This define dicates the period at which the simulated +** 'last tone' time is updated. Units are seconds. +** +** \par Limits +** Not Applicable +*/ +#define CFE_TIME_CFG_LATCH_FLY 8 + + +/** +** \cfetimecfg Define Maximum number of Time Synchronization Callbacks allowed +** +** \par Description: +** Define maximum number of Time Synchronization callback functions allowed. +** Each callback is called whenever cFE TIME receives a valid time synchronization +** signal (typically 1 Hz). +** +** \par Limits +** Not Applicable +*/ +#define CFE_TIME_MAX_NUM_SYNCH_FUNCS 4 + + +/** +** \cfetimecfg Enable (or disable) the 1HZ time command packet +** +** \par Description: +** Controls the generation of a packet that may be used as a 1HZ wakeup +** signal for applications that subscribe to CFE_TIME_1HZ_CMD_MID. +** Disable the packet to avoid 'no subscriber' errors that result from +** sending a packet when there are no subscribers to the packet. +** +** \par Limits +** Enable the 1HZ packet by setting #CFE_TIME_ENA_1HZ_CMD_PKT to TRUE. +** Disable the 1HZ packet by setting #CFE_TIME_ENA_1HZ_CMD_PKT to FALSE. +*/ +#define CFE_TIME_ENA_1HZ_CMD_PKT TRUE + + +/** +** \cfeescfg Define Max Number of Applications +** +** \par Description: +** Defines the maximum number of applications that can be loaded into the +** system. This number does not include child tasks. +** +** \par Limits +** There is a lower limit of 6 and an upper limit of 64 on this configuration +** paramater. The lower limit corresponds to the cFE internal applications. +*/ +#define CFE_ES_MAX_APPLICATIONS 32 + + +/** +** \cfeescfg Define Max Number of Shared libraries +** +** \par Description: +** Defines the maximum number of cFE Shared libraries that can be loaded into +** the system. +** +** \par Limits +** There is a lower limit of 1 and an upper limit of 64 on this configuration +** paramater. +*/ +#define CFE_ES_MAX_LIBRARIES 10 + +/** +** \cfeescfg Define Max Number of ER (Exception and Reset) log entries +** +** \par Description: +** Defines the maximum number of ER (Exception and Reset) log entries +** +** \par Limits +** There is a lower limit of 10 and an upper limit of 128 on this configuration +** paramater. +*/ +#define CFE_ES_ER_LOG_ENTRIES 20 + +/** \cfeescfg Maximum size of CPU Context in ES Error Log +** +** \par Description: +** This should be large enough to accommodate the CPU context +** information supplied by the PSP on the given platform. +** +** \par Limits: +** Must be greater than zero and a multiple of sizeof(uint32). +** Limited only by the available memory and the number of entries +** in the error log. Any context information beyond this size will +** be truncated. +*/ +#define CFE_ES_ER_LOG_MAX_CONTEXT_SIZE 128 + + +/** +** \cfeescfg Define Size of the cFE System Log. +** +** \par Description: +** Defines the size in bytes of the cFE system log. The system log holds +** variable length strings that are terminated by a linefeed and null +** character. +** +** \par Limits +** There is a lower limit of 512 and an upper limit of 16384 on this +** configuration paramater. +*/ +#define CFE_ES_SYSTEM_LOG_SIZE 3072 + + +/** +** \cfeescfg Define Number of entries in the ES Object table +** +** \par Description: +** Defines the number of entries in the ES Object table. This table controls +** the core cFE startup. +** +** \par Limits +** There is a lower limit of 15 and an upper limit of 50 on this configuration +** paramater. +*/ +#define CFE_ES_OBJECT_TABLE_SIZE 30 + + +/** +** \cfeescfg Define Max Number of Generic Counters +** +** \par Description: +** Defines the maximum number of Generic Counters that can be registered. +** +** \par Limits +** This parameter has a lower limit of 1 and an upper limit of 65535. +*/ +#define CFE_ES_MAX_GEN_COUNTERS 8 + + +/** +** \cfeescfg Define ES Application Control Scan Rate +** +** \par Description: +** ES Application Control Scan Rate. This parameter controls the speed that ES +** scans the Application Table looking for App Delete/Restart/Reload requests. +** All Applications are deleted, restarted, or reloaded by the ES Application. +** ES will periodically scan for control requests to process. The scan rate is +** controlled by this parameter, which is given in milliseconds. A value of +** 1000 means that ES will scan the Application Table once per second. Be +** careful not to set the value of this too low, because ES will use more CPU +** cycles scanning the table. +** +** \par Limits +** There is a lower limit of 100 and an upper limit of 20000 on this +** configuration paramater. millisecond units. +*/ +#define CFE_ES_APP_SCAN_RATE 1000 + + +/** +** \cfeescfg Define ES Application Kill Timeout +** +** \par Description: +** ES Application Kill Timeout. This parameter controls the number of +** "scan periods" that ES will wait for an application to Exit after getting +** the signal Delete, Reload or Restart. The sequence works as follows: +** -# ES will set the control request for an App to Delete/Restart/Reload and +** set this kill timer to the value in this parameter. +** -# If the App is reponding and Calls it's RunLoop function, it will drop out +** of it's main loop and call CFE_ES_ExitApp. Once it calls Exit App, then +** ES can delete, restart, or reload the app the next time it scans the app +** table. +** -# If the App is not responding, the ES App will decrement this Kill Timeout +** value each time it runs. If the timeout value reaches zero, ES will kill +** the app. +** +** The Kill timeout value depends on the #CFE_ES_APP_SCAN_RATE. If the Scan Rate +** is 1000, or 1 second, and this #CFE_ES_APP_KILL_TIMEOUT is set to 5, then it +** will take 5 seconds to kill a non-responding App. +** If the Scan Rate is 250, or 1/4 second, and the #CFE_ES_APP_KILL_TIMEOUT is +** set to 2, then it will take 1/2 second to time out. +** +** \par Limits +** There is a lower limit of 1 and an upper limit of 100 on this configuration +** paramater. Units are number of #CFE_ES_APP_SCAN_RATE cycles. +*/ +#define CFE_ES_APP_KILL_TIMEOUT 5 + + +/** +** \cfeescfg ES Ram Disk Sector Size +** +** \par Description: +** Defines the ram disk sector size. The ram disk is 1 of 4 memory areas that +** are preserved on a processor reset. +** NOTE: Changing this value changes memory allocation, and may +** require changes to platform specific values (in CFE_PSP) such as +** USER_RESERVED_MEM in VxWorks depending on the memory areas +** being used for preserved data and on OS specific behavior. +** +** \par Limits +** There is a lower limit of 128 and an upper limit of 4096 on this +** configuration paramater. +*/ +#define CFE_ES_RAM_DISK_SECTOR_SIZE 512 + + +/** +** \cfeescfg ES Ram Disk Number of Sectors +** +** \par Description: +** Defines the ram disk number of sectors. The ram disk is one of four memory +** areas that are preserved on a processor reset. +** NOTE: Changing this value changes memory allocation, and may +** require changes to platform specific values (in CFE_PSP) such as +** USER_RESERVED_MEM in VxWorks depending on the memory areas +** being used for preserved data and on OS specific behavior. +** +** \par Limits +** There is a lower limit of 128 and an upper limit of 8192 on this +** configuration paramater. +*/ +#define CFE_ES_RAM_DISK_NUM_SECTORS 4096 + +/** +** \cfeescfg Percentage of Ram Disk Reserved for Decompressing Apps +** +** \par Description: +** The #CFE_ES_RAM_DISK_PERCENT_RESERVED parameter is used to make sure that the +** Volatile ( RAM ) Disk has a defined amount of free space during a processor +** reset. The cFE uses the Volatile disk to decompress cFE applications during +** system startup. If this Volatile disk happens to get filled with logs and +** misc files, then a processor reset may not work, because there will be no +** room to decompress cFE apps. To solve that problem, this parameter sets the +** "Low Water Mark" for disk space on a Processor reset. It should be set to +** allow the largest cFE Application to be decompressed. +** During a Processor reset, if there is not sufficient space left on the disk, +** it will be re-formatted in order to clear up some space. +** +** This feature can be turned OFF by setting the parameter to 0. +** +** \par Limits +** There is a lower limit of 0 and an upper limit of 75 on this configuration +** paramater.Units are percentage. A setting of zero will turn this feature +** off. +*/ +#define CFE_ES_RAM_DISK_PERCENT_RESERVED 30 + + +/** +** \cfeescfg RAM Disk Mount string +** +** \par Description: +** The #CFE_ES_RAM_DISK_MOUNT_STRING parameter is used to set the cFE mount path +** for the CFE RAM disk. This is a parameter for missions that do not want to +** use the default value of "/ram", or for missions that need to have a different +** value for different CPUs or Spacecraft. +** Note that the vxWorks OSAL cannot currently handle names that have more than one +** path separator in it. The names "/ram", "/ramdisk", "/disk123" will all work, but +** "/disks/ram" will not. +** Multiple separators can be used with the posix or RTEMS ports. +** +*/ +#define CFE_ES_RAM_DISK_MOUNT_STRING "/ram" + + +/** +** \cfeescfg Define Critical Data Store Size +** +** \par Description: +** Defines the Critical Data Store (CDS) area size in bytes size. The CDS is +** one of four memory areas that are preserved during a processor reset. +** NOTE: Changing this value changes memory allocation, and may +** require changes to platform specific values (in CFE_PSP) such as +** USER_RESERVED_MEM in VxWorks depending on the memory areas +** being used for preserved data and on OS specific behavior. +** +** \par Limits +** There is a lower limit of 8192 and an upper limit of 2097152 (2MBytes) on +** this configuration paramater. +*/ +#define CFE_ES_CDS_SIZE ( 128 * 1024 ) + + +/** +** \cfeescfg Define User Reserved Memory Size +** +** \par Description: +** User Reserved Memory Size. This is the size in bytes of the cFE User +** reserved Memory area. This is a block of memory that is available for cFE +** application use. The address is obtained by calling +** #CFE_PSP_GetUserReservedArea. The User Reserved Memory is one of four memory +** areas that are preserved during a processor reset. +** NOTE: Changing this value changes memory allocation, and may +** require changes to platform specific values (in CFE_PSP) such as +** USER_RESERVED_MEM in VxWorks depending on the memory areas +** being used for preserved data and on OS specific behavior. +** +** \par Limits +** There is a lower limit of 1024 and an upper limit of 33554432 (32Mbytes) on +** this configuration paramater. +*/ +#define CFE_ES_USER_RESERVED_SIZE ( 1024 * 1024 ) + + +/** +** \cfeescfg Define ES Reset Area Size +** +** \par Description: +** The ES Reset Area Size. This is the size in bytes of the cFE Reset variable +** and log area. This is a block of memory used by the cFE to store the system +** log ER Log and critical reset variables. This is 4 of 4 of the memory areas +** that are preserved during a processor reset. +** Note: This area must be sized large enough to hold all of the data +** structures. It should be automatically sized based on the #CFE_ES_ResetData_t +** type, but circular dependancies in the headers prevent it from being defined +** this way. +** NOTE: Changing this value changes memory allocation, and may +** require changes to platform specific values (in CFE_PSP) such as +** USER_RESERVED_MEM in VxWorks depending on the memory areas +** being used for preserved data and on OS specific behavior. +** +** \par Limits +** There is a lower limit of 153600 (150KBytes) and an upper limit of 2097152 +** (2MBytes) on this configuration paramater. +*/ +#define CFE_ES_RESET_AREA_SIZE ( 170 * 1024 ) + +/** +** \cfeescfg Define Default Memory Pool Alignment Mode +** +** \par Description: +** Defines the default mode for the requirement to align ES Mempool buffer. +** If this define is set, the memory pool must be aligned or the call to +** create a new memory pool will be rejected with a CFE_ES_BAD_ARGUMENT +** return code. +** +** \par Limits +** If CFE_ES_MEMPOOL_ALIGNED is defined, the alignment check is enabled. +** If CFE_ES_MEMPOOL_ALIGNED is not defined, the alignment check is not +** compiled in. +*/ +#define CFE_ES_MEMPOOL_ALIGNED 1 + +/** +** \cfeescfg ES Nonvolatile Startup Filename +** +** \par Description: +** The value of this constant defines the path and name of the file that +** contains a list of modules that will be loaded and started by the cFE after +** the cFE finishes its startup sequence. +** +** \par Limits +** The length of each string, including the NULL terminator cannot exceed the +** #OS_MAX_PATH_LEN value. +*/ +#define CFE_ES_NONVOL_STARTUP_FILE "/cf/apps/cfe_es_startup.scr" + + +/** +** \cfeescfg ES Volatile Startup Filename +** +** \par Description: +** The value of this constant defines the path and name of the file that +** contains a list of modules that will be loaded and started by the cFE after +** the cFE finishes its startup sequence. +** +** \par Limits +** The length of each string, including the NULL terminator cannot exceed the +** #OS_MAX_PATH_LEN value. +*/ +#define CFE_ES_VOLATILE_STARTUP_FILE "/ram/apps/cfe_es_startup.scr" + +/** +** \cfeescfg Default Shell Filename +** +** \par Description: +** The value of this constant defines the filename used to store the shell +** output after a shell command is received by ES. This file contains the +** entire shell output. The fsw also sends the shell output in series of fixed +** size telemetry packets. This filename is used only when no filename +** is specified in the shell command. +** +** \par Limits +** The length of each string, including the NULL terminator cannot exceed the +** #OS_MAX_PATH_LEN value. +*/ +#define CFE_ES_DEFAULT_SHELL_FILENAME "/ram/ShellCmd.out" + + +/** +** \cfeescfg Define Max Shell Command Size +** +** \par Description: +** Defines the maximum size in characters of the shell command. +** +** \par Limits +** There is a lower limit of 64 and an upper limit of 128 on this configuration +** paramater. Units are characters. +*/ +#define CFE_ES_MAX_SHELL_CMD 64 + + +/** +** \cfeescfg Define Shell Command Telemetry Pkt Segment Size +** +** \par Description: +** Defines the size of the shell command tlm packet segments.The shell command +** output size is dependant on the shell command itself. If the shell output +** size is greater than the size of the packet defined here, the fsw will +** generate a series of tlm packets (of the size defined here) that can be +** reconstructed by the ground system. +** +** \par Limits +** There is a lower limit of 32 and an upper limit of 128 on this configuration +** paramater. +*/ +#define CFE_ES_MAX_SHELL_PKT 64 + + +/** +** \cfeescfg Default Application Information Filename +** +** \par Description: +** The value of this constant defines the filename used to store information +** pertaining to all of the Applications that are registered with Executive +** Services. This filename is used only when no filename is specified in the +** the command to query all system apps. +** +** \par Limits +** The length of each string, including the NULL terminator cannot exceed the +** #OS_MAX_PATH_LEN value. +*/ +#define CFE_ES_DEFAULT_APP_LOG_FILE "/ram/cfe_es_app_info.log" + +/** +** \cfeescfg Default Application Information Filename +** +** \par Description: +** The value of this constant defines the filename used to store information +** pertaining to all of the Applications that are registered with Executive +** Services. This filename is used only when no filename is specified in the +** the command to query all system tasks. +** +** \par Limits +** The length of each string, including the NULL terminator cannot exceed the +** #OS_MAX_PATH_LEN value. +*/ +#define CFE_ES_DEFAULT_TASK_LOG_FILE "/ram/cfe_es_task_info.log" + +/** +** \cfeescfg Default System Log Filename +** +** \par Description: +** The value of this constant defines the filename used to store important +** information (as ASCII text strings) that might not be able to be sent in an +** Event Message. This filename is used only when no filename is specified in +** the command to dump the system log. No file specified in the cmd means the +** first character in the cmd filename is a NULL terminator (zero). +** +** \par Limits +** The length of each string, including the NULL terminator cannot exceed the +** #OS_MAX_PATH_LEN value. +*/ +#define CFE_ES_DEFAULT_SYSLOG_FILE "/ram/cfe_es_syslog.log" + +/** +** \cfeescfg Default Exception and Reset (ER) Log Filename +** +** \par Description: +** The value of this constant defines the filename used to store the +** Exception and Reset (ER) Log. This filename is used only when no filename is +** specified in the command to dump the ER log. No file specified in the cmd +** means the first character in the cmd filename is a NULL terminator (zero). +** +** \par Limits +** The length of each string, including the NULL terminator cannot exceed the +** #OS_MAX_PATH_LEN value. +*/ +#define CFE_ES_DEFAULT_ER_LOG_FILE "/ram/cfe_erlog.log" + +/** +** \cfeescfg Default Performance Data Filename +** +** \par Description: +** The value of this constant defines the filename used to store the +** Performance Data. This filename is used only when no filename is specified +** in the command to stop performance data collecting. +** +** \par Limits +** The length of each string, including the NULL terminator cannot exceed the +** #OS_MAX_PATH_LEN value. +*/ +#define CFE_ES_DEFAULT_PERF_DUMP_FILENAME "/ram/cfe_es_perf.dat" + + +/** +** \cfeescfg Default Critical Data Store Registry Filename +** +** \par Description: +** The value of this constant defines the filename used to store the +** Critical Data Store Registry. This filename is used only when no filename is +** specified in the command to stop performance data collecting. +** +** \par Limits +** The length of each string, including the NULL terminator cannot exceed the +** #OS_MAX_PATH_LEN value. +*/ +#define CFE_ES_DEFAULT_CDS_REG_DUMP_FILE "/ram/cfe_cds_reg.log" + +/** +** \cfeescfg Define Default System Log Mode +** +** \par Description: +** Defines the default mode for the operation of the ES System log. The log may +** operate in either Overwrite mode = 0, where once the log becomes full the +** oldest message in the log will be overwritten, or Discard mode = 1, where +** once the log becomes full the contents of the log are preserved and the new +** event is discarded. This constant may hold a value of either 0 or 1 +** depending on the desired default log mode. Overwrite Mode = 0, Discard +** Mode = 1. +** +** \par Limits +** There is a lower limit of 0 and an upper limit of 1 on this configuration +** paramater. +*/ +#define CFE_ES_DEFAULT_SYSLOG_MODE 1 + +/** +** \cfeescfg Define Max Number of Performance IDs +** +** \par Description: +** Defines the maximum number of perf ids allowed. +** +** +** \par Limits +** This number must always be divisible by 32. There is a lower limit of 32 and +** an upper limit of 512 on this configuration paramater. +*/ +#define CFE_ES_PERF_MAX_IDS 128 + +/** +** \cfeescfg Define Max Size of Performance Data Buffer +** +** \par Description: +** Defines the maximum size of the performance data buffer. Units are number of +** performance data entries. An entry is defined by a 32 bit data word followed +** by a 64 bit time stamp. +** +** \par Limits +** There is a lower limit of 1025 and an upper limit of 1048576 (1 Meg) on this +** configuration paramater. The units are number of entries. An entry is +** defined by a 32 bit data word followed by a 64 bit time stamp. +*/ +#define CFE_ES_PERF_DATA_BUFFER_SIZE 10000 + + +/** +** \cfeescfg Define Filter Mask Setting for Disabling All Performance Entries +** +** \par Description: +** Defines the filter mask for disabling all performance entries. The value is a +** bit mask. For each bit, 0 means the corresponding entry is disabled and +** 1 means it is enabled. +*/ +#define CFE_ES_PERF_FILTMASK_NONE 0 + +/** +** \cfeescfg Define Filter Mask Setting for Enabling All Performance Entries +** +** \par Description: +** Defines the filter mask for enabling all performance entries. The value is a +** bit mask. For each bit, 0 means the corresponding entry is disabled and +** 1 means it is enabled. +*/ +#define CFE_ES_PERF_FILTMASK_ALL ~CFE_ES_PERF_FILTMASK_NONE + +/** +** \cfeescfg Define Default Filter Mask Setting for Performance Data Buffer +** +** \par Description: +** Defines the default filter mask for the performance data buffer. The value is a +** bit mask. For each bit, 0 means the corresponding entry is disabled and 1 +** means it is enabled. +** +*/ +#define CFE_ES_PERF_FILTMASK_INIT CFE_ES_PERF_FILTMASK_ALL + + +/** +** \cfeescfg Define Default Filter Trigger Setting for Disabling All Performance Entries +** +** \par Description: +** Defines the default trigger mask for disabling all performance data entries. The value +** is a bit mask. For each bit, 0 means the trigger for the corresponding entry is +** disabled and 1 means it is enabled. +** +*/ +#define CFE_ES_PERF_TRIGMASK_NONE 0 + +/** +** \cfeescfg Define Filter Trigger Setting for Enabling All Performance Entries +** +** \par Description: +** Defines the trigger mask for enabling all performance data entries. The value is +** a bit mask. For each bit, 0 means the trigger for the corresponding entry is +** disabled and 1 means it is enabled. +** +*/ +#define CFE_ES_PERF_TRIGMASK_ALL ~CFE_ES_PERF_TRIGMASK_NONE + +/** +** \cfeescfg Define Default Filter Trigger Setting for Performance Data Buffer +** +** \par Description: +** Defines the default trigger mask for the performance data buffer. The value is a +** 32-bit mask. For each bit, 0 means the trigger for the corresponding entry is +** disabled and 1 means it is enabled. +** +*/ +#define CFE_ES_PERF_TRIGMASK_INIT CFE_ES_PERF_TRIGMASK_NONE + +/** +** \cfeescfg Define Performance Analyzer Child Task Priority +** +** \par Description: +** This parameter defines the priority of the child task spawed by the +** Executive Services to write performance data to a file. Lower numbers +** are higher priority, with 1 being the highest priority in the case of a +** child task. +** +** \par Limits +** Valid range for a child task is 1 to 255 however, the priority cannot +** be higher (lower number) than the ES parent application priority. +*/ +#define CFE_ES_PERF_CHILD_PRIORITY 200 + +/** +** \cfeescfg Define Performance Analyzer Child Task Stack Size +** +** \par Description: +** This parameter defines the stack size of the child task spawed by the +** Executive Services to write performance data to a file. +** +** \par Limits +** It is recommended this parameter be greater than or equal to 4KB. This parameter +** is limited by the maximum value allowed by the data type. In this case, the data +** type is an unsigned 32-bit integer, so the valid range is 0 to 0xFFFFFFFF. +*/ +#define CFE_ES_PERF_CHILD_STACK_SIZE 4096 + +/** +** \cfeescfg Define Performance Analyzer Child Task Delay +** +** \par Description: +** This parameter defines the delay time (in milliseconds) between performance +** data file writes performed by the Executive Services Performace Analyzer +** Child Task. +** +** \par Limits +** It is recommended this parameter be greater than or equal to 20ms. This parameter +** is limited by the maximum value allowed by the data type. In this case, the data +** type is an unsigned 32-bit integer, so the valid range is 0 to 0xFFFFFFFF. +*/ +#define CFE_ES_PERF_CHILD_MS_DELAY 20 + +/** +** \cfeescfg Define Performance Analyzer Child Task Number of Entries Between Delay +** +** \par Description: +** This parameter defines the number of performace analyzer entries the Performace +** Analyzer Child Task will write to the file between delays. +** +*/ +#define CFE_ES_PERF_ENTRIES_BTWN_DLYS 50 + +/** +** \cfeescfg Define Default Stack Size for an Application +** +** \par Description: +** This parameter defines a default stack size. This parameter is used by the +** cFE Core Applications. +** +** \par Limits +** There is a lower limit of 2048 and an upper limit of 16384 on this +** configuration paramater. +*/ +#define CFE_ES_DEFAULT_STACK_SIZE 8192 + +/** +** \cfeescfg Define cFE Core Exception Function +** +** \par Description: +** This parameter defines the function-to-call when an exception occurs in +** the cFE core. +** +** \par Limits +** Must be a valid function name. +*/ +#define CFE_ES_EXCEPTION_FUNCTION CFE_ES_ProcessCoreException + +/** +** \cfeescfg Define EVS Task Priority +** +** \par Description: +** Defines the cFE_EVS Task priority. +** +** \par Limits +** Not Applicable +*/ +#define CFE_EVS_START_TASK_PRIORITY 61 + +/** +** \cfeescfg Define EVS Task Stack Size +** +** \par Description: +** Defines the cFE_EVS Task Stack Size +** +** \par Limits +** There is a lower limit of 2048 and an upper limit of 16384 on this +** configuration paramater. +*/ +#define CFE_EVS_START_TASK_STACK_SIZE CFE_ES_DEFAULT_STACK_SIZE + +/** +** \cfeescfg Define SB Task Priority +** +** \par Description: +** Defines the cFE_SB Task priority. +** +** \par Limits +** Not Applicable +*/ +#define CFE_SB_START_TASK_PRIORITY 64 + +/** +** \cfeescfg Define SB Task Stack Size +** +** \par Description: +** Defines the cFE_SB Task Stack Size +** +** \par Limits +** There is a lower limit of 2048 and an upper limit of 16384 on this +** configuration paramater. +*/ +#define CFE_SB_START_TASK_STACK_SIZE CFE_ES_DEFAULT_STACK_SIZE + +/** +** \cfeescfg Define ES Task Priority +** +** \par Description: +** Defines the cFE_ES Task priority. +** +** \par Limits +** Not Applicable +*/ +#define CFE_ES_START_TASK_PRIORITY 68 + +/** +** \cfeescfg Define ES Task Stack Size +** +** \par Description: +** Defines the cFE_ES Task Stack Size +** +** \par Limits +** There is a lower limit of 2048 and an upper limit of 16384 on this +** configuration paramater. +*/ +#define CFE_ES_START_TASK_STACK_SIZE 16384 + +/** +** \cfetimecfg Define TIME Task Priorities +** +** \par Description: +** Defines the cFE_TIME Task priority. +** Defines the cFE_TIME Tone Task priority. +** Defines the cFE_TIME 1HZ Task priority. +** +** \par Limits +** There is a lower limit of zero and an upper limit of 255 on these +** configuration paramaters. Remember that the meaning of each task +** priority is inverted -- a "lower" number has a "higher" priority. +*/ +#define CFE_TIME_START_TASK_PRIORITY 60 +#define CFE_TIME_TONE_TASK_PRIORITY 25 +#define CFE_TIME_1HZ_TASK_PRIORITY 25 + +/** +** \cfetimecfg Define TIME Task Stack Sizes +** +** \par Description: +** Defines the cFE_TIME Main Task Stack Size +** Defines the cFE_TIME Tone Task Stack Size +** Defines the cFE_TIME 1HZ Task Stack Size +** +** \par Limits +** There is a lower limit of 2048 and an upper limit of 16384 on these +** configuration paramaters. +*/ +#define CFE_TIME_START_TASK_STACK_SIZE CFE_ES_DEFAULT_STACK_SIZE +#define CFE_TIME_TONE_TASK_STACK_SIZE 4096 +#define CFE_TIME_1HZ_TASK_STACK_SIZE 8192 + +/** +** \cfeescfg Define TBL Task Priority +** +** \par Description: +** Defines the cFE_TBL Task priority. +** +** \par Limits +** Not Applicable +*/ +#define CFE_TBL_START_TASK_PRIORITY 70 + +/** +** \cfeescfg Define TBL Task Stack Size +** +** \par Description: +** Defines the cFE_TBL Task Stack Size +** +** \par Limits +** There is a lower limit of 2048 and an upper limit of 16384 on this +** configuration paramater. +*/ +#define CFE_TBL_START_TASK_STACK_SIZE CFE_ES_DEFAULT_STACK_SIZE + +/** +** \cfeescfg Define Maximum Number of Registered CDS Blocks +** +** \par Description: +** Maximum number of registered CDS Blocks +** +** \par Limits +** There is a lower limit of 8 and an upper limit of 32767 on this configuration +** paramater. +*/ +#define CFE_ES_CDS_MAX_NUM_ENTRIES 512 + + +/** +** \cfeescfg Define Number of Processor Resets Before a Power On Reset +** +** \par Description: +** Number of Processor Resets before a Power On Reset is called. If set to 2, +** then 2 processor resets will occur, and the 3rd processor reset will be a +** power on reset instead. +** +** \par Limits +** There is a lower limit of 0 and an upper limit of 1024 on this configuration +** paramater. +*/ +#define CFE_ES_MAX_PROCESSOR_RESETS 2 + + +/** +** \cfeescfg Define Default ES Memory Pool Block Sizes +** +** \par Description: +** Default Intermediate ES Memory Pool Block Sizes. If an application +** is using the CFE_ES Memory Pool APIs (#CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, +** #CFE_ES_GetPoolBuf and #CFE_ES_PutPoolBuf) but finds these sizes +** inappropriate for their use, they may wish to use the #CFE_ES_PoolCreateEx +** API to specify their own intermediate block sizes +** +** \par Limits +** These sizes MUST be increasing and MUST be an integral multiple of 4. Also, +** CFE_ES_MAX_BLOCK_SIZE must be larger than CFE_SB_MAX_SB_MSG_SIZE and both +** CFE_TBL_MAX_SNGL_TABLE_SIZE and CFE_TBL_MAX_DBL_TABLE_SIZE. Note that if Table +** Services have been removed from the CFE, the table size limits are still +** enforced although the table size definitions may be reduced. Refer to the CFS +** Deployment Guide for information about removing CFE Table Services from the CFE. +*/ +#define CFE_ES_MEM_BLOCK_SIZE_01 8 +#define CFE_ES_MEM_BLOCK_SIZE_02 16 +#define CFE_ES_MEM_BLOCK_SIZE_03 32 +#define CFE_ES_MEM_BLOCK_SIZE_04 48 +#define CFE_ES_MEM_BLOCK_SIZE_05 64 +#define CFE_ES_MEM_BLOCK_SIZE_06 96 +#define CFE_ES_MEM_BLOCK_SIZE_07 128 +#define CFE_ES_MEM_BLOCK_SIZE_08 160 +#define CFE_ES_MEM_BLOCK_SIZE_09 256 +#define CFE_ES_MEM_BLOCK_SIZE_10 512 +#define CFE_ES_MEM_BLOCK_SIZE_11 1024 +#define CFE_ES_MEM_BLOCK_SIZE_12 2048 +#define CFE_ES_MEM_BLOCK_SIZE_13 4096 +#define CFE_ES_MEM_BLOCK_SIZE_14 8192 +#define CFE_ES_MEM_BLOCK_SIZE_15 16384 +#define CFE_ES_MEM_BLOCK_SIZE_16 32768 +#define CFE_ES_MAX_BLOCK_SIZE 80000 + + +/** +** \cfeescfg Define ES Critical Data Store Memory Pool Block Sizes +** +** \par Description: +** Intermediate ES Critical Data Store Memory Pool Block Sizes +** +** \par Limits +** These sizes MUST be increasing and MUST be an integral multiple of 4. +*/ +#define CFE_ES_CDS_MEM_BLOCK_SIZE_01 8 +#define CFE_ES_CDS_MEM_BLOCK_SIZE_02 16 +#define CFE_ES_CDS_MEM_BLOCK_SIZE_03 32 +#define CFE_ES_CDS_MEM_BLOCK_SIZE_04 48 +#define CFE_ES_CDS_MEM_BLOCK_SIZE_05 64 +#define CFE_ES_CDS_MEM_BLOCK_SIZE_06 96 +#define CFE_ES_CDS_MEM_BLOCK_SIZE_07 128 +#define CFE_ES_CDS_MEM_BLOCK_SIZE_08 160 +#define CFE_ES_CDS_MEM_BLOCK_SIZE_09 256 +#define CFE_ES_CDS_MEM_BLOCK_SIZE_10 512 +#define CFE_ES_CDS_MEM_BLOCK_SIZE_11 1024 +#define CFE_ES_CDS_MEM_BLOCK_SIZE_12 2048 +#define CFE_ES_CDS_MEM_BLOCK_SIZE_13 4096 +#define CFE_ES_CDS_MEM_BLOCK_SIZE_14 8192 +#define CFE_ES_CDS_MEM_BLOCK_SIZE_15 16384 +#define CFE_ES_CDS_MEM_BLOCK_SIZE_16 32768 +#define CFE_ES_CDS_MAX_BLOCK_SIZE 80000 + + + +/** +** \cfeevscfg Define Maximum Number of Event Filters per Application +** +** \par Description: +** Maximum number of events that may be filtered per application. +** +** \par Limits +** There is an upper limit of 32767 on this configuration paramater. +*/ +#define CFE_EVS_MAX_EVENT_FILTERS 8 + + +/** +** \cfeevscfg Enable or Disable EVS Local Event Log +** +** \par Description: +** The CFE_EVS_LOG_ON configuration parameter must be defined to enable EVS +** event logging. In order to disable the local event log this definition needs +** to be commented out. +** +** \par Limits +** Not Applicable +*/ +#define CFE_EVS_LOG_ON + + +/** +** \cfeevscfg Default Event Log Filename +** +** \par Description: +** The value of this constant defines the filename used to store the Event +** Services local event log. This filename is used only when no filename is +** specified in the command to dump the event log. +** +** \par Limits +** The length of each string, including the NULL terminator cannot exceed the +** #OS_MAX_PATH_LEN value. +*/ +#define CFE_EVS_DEFAULT_LOG_FILE "/ram/cfe_evs.log" + + +/** +** \cfeevscfg Maximum Number of Events in EVS Local Event Log +** +** \par Description: +** Dictates the EVS local event log capacity. Units are the number of events. +** +** \par Limits +** There is an upper limit of 65535 on this configuration paramater. +*/ +#define CFE_EVS_LOG_MAX 20 + + +/** +** \cfeevscfg Default EVS Application Data Filename +** +** \par Description: +** The value of this constant defines the filename used to store the EVS +** Application Data(event counts/filtering information). This filename is +** used only when no filename is specified in the command to dump the event +** log. +** +** \par Limits +** The length of each string, including the NULL terminator cannot exceed the +** #OS_MAX_PATH_LEN value. +*/ +#define CFE_EVS_DEFAULT_APP_DATA_FILE "/ram/cfe_evs_app.dat" + + +/** +** \cfeevscfg Default EVS Output Port State +** +** \par Description: +** Defines the default port state (enabled or deisabled) for the four output +** ports defined within the Event Service. Port 1 is usually the uart output +** terminal. To enable a port, set the proper bit to a 1. Bit 0 is port 1, +** bit 1 is port2 etc. +** +** \par Limits +** The valid settings are 0x0 to 0xF. +*/ +#define CFE_EVS_PORT_DEFAULT 0x0001 + + +/** +** \cfeevscfg Default EVS Event Type Filter Mask +** +** \par Description: +** Defines a state of on or off for all four event types. The term event +** 'type' refers to the criticality level and may be Debug, Informational, +** Error or Critical. Each event type has a bit position. (bit 0 = Debug, +** bit 1 = Info, bit 2 = Error, bit 3 = Critical). This is a global setting, +** meaning it applies to all applications. To filter an event type, set its +** bit to zero. For example, +** 0xE means Debug = OFF, Info = ON, Error = ON, Critical = ON +** +** \par Limits +** The valid settings are 0x0 to 0xF. +*/ +#define CFE_EVS_DEFAULT_TYPE_FLAG 0xE + + + +/** +** \cfeevscfg Default EVS Local Event Log Mode +** +** \par Description: +** Defines a state of overwrite(0) or discard(1) for the operation of the +** EVS local event log. The log may operate in either Overwrite mode = 0, +** where once the log becomes full the oldest event in the log will be +** overwritten, or Discard mode = 1, where once the log becomes full the +** contents of the log are preserved and the new event is discarded. +** Overwrite Mode = 0, Discard Mode = 1. +** +** \par Limits +** The valid settings are 0 or 1 +*/ +#define CFE_EVS_DEFAULT_LOG_MODE 1 + + +/** +** \cfeevscfg Default EVS Message Format Mode +** +** \par Description: +** Defines the default message format (long or short) for event messages being +** sent to the ground. Choose between #CFE_EVS_LONG_FORMAT or +** #CFE_EVS_SHORT_FORMAT. +** +** \par Limits +** The valid settings are #CFE_EVS_LONG_FORMAT or #CFE_EVS_SHORT_FORMAT +*/ +#define CFE_EVS_DEFAULT_MSG_FORMAT_MODE CFE_EVS_LONG_FORMAT + + + +/* Platform Configuration Parameters for Table Service (TBL) */ + +/** +** \cfetblcfg Size of Table Services Table Memory Pool +** +** \par Description: +** Defines the TOTAL size of the memory pool that cFE Table Services allocates +** from the system. The size must be large enough to provide memory for each +** registered table, the inactive buffers for double buffered tables and for +** the shared inactive buffers for single buffered tables. +** +** \par Limits +** The cFE does not place a limit on the size of this parameter. +*/ +#define CFE_TBL_BUF_MEMORY_BYTES 524288 + +/** +** \cfetblcfg Maximum Size Allowed for a Double Buffered Table +** +** \par Description: +** Defines the maximum allowed size (in bytes) of a double buffered table. +** +** \par Limits +** The cFE does not place a limit on the size of this parameter but it must be +** less than half of #CFE_TBL_BUF_MEMORY_BYTES. +*/ +#define CFE_TBL_MAX_DBL_TABLE_SIZE 16384 + +/** +** \cfetblcfg Maximum Size Allowed for a Single Buffered Table +** +** \par Description: +** Defines the maximum allowed size (in bytes) of a single buffered table. +** \b NOTE: This size determines the size of all shared table buffers. +** Therefore, this size will be multiplied by #CFE_TBL_MAX_SIMULTANEOUS_LOADS +** below when allocating memory for shared tables. +** +** \par Limits +** The cFE does not place a limit on the size of this parameter but it must be +** small enough to allow for #CFE_TBL_MAX_SIMULTANEOUS_LOADS number of tables +** to fit into #CFE_TBL_BUF_MEMORY_BYTES. +*/ +#define CFE_TBL_MAX_SNGL_TABLE_SIZE 16384 + +/** +** \cfetblcfg Maximum Number of Tables Allowed to be Registered +** +** \par Description: +** Defines the maximum number of tables supported by this processor's Table Services. +** +** \par Limits +** This number must be less than 32767. It should be recognized that this parameter +** determines the size of the Table Registry. An excessively high number will waste +** memory. +*/ +#define CFE_TBL_MAX_NUM_TABLES 128 + +/** +** \cfetblcfg Maximum Number of Critical Tables that can be Registered +** +** \par Description: +** Defines the maximum number of critical tables supported by this processor's Table Services. +** +** \par Limits +** This number must be less than 32767. It should be recognized that this parameter +** determines the size of the Critical Table Registry which is maintained in the Critical +** Data Store. An excessively high number will waste Critical Data Store memory. Therefore, +** this number must not exceed the value defined in CFE_ES_CDS_MAX_CRITICAL_TABLES. +*/ +#define CFE_TBL_MAX_CRITICAL_TABLES 32 + +/** +** \cfetblcfg Maximum Number of Table Handles +** +** \par Description: +** Defines the maximum number of Table Handles. +** +** \par Limits +** This number must be less than 32767. This number must be at least as big as +** the number of tables (#CFE_TBL_MAX_NUM_TABLES) and should be set higher if tables +** are shared between applications. +*/ +#define CFE_TBL_MAX_NUM_HANDLES 256 + +/** +** \cfetblcfg Maximum Number of Simultaneous Loads to Support +** +** \par Description: +** Defines the maximum number of single buffered tables that can be +** loaded simultaneously. This number is used to determine the number +** of shared buffers to allocate. +** +** \par Limits +** This number must be less than 32767. An excessively high number will +** degrade system performance and waste memory. A number less than 5 is +** suggested but not required. +*/ +#define CFE_TBL_MAX_SIMULTANEOUS_LOADS 4 + +/** +** \cfetblcfg Maximum Number of Simultaneous Table Validations +** +** \par Description: +** Defines the maximum number of pending validations that +** the Table Services can handle at any one time. When a +** table has a validation function, a validation request is +** made of the application to perform that validation. This +** number determines how many of those requests can be +** outstanding at any one time. +** +** \par Limits +** This number must be less than 32767. An excessively high number will +** degrade system performance and waste memory. A number less than 20 is +** suggested but not required. +*/ +#define CFE_TBL_MAX_NUM_VALIDATIONS 10 + +/** +** \cfetblcfg Default Filename for a Table Registry Dump +** +** \par Description: +** Defines the file name used to store the table registry when +** no filename is specified in the dump registry command. +** +** \par Limits +** The length of each string, including the NULL terminator cannot exceed the +** #OS_MAX_PATH_LEN value. +*/ +#define CFE_TBL_DEFAULT_REG_DUMP_FILE "/ram/cfe_tbl_reg.log" + +/** +** \cfetblcfg Number of Spacecraft ID's specified for validation +** +** \par Description: +** Defines the number of specified spacecraft ID values that +** are verified during table loads. If the number is zero +** then no validation of the spacecraft ID field in the table +** file header is performed when tables are loaded. Non-zero +** values indicate how many values from the list of spacecraft +** ID's defined below are compared to the spacecraft ID field +** in the table file header. The ELF2CFETBL tool may be used +** to create table files with specified spacecraft ID values. +** +** \par Limits +** This number must be greater than or equal to zero and +** less than or equal to 2. +*/ +#define CFE_TBL_VALID_SCID_COUNT 0 + +/* macro to construct 32 bit value from 4 chars */ +#define CFE_TBL_U32FROM4CHARS( _C1, _C2, _C3, _C4 ) \ + ( (uint32)(_C1) << 24 | \ + (uint32)(_C2) << 16 | \ + (uint32)(_C3) << 8 | \ + (uint32)(_C4) ) + +/** +** \cfetblcfg Spacecraft ID values used for table load validation +** +** \par Description: +** Defines the spacecraft ID values used for validating the +** spacecraft ID field in the table file header. To be valid, +** the spacecraft ID specified in the table file header must +** match one of the values defined here. +** +** \par Limits +** This value can be any 32 bit unsigned integer. +*/ +#define CFE_TBL_VALID_SCID_1 (CFE_SPACECRAFT_ID) +#define CFE_TBL_VALID_SCID_2 (CFE_TBL_U32FROM4CHARS('a', 'b', 'c', 'd')) + +/** +** \cfetblcfg Number of Processor ID's specified for validation +** +** \par Description: +** Defines the number of specified processor ID values that +** are verified during table loads. If the number is zero +** then no validation of the processor ID field in the table +** file header is performed when tables are loaded. Non-zero +** values indicate how many values from the list of processor +** ID's defined below are compared to the processor ID field +** in the table file header. The ELF2CFETBL tool may be used +** to create table files with specified processor ID values. +** +** \par Limits +** This number must be greater than or equal to zero and +** less than or equal to 4. +*/ +#define CFE_TBL_VALID_PRID_COUNT 0 + +/** +** \cfetblcfg Processor ID values used for table load validation +** +** \par Description: +** Defines the processor ID values used for validating the +** processor ID field in the table file header. To be valid, +** the spacecraft ID specified in the table file header must +** match one of the values defined here. +** +** \par Limits +** This value can be any 32 bit unsigned integer. +*/ +#define CFE_TBL_VALID_PRID_1 (CFE_CPU_ID) +#define CFE_TBL_VALID_PRID_2 (CFE_TBL_U32FROM4CHARS('a', 'b', 'c', 'd')) +#define CFE_TBL_VALID_PRID_3 0 +#define CFE_TBL_VALID_PRID_4 0 + +/** \cfeescfg Mission specific version number for cFE +** +** \par Description: +** The cFE version number consists of four parts: +** major version number, minor version number, revision +** number and mission specific revision number. The mission +** specific revision number is defined here and the other +** parts are defined in "cfe_version.h". +** +** \par Limits: +** Must be defined as a numeric value that is greater than +** or equal to zero. +*/ +#define CFE_MISSION_REV 0 + +/** \cfeescfg Poll timer for startup sync delay +** +** \par Description: +** During startup, some tasks may need to synchronize their own initialization +** with the initialization of other applications in the system. +** +** CFE ES implements an API to accomplish this, that performs a task delay (sleep) +** while polling the overall system state until other tasks are ready. +** +** This value controls the amount of time that the CFE_ES_ApplicationSyncDelay +** will sleep between each check of the system state. This should be large enough +** to allow other tasks to run, but not so large as to noticeably delay the startup +** completion. +** +** Units are in milliseconds +** +** \par Limits: +** Must be defined as an integer value that is greater than +** or equal to zero. +*/ +#define CFE_ES_STARTUP_SYNC_POLL_MSEC 50 + +/** \cfeescfg CFE core application startup timeout +** +** \par Description: +** The upper limit for the amount of time that the cFE core applications +** (ES, SB, EVS, TIME, TBL) are each alloted to reach their respective +** "ready" states. +** +** The CFE "main" thread starts individual tasks for each of the core applications +** (except FS). Each of these must perform some initialization work before the +** next core application can be started, so the main thread waits to ensure that the +** application has reached the "ready" state before starting the next application. +** +** If any core application fails to start, then it indicates a major problem with +** the system and startup is aborted. +** +** Units are in milliseconds +** +** \par Limits: +** Must be defined as an integer value that is greater than +** or equal to zero. +** +*/ +#define CFE_CORE_MAX_STARTUP_MSEC 30000 + +/** \cfeescfg Startup script timeout +** +** \par Description: +** The upper limit for the total amount of time that all apps listed in the CFE ES startup +** script may take to all become ready. +** +** Unlike the "core" app timeout, this is a soft limit; if the alloted time is exceeded, +** it probably indicates an issue with one of the apps, but does not cause CFE ES to take +** any additional action other than logging the event to the syslog. +** +** Units are in milliseconds +** +** \par Limits: +** Must be defined as an integer value that is greater than +** or equal to zero. + */ +#define CFE_ES_STARTUP_SCRIPT_TIMEOUT_MSEC 30000 + + +#endif diff --git a/src/components/interface/cFE/cfe_psp.h b/src/components/interface/cFE/cfe_psp.h new file mode 100644 index 0000000000..277816e188 --- /dev/null +++ b/src/components/interface/cFE/cfe_psp.h @@ -0,0 +1,422 @@ +/* +** File Name: cfe_psp.h +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Author: A. Cudmore +** +** Purpose: This file contains the cFE Platform Support Package(PSP) +** prototypes. +** The PSP routines serve as the "glue" between the RTOS and +** the cFE Flight Software. The routines fill gaps that are not +** really considered part of the OS Abstraction, but are required +** for the cFE flight software implementation. It is possible that +** some of these routines could migrate into the OS AL. +** +** $Log: cfe_psp.h $ +** Revision 1.3 2009/07/29 12:04:46GMT-05:00 acudmore +** Added Bank parameter to EEPROM Power up/down and EEPROM write enable/disable functions. +** Revision 1.2 2009/07/22 17:34:10EDT acudmore +** Added new watchdog API +** Revision 1.1 2009/06/10 09:28:44EDT acudmore +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFE-PSP-REPOSITORY/fsw/inc/project.pj +** +*/ + +#ifndef _cfe_psp_ +#define _cfe_psp_ + +/* +** Include Files +*/ + +#include "common_types.h" +#include "osapi.h" + +/* + * These internal header files should not be used in application code + * They will not be accessible when using the newest build scripts + */ +#if !defined(_ENHANCED_BUILD_) || defined(_CFE_PSP_) +#include "cfe_psp_config.h" +#include "psp_version.h" +#endif + +/* +** Macro Definitions +*/ + +/* +** Error and return codes +*/ +#define CFE_PSP_SUCCESS (0) +#define CFE_PSP_ERROR (-1) +#define CFE_PSP_INVALID_POINTER (-2) +#define CFE_PSP_ERROR_ADDRESS_MISALIGNED (-3) +#define CFE_PSP_ERROR_TIMEOUT (-4) +#define CFE_PSP_INVALID_INT_NUM (-5) +#define CFE_PSP_INVALID_MEM_ADDR (-21) +#define CFE_PSP_INVALID_MEM_TYPE (-22) +#define CFE_PSP_INVALID_MEM_RANGE (-23) +#define CFE_PSP_INVALID_MEM_WORDSIZE (-24) +#define CFE_PSP_INVALID_MEM_SIZE (-25) +#define CFE_PSP_INVALID_MEM_ATTR (-26) +#define CFE_PSP_ERROR_NOT_IMPLEMENTED (-27) +#define CFE_PSP_INVALID_MODULE_NAME (-28) +#define CFE_PSP_INVALID_MODULE_ID (-29) + + + +/* +** Definitions for PSP PANIC types +*/ +#define CFE_PSP_PANIC_STARTUP 1 +#define CFE_PSP_PANIC_VOLATILE_DISK 2 +#define CFE_PSP_PANIC_MEMORY_ALLOC 3 +#define CFE_PSP_PANIC_NONVOL_DISK 4 +#define CFE_PSP_PANIC_STARTUP_SEM 5 +#define CFE_PSP_PANIC_CORE_APP 6 +#define CFE_PSP_PANIC_GENERAL_FAILURE 7 + +/* +** Macros for the file loader +*/ +#define BUFF_SIZE 256 +#define SIZE_BYTE 1 +#define SIZE_HALF 2 +#define SIZE_WORD 3 + +/* +** Define memory types +*/ +#define CFE_PSP_MEM_RAM 1 +#define CFE_PSP_MEM_EEPROM 2 +#define CFE_PSP_MEM_ANY 3 +#define CFE_PSP_MEM_INVALID 4 + +/* +** Define Memory Read/Write Attributes +*/ +#define CFE_PSP_MEM_ATTR_WRITE 0x01 +#define CFE_PSP_MEM_ATTR_READ 0x02 +#define CFE_PSP_MEM_ATTR_READWRITE 0x03 + +/* +** Define the Memory Word Sizes +*/ +#define CFE_PSP_MEM_SIZE_BYTE 0x01 +#define CFE_PSP_MEM_SIZE_WORD 0x02 +#define CFE_PSP_MEM_SIZE_DWORD 0x04 + +/* + * Common definition for reset types at the PSP layer + */ +/** \name Reset Types */ +/** \{ */ +#define CFE_PSP_RST_TYPE_PROCESSOR 1 /**< Volatile disk, Critical Data Store and User Reserved memory could still be valid */ +#define CFE_PSP_RST_TYPE_POWERON 2 /**< All memory has been cleared */ +#define CFE_PSP_RST_TYPE_MAX 3 /**< Placeholder to indicate 1+ the maximum value that the PSP will ever use. */ +/** \} */ + +/* +** Reset Sub-Types +*/ +/** \name Reset Sub-Types */ +/** \{ */ +#define CFE_PSP_RST_SUBTYPE_POWER_CYCLE 1 /**< \brief Reset caused by power having been removed and restored */ +#define CFE_PSP_RST_SUBTYPE_PUSH_BUTTON 2 /**< \brief Reset caused by reset button on the board having been pressed */ +#define CFE_PSP_RST_SUBTYPE_HW_SPECIAL_COMMAND 3 /**< \brief Reset was caused by a reset line having been stimulated by a hardware special command */ +#define CFE_PSP_RST_SUBTYPE_HW_WATCHDOG 4 /**< \brief Reset was caused by a watchdog timer expiring */ +#define CFE_PSP_RST_SUBTYPE_RESET_COMMAND 5 /**< \brief Reset was caused by cFE ES processing a \link #CFE_ES_RESTART_CC Reset Command \endlink */ +#define CFE_PSP_RST_SUBTYPE_EXCEPTION 6 /**< \brief Reset was caused by a Processor Exception */ +#define CFE_PSP_RST_SUBTYPE_UNDEFINED_RESET 7 /**< \brief Reset was caused in an unknown manner */ +#define CFE_PSP_RST_SUBTYPE_HWDEBUG_RESET 8 /**< \brief Reset was caused by a JTAG or BDM connection */ +#define CFE_PSP_RST_SUBTYPE_BANKSWITCH_RESET 9 /**< \brief Reset reverted to a cFE POWERON due to a boot bank switch */ +#define CFE_PSP_RST_SUBTYPE_MAX 10 /**< \brief Placeholder to indicate 1+ the maximum value that the PSP will ever use. */ +/** \} */ + +/* Replacements for the "version" macros */ +#ifdef _ENHANCED_BUILD_ + +#define CFE_PSP_MAJOR_VERSION (GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MajorVersion) +#define CFE_PSP_MINOR_VERSION (GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MinorVersion) +#define CFE_PSP_REVISION (GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.Revision) +#define CFE_PSP_MISSION_REV (GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MissionRev) + +/* For backwards compatibility */ +#define CFE_PSP_SUBMINOR_VERSION CFE_PSP_REVISION + +#endif + +/* +** Type Definitions +*/ + +/* +** Memory table type +*/ +typedef struct +{ + uint32 MemoryType; + uint32 WordSize; + cpuaddr StartAddr; + uint32 Size; + uint32 Attributes; +} CFE_PSP_MemTable_t; + +/* +** Function prototypes +*/ + +/* +** PSP entry point and reset routines +*/ +extern void CFE_PSP_Main(uint32 ModeId, char *StartupFilePath); + +/* +** CFE_PSP_Main is the entry point that the real time OS calls to start our +** software. This routine will do any BSP/OS specific setup, then call the +** entrypoint of the flight software ( i.e. the cFE main entry point ). +** The flight software (i.e. cFE ) should not call this routine. +*/ + +extern void CFE_PSP_GetTime(OS_time_t *LocalTime); +/* This call gets the local time from the hardware on the Vxworks system + * on the mcp750s + * on the other os/hardware setup, it will get the time the normal way */ + + +extern void CFE_PSP_Restart(uint32 resetType); +/* +** CFE_PSP_Restart is the entry point back to the BSP to restart the processor. +** The flight software calls this routine to restart the processor. +*/ + + +extern uint32 CFE_PSP_GetRestartType(uint32 *restartSubType ); +/* +** CFE_PSP_GetRestartType returns the last reset type and if a pointer to a valid +** memory space is passed in, it returns the reset sub-type in that memory. +** Right now the reset types are application specific. For the cFE they +** are defined in the cfe_es.h file. +*/ + + +extern void CFE_PSP_FlushCaches(uint32 type, cpuaddr address, uint32 size); +/* +** This is a BSP specific cache flush routine +*/ + +extern uint32 CFE_PSP_GetProcessorId ( void ); +/* +** CFE_PSP_GetProcessorId returns the CPU ID as defined by the specific board +** and BSP. +*/ + + +extern uint32 CFE_PSP_GetSpacecraftId ( void ); +/* +** CFE_PSP_GetSpacecraftId retuns the Spacecraft ID (if any ) +*/ + + +extern uint32 CFE_PSP_Get_Timer_Tick(void); +/* +** CFE_PSP_Get_Timer_Tick returns the underlying OS timer tick value +** It is used for the performance monitoring software +*/ + +extern uint32 CFE_PSP_GetTimerTicksPerSecond(void); +/* +** CFE_PSP_GetTimerTicksPerSecond provides the resolution of the least significant +** 32 bits of the 64 bit time stamp returned by CFE_PSP_Get_Timebase in timer +** ticks per second. The timer resolution for accuracy should not be any slower +** than 1000000 ticks per second or 1 us per tick +*/ + +extern uint32 CFE_PSP_GetTimerLow32Rollover(void); +/* +** CFE_PSP_GetTimerLow32Rollover provides the number that the least significant +** 32 bits of the 64 bit time stamp returned by CFE_PSP_Get_Timebase rolls over. +** If the lower 32 bits rolls at 1 second, then the CFE_PSP_TIMER_LOW32_ROLLOVER +** will be 1000000. if the lower 32 bits rolls at its maximum value (2^32) then +** CFE_PSP_TIMER_LOW32_ROLLOVER will be 0. +*/ + +extern void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32 *Tbl); +/* +** CFE_PSP_Get_Timebase +*/ + +extern uint32 CFE_PSP_Get_Dec(void); +/* +** CFE_PSP_Get_Dec +*/ + + +extern int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType ); +/* +** CFE_PSP_InitProcessorReservedMemory initializes all of the memory in the +** BSP that is preserved on a processor reset. The memory includes the +** Critical Data Store, the ES Reset Area, the Volatile Disk Memory, and +** the User Reserved Memory. In general, the memory areas will be initialized +** ( cleared ) on a Power On reset, and preserved during a processor reset. +*/ + +extern int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS); +/* +** CFE_PSP_GetCDSSize fetches the size of the OS Critical Data Store area. +*/ + +extern int32 CFE_PSP_WriteToCDS(void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumBytes); +/* +** CFE_PSP_WriteToCDS writes to the CDS Block. +*/ + +extern int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumBytes); +/* +** CFE_PSP_ReadFromCDS reads from the CDS Block +*/ + +extern int32 CFE_PSP_GetResetArea (cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea); +/* +** CFE_PSP_GetResetArea returns the location and size of the ES Reset information area. +** This area is preserved during a processor reset and is used to store the +** ER Log, System Log and reset related variables +*/ + +extern int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea ); +/* +** CFE_PSP_GetUserReservedArea returns the location and size of the memory used for the cFE +** User reserved area. +*/ + +extern int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk ); +/* +** CFE_PSP_GetVolatileDiskMem returns the location and size of the memory used for the cFE +** volatile disk. +*/ + +extern int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *SizeOfKernelSegment); +/* +** CFE_PSP_GetKernelTextSegmentInfo returns the location and size of the kernel memory. +*/ + +extern int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFESegment); +/* +** CFE_PSP_GetCFETextSegmentInfo returns the location and size of the kernel memory. +*/ + +extern void CFE_PSP_WatchdogInit(void); +/* +** CFE_PSP_WatchdogInit configures the watchdog timer. +*/ + +extern void CFE_PSP_WatchdogEnable(void); +/* +** CFE_PSP_WatchdogEnable enables the watchdog timer. +*/ + +extern void CFE_PSP_WatchdogDisable(void); +/* +** CFE_PSP_WatchdogDisable disables the watchdog timer. +*/ + +extern void CFE_PSP_WatchdogService(void); +/* +** CFE_PSP_WatchdogService services the watchdog timer according to the +** value set in WatchDogSet. +*/ + +extern uint32 CFE_PSP_WatchdogGet(void); +/* +** CFE_PSP_WatchdogGet gets the watchdog time in milliseconds +*/ + +extern void CFE_PSP_WatchdogSet(uint32 WatchdogValue); +/* +** CFE_PSP_WatchdogSet sets the watchdog time in milliseconds +*/ + +extern void CFE_PSP_Panic(int32 ErrorCode); +/* +** CFE_PSP_Panic is called by the cFE Core startup code when it needs to abort the +** cFE startup. This should not be called by applications. +*/ + +extern int32 CFE_PSP_InitSSR(uint32 bus, uint32 device, char *DeviceName ); +/* +** CFE_PSP_InitSSR will initialize the Solid state recorder memory for a particular platform +*/ + +extern int32 CFE_PSP_Decompress( char * srcFileName, char * dstFileName ); +/* +** CFE_PSP_Decompress will uncompress the source file to the file specified in the +** destination file name. The Decompress uses the "gzip" algorithm. Files can +** be compressed using the "gzip" program available on almost all host platforms. +*/ + +extern void CFE_PSP_AttachExceptions(void); +/* +** CFE_PSP_AttachExceptions will setup the exception environment for the chosen platform +** On a board, this can be configured to look at a debug flag or switch in order to +** keep the standard OS exeption handlers, rather than restarting the system +*/ + + +extern void CFE_PSP_SetDefaultExceptionEnvironment(void); +/* +** +** CFE_PSP_SetDefaultExceptionEnvironment defines the CPU and FPU exceptions that are enabled for each cFE Task/App +** +** Notes: The exception environment is local to each task Therefore this must be +** called for each task that that wants to do floating point and catch exceptions +*/ + + +/* +** I/O Port API +*/ +int32 CFE_PSP_PortRead8 (cpuaddr PortAddress, uint8 *ByteValue); +int32 CFE_PSP_PortWrite8 (cpuaddr PortAddress, uint8 ByteValue); +int32 CFE_PSP_PortRead16 (cpuaddr PortAddress, uint16 *uint16Value); +int32 CFE_PSP_PortWrite16 (cpuaddr PortAddress, uint16 uint16Value); +int32 CFE_PSP_PortRead32 (cpuaddr PortAddress, uint32 *uint32Value); +int32 CFE_PSP_PortWrite32 (cpuaddr PortAddress, uint32 uint32Value); + +/* +** Memory API +*/ +int32 CFE_PSP_MemRead8 (cpuaddr MemoryAddress, uint8 *ByteValue); +int32 CFE_PSP_MemWrite8 (cpuaddr MemoryAddress, uint8 ByteValue); +int32 CFE_PSP_MemRead16 (cpuaddr MemoryAddress, uint16 *uint16Value); +int32 CFE_PSP_MemWrite16 (cpuaddr MemoryAddress, uint16 uint16Value); +int32 CFE_PSP_MemRead32 (cpuaddr MemoryAddress, uint32 *uint32Value); +int32 CFE_PSP_MemWrite32 (cpuaddr MemoryAddress, uint32 uint32Value); + +int32 CFE_PSP_MemCpy (void *dest, void *src, uint32 n); +int32 CFE_PSP_MemSet (void *dest, uint8 value, uint32 n); + +int32 CFE_PSP_MemValidateRange (cpuaddr Address, uint32 Size, uint32 MemoryType); +uint32 CFE_PSP_MemRanges (void); +int32 CFE_PSP_MemRangeSet (uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, + uint32 Size, uint32 WordSize, uint32 Attributes); +int32 CFE_PSP_MemRangeGet (uint32 RangeNum, uint32 *MemoryType, cpuaddr *StartAddr, + uint32 *Size, uint32 *WordSize, uint32 *Attributes); + +int32 CFE_PSP_EepromWrite8 (cpuaddr MemoryAddress, uint8 ByteValue); +int32 CFE_PSP_EepromWrite16 (cpuaddr MemoryAddress, uint16 uint16Value); +int32 CFE_PSP_EepromWrite32 (cpuaddr MemoryAddress, uint32 uint32Value); + +int32 CFE_PSP_EepromWriteEnable (uint32 Bank); +int32 CFE_PSP_EepromWriteDisable(uint32 Bank); +int32 CFE_PSP_EepromPowerUp (uint32 Bank); +int32 CFE_PSP_EepromPowerDown (uint32 Bank); + +#endif /* _cfe_psp_ */ diff --git a/src/components/interface/cFE/cfe_psp_config.h b/src/components/interface/cFE/cfe_psp_config.h new file mode 100644 index 0000000000..44699696a3 --- /dev/null +++ b/src/components/interface/cFE/cfe_psp_config.h @@ -0,0 +1,57 @@ +/* +** cfe_psp_config.h +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** +*/ + +#ifndef _cfe_psp_config_ +#define _cfe_psp_config_ + + + +#include "common_types.h" + + +/* +** This define sets the number of memory ranges that are defined in the memory range defintion +** table. +*/ +#define CFE_PSP_MEM_TABLE_SIZE 10 + + +/* +** Processor Context type. +** This is needed to determine the size of the context entry in the ER log. +** Although this file is in a CPU directory, it really is OS dependant, so supporting +** multiple OSs on the same CPU architecture ( i.e. x86/linux, x86/windows, x86/osx ) +** will require IFDEFS. +*/ +typedef struct +{ + uint32 regs[32]; + +} CFE_PSP_ExceptionContext_t; + +#define CFE_PSP_CPU_CONTEXT_SIZE (sizeof(CFE_PSP_ExceptionContext_t)) + + +/* +** Watchdog minimum and maximum values ( in milliseconds ) +*/ +#define CFE_PSP_WATCHDOG_MIN (0) +#define CFE_PSP_WATCHDOG_MAX (0xFFFFFFFF) + +/* +** Number of EEPROM banks on this platform +*/ +#define CFE_PSP_NUM_EEPROM_BANKS 1 + +#endif + diff --git a/src/components/interface/cFE/cfe_psp_configdata.h b/src/components/interface/cFE/cfe_psp_configdata.h new file mode 100644 index 0000000000..9e60caf3d7 --- /dev/null +++ b/src/components/interface/cFE/cfe_psp_configdata.h @@ -0,0 +1,88 @@ +/** + * \file cfe_psp_config.h + * + * Created on: Dec 31, 2014 + * Author: joseph.p.hickey@nasa.gov + * + * Copyright (c) 2004-2011, United States Government as represented by + * Administrator for The National Aeronautics and Space Administration. + * All Rights Reserved. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only pursuant to the terms of that agreement. + */ + +#ifndef CFE_PSP_CONFIG_H_ +#define CFE_PSP_CONFIG_H_ + +/* osapi.h is required for the definition of OS_VolumeInto_t */ +#include +/* cfe_psp.h is required for the definition of CFE_PSP_MemTable_t */ +#include + +/* +** PSP software version record +** (replaces PSP_*_VERSION macros) +*/ +typedef const struct +{ + uint8 MajorVersion; + uint8 MinorVersion; + uint8 Revision; + uint8 MissionRev; +} CFE_PSP_VersionInfo_t; + + + +/** + * PSP/Hardware configuration parameters + * This structure should be instantiated by the PSP according + * such that other modules do not need to directly include + * the PSP configuration at compile time. + */ +typedef const struct +{ + uint32 PSP_WatchdogMin; /**< PSP Minimum watchdog in milliseconds */ + uint32 PSP_WatchdogMax; /**< PSP Maximum watchdog in milliseconds */ + uint32 PSP_MemTableSize; /**< Size of PSP memory table */ + CFE_PSP_MemTable_t *PSP_MemoryTable; /**< Pointer to PSP memory table (forward reference) */ + + uint32 OS_VolumeTableSize; /**< Size of OS volume table */ + OS_VolumeInfo_t *OS_VolumeTable; /**< Pointer to OS volume table (forward reference) */ + + /** + * Processor Context type. + * This is needed to determine the size of the context entry in the ER log. + * It is a placeholder as the implementation to use it is not merged in yet. + */ + uint32 OS_CpuContextSize; + + /** + * Number of EEPROM banks on this platform + */ + uint32 HW_NumEepromBanks; + + CFE_PSP_VersionInfo_t PSP_VersionInfo; + +} Target_PspConfigData; + +/** + * Extern reference to psp config struct. + * Allows the actual instantiation to be done outside this module + */ +extern Target_PspConfigData GLOBAL_PSP_CONFIGDATA; + +/** + * Extern reference to the psp memory table + * Allows the actual instantiation to be done outside this module + */ +extern CFE_PSP_MemTable_t CFE_PSP_MemoryTable[]; + +/** + * Extern reference to the psp volume table + * Allows the actual instantiation to be done outside this module + */ +extern OS_VolumeInfo_t OS_VolumeTable[]; + + +#endif /* CFE_PSP_CONFIG_H_ */ diff --git a/src/components/interface/cFE/cfe_sb.h b/src/components/interface/cFE/cfe_sb.h new file mode 100644 index 0000000000..a0fabd581c --- /dev/null +++ b/src/components/interface/cFE/cfe_sb.h @@ -0,0 +1,1267 @@ +/****************************************************************************** +** File: cfe_sb.h +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** +** Purpose: +** This header file contains all definitions for the cFE Software Bus +** Application Programmer's Interface. +** +** Author: R.McGraw/SSI +** +** $Log: cfe_sb.h $ +** Revision 1.10 2011/04/07 08:34:14GMT-05:00 lwalling +** This file references CFE TIME structures, therefore it should include cfe_time.h +** Revision 1.9 2009/07/29 19:21:50EDT aschoeni +** Added ZeroCopyHandle_t +** Revision 1.8 2009/07/24 18:25:20EDT aschoeni +** Added Zero Copy Mode +** Revision 1.7 2009/07/17 19:42:20EDT aschoeni +** Added PassMsg API to sb to support sequence count preservation +** Revision 1.6 2009/06/10 09:15:06EDT acudmore +** updated os_bsp.h to cfe_psp.h +** Revision 1.5 2009/04/29 10:03:59EDT rmcgraw +** DCR5801:11 Changed comments related to subscription return value +** Revision 1.4 2009/02/27 09:55:04EST rmcgraw +** DCR1709:1 Removed incorrect comment in SetTotalMsgLength +** and reworded other comments +** Revision 1.3 2009/02/26 17:49:19EST rmcgraw +** DCR6805:1 Added note under subscription API declaration +** Revision 1.2 2008/12/08 12:06:56EST dkobe +** Updates to correct doxygen errors +** Revision 1.1 2008/04/17 08:05:22EDT ruperera +** Initial revision +** Member added to cfe project on tlserver3 +** Revision 1.25 2007/09/25 10:34:38EDT rjmcgraw +** DCR5127 Added doxygen comments +** Revision 1.24 2007/07/06 13:18:35EDT rjmcgraw +** DCR469:1 Changed function prototype for GetLastSenderId +** Revision 1.23 2007/05/23 11:22:02EDT dlkobe +** Added doxygen formatting +** Revision 1.22 2007/04/19 15:47:03EDT rjmcgraw +** Moved subscription reporting structs to cfe_sb_msg.h +** Revision 1.20 2007/03/22 12:55:20EST rjmcgraw +** Added comments regarding Qos +** Revision 1.19 2007/01/24 16:49:35EST rjmcgraw +** Added Pipe to SubEntries_t +** Revision 1.18 2007/01/08 14:42:18EST rjmcgraw +** Moved SubscribeLocal prototypes to this file from cfe_sb_priv.h +** Revision 1.17 2007/01/04 14:49:44EST rjmcgraw +** Added SubType to CFE_SB_SubRprtMsg_t +** Revision 1.16 2007/01/02 10:01:35EST rjmcgraw +** Moved structs from priv.h to cfe_sb.h for exposure to apps +** Revision 1.15 2006/12/28 16:27:34EST rjmcgraw +** Added cmd codes for SB subscription processing +** +******************************************************************************/ + +#ifndef _cfe_sb_ +#define _cfe_sb_ + +/* +** Includes +*/ +#include "osconfig.h" +#include "cfe_psp.h" +#include "common_types.h" +#include "cfe_mission_cfg.h" +#include "cfe_platform_cfg.h" +#include "ccsds.h" +#include "cfe_time.h" + + +/* +** Defines +*/ +#define CFE_SB_POLL 0 /**< \brief Option used with #CFE_SB_RcvMsg to request immediate pipe status */ +#define CFE_SB_PEND_FOREVER -1 /**< \brief Option used with #CFE_SB_RcvMsg to force a wait for next message */ +#define CFE_SB_SUB_ENTRIES_PER_PKT 20 /**< \brief Configuration parameter used by SBN App */ +#define CFE_SB_SUBSCRIPTION 0 /**< \brief Subtype specifier used in #CFE_SB_SubRprtMsg_t by SBN App */ +#define CFE_SB_UNSUBSCRIPTION 1 /**< \brief Subtype specified used in #CFE_SB_SubRprtMsg_t by SBN App */ + +/* +** Macro Definitions +*/ +#define CFE_BIT(x) (1 << (x)) /**< \brief Places a one at bit positions 0 - 31*/ +#define CFE_SET(i,x) ((i) |= CFE_BIT(x)) /**< \brief Sets bit x of i */ +#define CFE_CLR(i,x) ((i) &= ~CFE_BIT(x)) /**< \brief Clears bit x of i */ +#define CFE_TST(i,x) (((i) & CFE_BIT(x)) != 0)/**< \brief TRUE(non zero) if bit x of i is set */ + +/** + * Macro that should be used to set memory addresses within software bus messages. + * For now this does a straight copy, but in a future revision this may translate the + * raw memory address into a "safe" integer value. This is particularly important if + * the message is to be sent off this CPU. + */ +#define CFE_SB_SET_MEMADDR(msgdst,src) msgdst = (cpuaddr)src + +/** + * Macro that should be used to get memory addresses from software bus messages. + * This is the inverse operation of CFE_SB_SET_MEMADDR. + */ +#define CFE_SB_GET_MEMADDR(msgsrc) (cpuaddr)msgsrc + +/* +** Type Definitions +*/ +#ifdef MESSAGE_FORMAT_IS_CCSDS + + /**< \brief Generic Software Bus Message Type Definition */ + typedef union { + CCSDS_PriHdr_t Hdr; /**< \brief CCSDS Primary Header #CCSDS_PriHdr_t */ + uint32 Dword; /**< \brief Forces minimum of 32-bit alignment for this object */ + uint8 Byte[sizeof(CCSDS_PriHdr_t)]; /**< \brief Allows byte-level access */ + }CFE_SB_Msg_t; + + /**< \brief Generic Software Bus Command Header Type Definition */ + typedef struct{ + CCSDS_PriHdr_t Pri;/**< \brief CCSDS Primary Header #CCSDS_PriHdr_t */ + CCSDS_CmdSecHdr_t Sec;/**< \brief CCSDS Command Secondary Header #CCSDS_CmdSecHdr_t */ + }CFE_SB_CmdHdr_t; + + /**< \brief Generic Software Bus Telemetry Header Type Definition */ + typedef struct{ + CCSDS_PriHdr_t Pri;/**< \brief CCSDS Primary Header #CCSDS_PriHdr_t */ + CCSDS_TlmSecHdr_t Sec;/**< \brief CCSDS Telemetry Secondary Header #CCSDS_TlmSecHdr_t */ + }CFE_SB_TlmHdr_t; + + #define CFE_SB_CMD_HDR_SIZE (sizeof(CFE_SB_CmdHdr_t))/**< \brief Size of #CFE_SB_CmdHdr_t in bytes */ + #define CFE_SB_TLM_HDR_SIZE (sizeof(CFE_SB_TlmHdr_t))/**< \brief Size of #CFE_SB_TlmHdr_t in bytes */ + +#endif /* MESSAGE_FORMAT_IS_CCSDS */ + +/**< \brief CFE_SB_TimeOut_t to primitive type definition +** +** Internally used by SB in the #CFE_SB_RcvMsg API. Translated from the +** input parmater named TimeOut which specifies the maximum time in +** milliseconds that the caller wants to wait for a message. +*/ +typedef uint32 CFE_SB_TimeOut_t; + +/**< \brief CFE_SB_PipeId_t to primitive type definition +** +** Software Bus pipe identifier used in many SB APIs +*/ +typedef uint8 CFE_SB_PipeId_t; + +/**< \brief CFE_SB_MsgId_t to primitive type definition +** +** Software Bus message identifier used in many SB APIs +*/ +typedef uint16 CFE_SB_MsgId_t; + +/**< \brief CFE_SB_MsgPtr_t defined as a pointer to an SB Message */ +typedef CFE_SB_Msg_t *CFE_SB_MsgPtr_t; + +/**< \brief CFE_SB_MsgPayloadPtr_t defined as an opaque pointer to a message Payload portion */ +typedef uint8 *CFE_SB_MsgPayloadPtr_t; + +/**< \brief CFE_SB_ZeroCopyId_t to primitive type definition +** +** Software Zero Copy handle used in many SB APIs +*/ +typedef cpuaddr CFE_SB_ZeroCopyHandle_t; + +/**< \brief Quality Of Service Type Definition +** +** Currently an unused parameter in #CFE_SB_SubscribeEx +** Intended to be used for interprocessor communication only +**/ +typedef struct { + uint8 Priority;/**< \brief Specify high(1) or low(0) message priority for off-board routing, currently unused */ + uint8 Reliability;/**< \brief Specify high(1) or low(0) message transfer reliability for off-board routing, currently unused */ +}CFE_SB_Qos_t; + +extern CFE_SB_Qos_t CFE_SB_Default_Qos;/**< \brief Defines a default priority and reliabilty for off-board routing */ + + +/**< \brief Message Sender Identification Type Definition +** +** Parameter used in #CFE_SB_GetLastSenderId API which allows the receiver of a message +** to validate the sender of the message. +**/ +typedef struct { + uint32 ProcessorId;/**< \brief Processor Id from which the message was sent */ + char AppName[OS_MAX_API_NAME];/**< \brief Application that sent the message */ +} CFE_SB_SenderId_t; + +/* +** cFE SB Application Programmer Interface's (API's) +*/ + +/*****************************************************************************/ +/** +** \brief Creates a new software bus pipe. +** +** \par Description +** This routine creates and initializes an input pipe that the calling +** application can use to receive software bus messages. By default, no +** messages are routed to the new pipe. So, the application must use +** #CFE_SB_Subscribe() to specify which messages it wants to receive on +** this pipe. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] PipeIdPtr A pointer to a variable of type #CFE_SB_PipeId_t, +** which will be filled in with the pipe ID information +** by the #CFE_SB_CreatePipe routine. +** +** \param[in] Depth The maximum number of messages that will be allowed on +** this pipe at one time. +** +** \param[in] PipeName A string to be used to identify this pipe in error messages +** and routing information telemetry. The string must be no +** longer than #OS_MAX_API_NAME. Longer strings will be truncated. +** +** \param[out] *PipeIdPtr The identifier for the created pipe. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode +** \retcode #CFE_SB_MAX_PIPES_MET \retdesc \copydoc CFE_SB_MAX_PIPES_MET \endcode +** \retcode #CFE_SB_PIPE_CR_ERR \retdesc \copydoc CFE_SB_PIPE_CR_ERR \endcode +** \endreturns +** +** \sa #CFE_SB_DeletePipe +**/ +int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, + uint16 Depth, + const char *PipeName); + +/*****************************************************************************/ +/** +** \brief Delete a software bus pipe. +** +** \par Description +** This routine deletes an input pipe and cleans up all data structures +** associated with the pipe. All subscriptions made for this pipe by +** calls to #CFE_SB_Subscribe will be automatically removed from the +** SB routing tables. Any messages in the pipe will be discarded. +** Applications must call this routine for all of their SB pipes as part +** of their orderly shutdown process. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] PipeId The pipe ID (obtained previously from #CFE_SB_CreatePipe) +** of the pipe to be deleted. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode +** \endreturns +** +** \sa #CFE_SB_CreatePipe +**/ +int32 CFE_SB_DeletePipe(CFE_SB_PipeId_t PipeId); + +/*****************************************************************************/ +/** +** \brief Subscribe to a message on the software bus +** +** \par Description +** This routine adds the specified pipe to the destination list associated +** with the specified message ID. +** +** \par Assumptions, External Events, and Notes: +** Note: As subscriptions are received, the destinations are added to +** the head of a linked list. During the sending of a message, the list +** is traversed beginning at the head of the list. Therefore the +** message will first be sent to the last subscriber. If an application +** has timing constraints and needs to receive a message in the +** shortest possible time, the developer may consider holding off its +** subscription until other applications have subscribed to the message. +** +** \param[in] MsgId The message ID of the message to be subscribed to. +** +** \param[in] PipeId The pipe ID of the pipe the subscribed message +** should be sent to. +** +** \param[in] Quality The requested Quality of Service (QoS) required of +** the messages. Most callers will use #CFE_SB_Default_Qos +** for this parameter. +** +** \param[in] MsgLim The maximum number of messages with this Message ID to +** allow in this pipe at the same time. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_SB_MAX_MSGS_MET \retdesc \copydoc CFE_SB_MAX_MSGS_MET \endcode +** \retcode #CFE_SB_MAX_DESTS_MET \retdesc \copydoc CFE_SB_MAX_DESTS_MET \endcode +** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode +** \retcode #CFE_SB_BUF_ALOC_ERR \retdesc \copydoc CFE_SB_BUF_ALOC_ERR \endcode +** \endreturns +** +** \sa #CFE_SB_Subscribe, #CFE_SB_SubscribeLocal, #CFE_SB_Unsubscribe, #CFE_SB_UnsubscribeLocal +**/ +int32 CFE_SB_SubscribeEx(CFE_SB_MsgId_t MsgId, + CFE_SB_PipeId_t PipeId, + CFE_SB_Qos_t Quality, + uint16 MsgLim); + +/*****************************************************************************/ +/** +** \brief Subscribe to a message on the software bus with default parameters +** +** \par Description +** This routine adds the specified pipe to the destination list for +** the specified message ID. This is the same as #CFE_SB_SubscribeEx +** with the Quality field set to #CFE_SB_Default_Qos and MsgLim set +** to #CFE_SB_DEFAULT_MSG_LIMIT (4). +** +** \par Assumptions, External Events, and Notes: +** Note: As subscriptions are received, the destinations are added to +** the head of a linked list. During the sending of a message, the list +** is traversed beginning at the head of the list. Therefore the +** message will first be sent to the last subscriber. If an application +** has timing constraints and needs to receive a message in the +** shortest possible time, the developer may consider holding off its +** subscription until other applications have subscribed to the message. +** +** \param[in] MsgId The message ID of the message to be subscribed to. +** +** \param[in] PipeId The pipe ID of the pipe the subscribed message +** should be sent to. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_SB_MAX_MSGS_MET \retdesc \copydoc CFE_SB_MAX_MSGS_MET \endcode +** \retcode #CFE_SB_MAX_DESTS_MET \retdesc \copydoc CFE_SB_MAX_DESTS_MET \endcode +** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode +** \retcode #CFE_SB_BUF_ALOC_ERR \retdesc \copydoc CFE_SB_BUF_ALOC_ERR \endcode +** \endreturns +** +** \sa #CFE_SB_SubscribeEx, #CFE_SB_SubscribeLocal, #CFE_SB_Unsubscribe, #CFE_SB_UnsubscribeLocal +**/ +int32 CFE_SB_Subscribe(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId); + +/*****************************************************************************/ +/** +** \brief Subscribe to a message while keeping the request local to a cpu +** +** \par Description +** This routine adds the specified pipe to the destination list for +** the specified message ID. This is similar to #CFE_SB_SubscribeEx +** with the Quality field set to #CFE_SB_Default_Qos and MsgLim set +** to #CFE_SB_DEFAULT_MSG_LIMIT, but will not report the subscription. +** Subscription Reporting is enabled for interprocessor communication +** by way of the Software Bus Network (SBN) Application. +** +** \par Assumptions, External Events, and Notes: +** - This API is typically only used by Software Bus Network (SBN) Application +** +** \param[in] MsgId The message ID of the message to be subscribed to. +** +** \param[in] PipeId The pipe ID of the pipe the subscribed message +** should be sent to. +** +** \param[in] MsgLim The maximum number of messages with this Message ID to +** allow in this pipe at the same time. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_SB_MAX_MSGS_MET \retdesc \copydoc CFE_SB_MAX_MSGS_MET \endcode +** \retcode #CFE_SB_MAX_DESTS_MET \retdesc \copydoc CFE_SB_MAX_DESTS_MET \endcode +** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode +** \retcode #CFE_SB_BUF_ALOC_ERR \retdesc \copydoc CFE_SB_BUF_ALOC_ERR \endcode +** \endreturns +** +** \sa #CFE_SB_Subscribe, #CFE_SB_SubscribeEx, #CFE_SB_Unsubscribe, #CFE_SB_UnsubscribeLocal +**/ +int32 CFE_SB_SubscribeLocal(CFE_SB_MsgId_t MsgId, + CFE_SB_PipeId_t PipeId, + uint16 MsgLim); + +/*****************************************************************************/ +/** +** \brief Remove a subscription to a message on the software bus +** +** \par Description +** This routine removes the specified pipe from the destination +** list for the specified message ID. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MsgId The message ID of the message to be unsubscribed. +** +** \param[in] PipeId The pipe ID of the pipe the subscribed message +** should no longer be sent to. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_SB_NO_SUBSCRIBERS \retdesc \copydoc CFE_SB_NO_SUBSCRIBERS \endcode +** \retcode #CFE_SB_INTERNAL_ERR \retdesc \copydoc CFE_SB_INTERNAL_ERR \endcode +** \endreturns +** +** \sa #CFE_SB_Subscribe, #CFE_SB_SubscribeEx, #CFE_SB_SubscribeLocal, #CFE_SB_UnsubscribeLocal +**/ +int32 CFE_SB_Unsubscribe(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId); + +/*****************************************************************************/ +/** +** \brief Remove a subscription to a message on the software bus on the current CPU +** +** \par Description +** This routine removes the specified pipe from the destination +** list for the specified message ID on the current CPU. +** +** \par Assumptions, External Events, and Notes: +** - This API is typically only used by Software Bus Network (SBN) Application +** +** \param[in] MsgId The message ID of the message to be unsubscribed. +** +** \param[in] PipeId The pipe ID of the pipe the subscribed message +** should no longer be sent to. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_SB_NO_SUBSCRIBERS \retdesc \copydoc CFE_SB_NO_SUBSCRIBERS \endcode +** \retcode #CFE_SB_INTERNAL_ERR \retdesc \copydoc CFE_SB_INTERNAL_ERR \endcode +** \endreturns +** +** \sa #CFE_SB_Subscribe, #CFE_SB_SubscribeEx, #CFE_SB_SubscribeLocal, #CFE_SB_Unsubscribe +**/ +int32 CFE_SB_UnsubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId); + +/*****************************************************************************/ +/** +** \brief Send a software bus message +** +** \par Description +** This routine sends the specified message to all subscribers. The +** software bus will read the message ID from the message header to +** determine which pipes should receive the message. +** +** \par Assumptions, External Events, and Notes: +** - This routine will not normally wait for the receiver tasks to +** process the message before returning control to the caller's task. +** - However, if a higher priority task is pending and subscribed to +** this message, that task may get to run before #CFE_SB_SendMsg +** returns control to the caller. +** - This function tracks and increments the source sequence counter +** of a telemetry message. +** +** \param[in] MsgPtr A pointer to the message to be sent. This must point +** to the first byte of the software bus message header +** (#CFE_SB_Msg_t). +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode +** \retcode #CFE_SB_MSG_TOO_BIG \retdesc \copydoc CFE_SB_MSG_TOO_BIG \endcode +** \retcode #CFE_SB_BUF_ALOC_ERR \retdesc \copydoc CFE_SB_BUF_ALOC_ERR \endcode +** \endreturns +** +** \sa #CFE_SB_RcvMsg, #CFE_SB_ZeroCopySend, #CFE_SB_PassMsg +**/ +int32 CFE_SB_SendMsg(CFE_SB_Msg_t *MsgPtr); + +/*****************************************************************************/ +/** +** \brief Passes a software bus message +** +** \par Description +** This routine sends the specified message to all subscribers. The +** software bus will read the message ID from the message header to +** determine which pipes should receive the message. This routine is +** intended to pass messages not generated by the sending application. +** +** \par Assumptions, External Events, and Notes: +** - This routine will not normally wait for the receiver tasks to +** process the message before returning control to the caller's task. +** - However, if a higher priority task is pending and subscribed to +** this message, that task may get to run before #CFE_SB_PassMsg +** returns control to the caller. +** - Unlike #CFE_SB_SendMsg this routine will preserve the source +** sequence counter in a telemetry message. +** +** \param[in] MsgPtr A pointer to the message to be sent. This must point +** to the first byte of the software bus message header +** (#CFE_SB_Msg_t). +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode +** \retcode #CFE_SB_MSG_TOO_BIG \retdesc \copydoc CFE_SB_MSG_TOO_BIG \endcode +** \retcode #CFE_SB_BUF_ALOC_ERR \retdesc \copydoc CFE_SB_BUF_ALOC_ERR \endcode +** \endreturns +** +** \sa #CFE_SB_RcvMsg, #CFE_SB_ZeroCopySend, #CFE_SB_SendMsg +**/ +int32 CFE_SB_PassMsg(CFE_SB_Msg_t *MsgPtr); + +/*****************************************************************************/ +/** +** \brief Receive a message from a software bus pipe +** +** \par Description +** This routine retrieves the next message from the specified pipe. +** If the pipe is empty, this routine will block until either a new +** message comes in or the timeout value is reached. +** +** \par Assumptions, External Events, and Notes: +** Note - If an error occurs in this API, the *BufPtr value may be NULL or +** random. Therefore, it is recommended that the return code be tested +** for CFE_SUCCESS before processing the message. +** +** \param[in] BufPtr A pointer to a local variable of type #CFE_SB_MsgPtr_t. +** Typically a caller declares a ptr of type CFE_SB_Msg_t +** (i.e. CFE_SB_Msg_t *Ptr) then gives the address of that +** pointer (&Ptr) as this parmeter. After a successful +** receipt of a message, *BufPtr will point to the first +** byte of the software bus message header. This should be +** used as a read-only pointer (in systems with an MMU, +** writes to this pointer may cause a memory protection fault). +** The *BufPtr is valid only until the next call to +** CFE_SB_RcvMsg for the same pipe. +** +** \param[in] PipeId The pipe ID of the pipe containing the message to be obtained. +** +** \param[in] TimeOut The number of milliseconds to wait for a new message if the +** pipe is empty at the time of the call. This can also be set +** to #CFE_SB_POLL for a non-blocking receive or +** #CFE_SB_PEND_FOREVER to wait forever for a message to arrive. +** +** \param[out] *BufPtr A pointer to the message obtained from the pipe. Valid +** only until the next call to CFE_SB_RcvMsg for the same pipe. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode +** \retcode #CFE_SB_TIME_OUT \retdesc \copydoc CFE_SB_TIME_OUT \endcode +** \retcode #CFE_SB_PIPE_RD_ERR \retdesc \copydoc CFE_SB_PIPE_RD_ERR \endcode +** \retcode #CFE_SB_NO_MESSAGE \retdesc \copydoc CFE_SB_NO_MESSAGE \endcode +** \endreturns +** +** \sa #CFE_SB_SendMsg, #CFE_SB_ZeroCopySend +**/ +int32 CFE_SB_RcvMsg(CFE_SB_MsgPtr_t *BufPtr, + CFE_SB_PipeId_t PipeId, + int32 TimeOut); + +/*****************************************************************************/ +/** +** \brief Retrieve the application Info of the sender for the last message. +** +** \par Description +** This routine can be used after a successful #CFE_SB_RcvMsg call +** to find out which application sent the message that was received. +** +** \par Assumptions, External Events, and Notes: +** Note - If an error occurs in this API, the *Ptr value may be NULL or +** random. Therefore, it is recommended that the return code be tested +** for CFE_SUCCESS before reading the sender information. +** +** \param[in] Ptr A pointer to a local variable of type #CFE_SB_SenderId_t. +** Typically a caller declares a ptr of type CFE_SB_SenderId_t +** (i.e. CFE_SB_SenderId_t *Ptr) then gives the address of that +** pointer (&Ptr) for this parameter. After a successful call +** to this API, *Ptr will point to the first byte of the +** CFE_SB_SenderId_t structure containing the sender information +** for the last message received on the given pipe. This should +** be used as a read-only pointer (in systems with an MMU, writes +** to this pointer may cause a memory protection fault). The *Ptr +** is valid only until the next call to CFE_SB_RcvMsg for the +** same pipe. +** +** \param[in] PipeId The pipe ID of the pipe the message was taken from. +** +** \returns +** \retcode The sender's application ID \retdesc \endcode +** \endreturns +** +** \sa +**/ +uint32 CFE_SB_GetLastSenderId(CFE_SB_SenderId_t **Ptr,CFE_SB_PipeId_t PipeId); + +/*****************************************************************************/ +/** +** \brief Get a buffer pointer to use for "zero copy" SB sends. +** +** \par Description +** This routine can be used to get a pointer to one of the software bus' +** internal memory buffers that are used for sending messages. The caller +** can use this memory buffer to build an SB message, then send it using +** the #CFE_SB_ZeroCopySend function. This interface is more complicated +** than the normal #CFE_SB_ZeroCopySend interface, but it avoids an extra +** copy of the message from the user's memory buffer to the software bus +** internal buffer. The "zero copy" interface can be used to improve +** performance in high-rate, high-volume software bus traffic. +** +** \par Assumptions, External Events, and Notes: +** -# The pointer returned by #CFE_SB_ZeroCopyGetPtr is only good for one +** call to #CFE_SB_ZeroCopySend. +** -# Applications should be written as if #CFE_SB_ZeroCopyGetPtr is +** equivalent to a \c malloc() and #CFE_SB_ZeroCopySend is equivalent to +** a \c free(). +** -# Applications must not de-reference the message pointer (for reading +** or writing) after the call to #CFE_SB_ZeroCopySend. +** +** \param[in] MsgSize The size of the SB message buffer the caller wants +** (including the SB message header). +** +** \param[out] BufferHandle A handle that must be supplied when sending or releasing +** in zero copy mode. +** +** \returns +** \retstmt A pointer to a memory buffer that can be used to build one SB message +** for use with #CFE_SB_ZeroCopySend. \endstmt +** \endreturns +** +** \sa #CFE_SB_ZeroCopyReleasePtr, #CFE_SB_ZeroCopySend +**/ +CFE_SB_Msg_t *CFE_SB_ZeroCopyGetPtr(uint16 MsgSize, + CFE_SB_ZeroCopyHandle_t *BufferHandle); + +/*****************************************************************************/ +/** +** \brief Release an unused "zero copy" buffer pointer. +** +** \par Description +** This routine can be used to release a pointer to one of the software +** bus' internal memory buffers. +** +** \par Assumptions, External Events, and Notes: +** -# This function is not needed for normal "zero copy" transfers. It +** is needed only for cleanup when an application gets a pointer using +** #CFE_SB_ZeroCopyGetPtr, but (due to some error condition) never uses +** that pointer for a #CFE_SB_ZeroCopySend +** +** \param[in] Ptr2Release A pointer to the SB internal buffer. This must be a +** pointer returned by a call to #CFE_SB_ZeroCopyGetPtr, +** but never used in a call to #CFE_SB_ZeroCopySend. +** +** \param[in] BufferHandle This must be the handle supplied with the pointer +** when #CFE_SB_ZeroCopyGetPtr was called. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_SB_BUFFER_INVALID \retdesc \copydoc CFE_SB_BUFFER_INVALID \endcode +** \endreturns +** +** \sa #CFE_SB_ZeroCopyGetPtr, #CFE_SB_ZeroCopySend +**/ +int32 CFE_SB_ZeroCopyReleasePtr(CFE_SB_Msg_t *Ptr2Release, + CFE_SB_ZeroCopyHandle_t BufferHandle); + +/*****************************************************************************/ +/** +** \brief Send an SB message in "zero copy" mode. +** +** \par Description +** This routine sends a message that has been created directly in an +** internal SB message buffer by an application (after a call to +** #CFE_SB_ZeroCopyGetPtr). This interface is more complicated than +** the normal #CFE_SB_SendMsg interface, but it avoids an extra copy of +** the message from the user's memory buffer to the software bus +** internal buffer. The "zero copy" interface can be used to improve +** performance in high-rate, high-volume software bus traffic. +** +** \par Assumptions, External Events, and Notes: +** -# The pointer returned by #CFE_SB_ZeroCopyGetPtr is only good for +** one call to #CFE_SB_ZeroCopySend. +** -# Callers must not use the same SB message buffer for multiple sends. +** -# Applications should be written as if #CFE_SB_ZeroCopyGetPtr is +** equivalent to a \c malloc() and #CFE_SB_ZeroCopySend is equivalent +** to a \c free(). +** -# Applications must not de-reference the message pointer (for reading +** or writing) after the call to #CFE_SB_ZeroCopySend. +** -# This function tracks and increments the source sequence counter +** of a telemetry message. +** +** \param[in] MsgPtr A pointer to the SB message to be sent. +** +** \param[in] BufferHandle The handle supplied with the #CFE_SB_ZeroCopyGetPtr call. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode +** \retcode #CFE_SB_MSG_TOO_BIG \retdesc \copydoc CFE_SB_MSG_TOO_BIG \endcode +** \retcode #CFE_SB_BUF_ALOC_ERR \retdesc \copydoc CFE_SB_BUF_ALOC_ERR \endcode +** \retcode #CFE_SB_BUFFER_INVALID \retdesc \copydoc CFE_SB_BUFFER_INVALID \endcode +** \endreturns +** +** \sa #CFE_SB_SendMsg, #CFE_SB_RcvMsg, #CFE_SB_ZeroCopyReleasePtr, #CFE_SB_ZeroCopyGetPtr +**/ +int32 CFE_SB_ZeroCopySend(CFE_SB_Msg_t *MsgPtr, + CFE_SB_ZeroCopyHandle_t BufferHandle); + +/*****************************************************************************/ +/** +** \brief Pass an SB message in "zero copy" mode. +** +** \par Description +** This routine sends a message that has been created directly in an +** internal SB message buffer by an application (after a call to +** #CFE_SB_ZeroCopyGetPtr). This interface is more complicated than +** the normal #CFE_SB_SendMsg interface, but it avoids an extra copy of +** the message from the user's memory buffer to the software bus +** internal buffer. The "zero copy" interface can be used to improve +** performance in high-rate, high-volume software bus traffic. This +** version is intended to pass messages not generated by the caller +** (to preserve the source sequence count). +** +** \par Assumptions, External Events, and Notes: +** -# The pointer returned by #CFE_SB_ZeroCopyGetPtr is only good for +** one call to #CFE_SB_ZeroCopySend or #CFE_SB_ZeroCopyPass. +** -# Callers must not use the same SB message buffer for multiple sends. +** -# Applications should be written as if #CFE_SB_ZeroCopyGetPtr is +** equivalent to a \c malloc() and #CFE_SB_ZeroCopyPass is equivalent +** to a \c free(). +** -# Applications must not de-reference the message pointer (for reading +** or writing) after the call to #CFE_SB_ZeroCopyPass. +** -# Unlike #CFE_SB_ZeroCopySend this routine will preserve the source +** sequence counter in a telemetry message. +** +** \param[in] MsgPtr A pointer to the SB message to be sent. +** +** \param[in] BufferHandle The handle supplied with the #CFE_SB_ZeroCopyGetPtr call. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode +** \retcode #CFE_SB_MSG_TOO_BIG \retdesc \copydoc CFE_SB_MSG_TOO_BIG \endcode +** \retcode #CFE_SB_BUF_ALOC_ERR \retdesc \copydoc CFE_SB_BUF_ALOC_ERR \endcode +** \retcode #CFE_SB_BUFFER_INVALID \retdesc \copydoc CFE_SB_BUFFER_INVALID \endcode +** \endreturns +** +** \sa #CFE_SB_PassMsg, #CFE_SB_ZeroCopySend, #CFE_SB_ZeroCopyReleasePtr, #CFE_SB_ZeroCopyGetPtr +**/ +int32 CFE_SB_ZeroCopyPass(CFE_SB_Msg_t *MsgPtr, + CFE_SB_ZeroCopyHandle_t BufferHandle); + + +/*****************************************************************************/ +/** +** \brief Initialize a buffer for a software bus message. +** +** \par Description +** This routine fills in the header information needed to create a +** valid software bus message. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MsgPtr A pointer to the buffer that will contain the message. +** This will point to the first byte of the message header. +** The \c void* data type allows the calling routine to use +** any data type when declaring its message buffer. +** +** \param[in] MsgId The message ID to put in the message header. +** +** \param[in] Length The total number of bytes of message data, including the SB +** message header . +** +** \param[in] Clear A flag indicating whether to clear the rest of the message: +** \arg TRUE - fill sequence count and packet data with zeroes. +** \arg FALSE - leave sequence count and packet data unchanged. +** +** \sa #CFE_SB_SetMsgId, #CFE_SB_SetUserDataLength, #CFE_SB_SetTotalMsgLength, +** #CFE_SB_SetMsgTime, #CFE_SB_TimeStampMsg, #CFE_SB_SetCmdCode +**/ +void CFE_SB_InitMsg(void *MsgPtr, + CFE_SB_MsgId_t MsgId, + uint16 Length, + boolean Clear ); + +/*****************************************************************************/ +/** +** \brief Get the size of a software bus message header. +** +** \par Description +** This routine returns the number of bytes in a software bus message header. +** This can be used for sizing buffers that need to store SB messages. SB +** message header formats can be different for each deployment of the cFE. +** So, applications should use this function and avoid hard coding their buffer +** sizes. +** +** \par Assumptions, External Events, and Notes: +** - For statically defined messages, a function call will not work. The +** macros #CFE_SB_CMD_HDR_SIZE and #CFE_SB_TLM_HDR_SIZE are available for use +** in static message buffer sizing or structure definitions. +** +** \param[in] MsgId The message ID to calculate header size for. The size of the message +** header may depend on the MsgId in some implementations. For example, +** if SB messages are implemented as CCSDS packets, the size of the header +** is different for command vs. telemetry packets. +** +** \returns +** \retstmt The number of bytes in the software bus message header for +** messages with the given \c MsgId. endstmt +** \endreturns +** +** \sa #CFE_SB_GetUserData, #CFE_SB_GetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_GetTotalMsgLength, +** #CFE_SB_GetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum +**/ +uint16 CFE_SB_MsgHdrSize(CFE_SB_MsgId_t MsgId); + +/*****************************************************************************/ +/** +** \brief Get a pointer to the user data portion of a software bus message. +** +** \par Description +** This routine returns a pointer to the user data portion of a software +** bus message. SB message header formats can be different for each +** deployment of the cFE. So, applications should use this function and +** avoid hard coding offsets into their SB message buffers. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** +** \returns +** \retstmt A pointer to the first byte of user data within the software bus message. \endstmt +** \endreturns +** +** \sa #CFE_SB_GetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_GetTotalMsgLength, +** #CFE_SB_GetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum, #CFE_SB_MsgHdrSize +**/ +void *CFE_SB_GetUserData(CFE_SB_MsgPtr_t MsgPtr); + +/*****************************************************************************/ +/** +** \brief Get the message ID of a software bus message. +** +** \par Description +** This routine returns the message ID from a software bus message. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** +** \returns +** \retstmt The software bus Message ID from the message header. \endstmt +** \endreturns +** +** \sa #CFE_SB_GetUserData, #CFE_SB_SetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_GetTotalMsgLength, +** #CFE_SB_GetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum, #CFE_SB_MsgHdrSize +**/ +CFE_SB_MsgId_t CFE_SB_GetMsgId(CFE_SB_MsgPtr_t MsgPtr); + +/*****************************************************************************/ +/** +** \brief Sets the message ID of a software bus message. +** +** \par Description +** This routine sets the Message ID in a software bus message header. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \param[in] MsgId The message ID to put into the message header. +** +** \returns +** \retstmt The software bus Message ID from the message header. \endstmt +** \endreturns +** +** \sa #CFE_SB_GetMsgId, #CFE_SB_SetUserDataLength, #CFE_SB_SetTotalMsgLength, +** #CFE_SB_SetMsgTime, #CFE_SB_TimeStampMsg, #CFE_SB_SetCmdCode, #CFE_SB_InitMsg +**/ +void CFE_SB_SetMsgId(CFE_SB_MsgPtr_t MsgPtr, + CFE_SB_MsgId_t MsgId); + +/*****************************************************************************/ +/** +** \brief Gets the length of user data in a software bus message. +** +** \par Description +** This routine returns the size of the user data in a software bus message. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \returns +** \retstmt The size (in bytes) of the user data in the software bus message. \endstmt +** \endreturns +** +** \sa #CFE_SB_GetUserData, #CFE_SB_GetMsgId, #CFE_SB_SetUserDataLength, #CFE_SB_GetTotalMsgLength, +** #CFE_SB_GetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum, #CFE_SB_MsgHdrSize +**/ +uint16 CFE_SB_GetUserDataLength(CFE_SB_MsgPtr_t MsgPtr); + +/*****************************************************************************/ +/** +** \brief Sets the length of user data in a software bus message. +** +** \par Description +** This routine sets the field in the SB message header that determines +** the size of the user data in a software bus message. SB message header +** formats can be different for each deployment of the cFE. So, applications +** should use this function rather than trying to poke a length value directly +** into their SB message buffers. +** +** \par Assumptions, External Events, and Notes: +** - You must set a valid message ID in the SB message header before +** calling this function. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \param[in] DataLength The length to set (size of the user data, in bytes). +** +** +** \sa #CFE_SB_SetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_SetTotalMsgLength, +** #CFE_SB_SetMsgTime, #CFE_SB_TimeStampMsg, #CFE_SB_SetCmdCode, #CFE_SB_InitMsg +**/ +void CFE_SB_SetUserDataLength(CFE_SB_MsgPtr_t MsgPtr,uint16 DataLength); + +/*****************************************************************************/ +/** +** \brief Gets the total length of a software bus message. +** +** \par Description +** This routine returns the total size of the software bus message. +** +** \par Assumptions, External Events, and Notes: +** - For the CCSDS implementation of this API, the size is derived from +** the message header. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \returns +** \retstmt The total size (in bytes) of the software bus message, including headers. \endstmt +** \endreturns +** +** \sa #CFE_SB_GetUserData, #CFE_SB_GetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_SetTotalMsgLength, +** #CFE_SB_GetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum, #CFE_SB_MsgHdrSize +**/ +uint16 CFE_SB_GetTotalMsgLength(CFE_SB_MsgPtr_t MsgPtr); + +/*****************************************************************************/ +/** +** \brief Sets the total length of a software bus message. +** +** \par Description +** This routine sets the field in the SB message header that determines +** the total length of the message. SB message header formats can be +** different for each deployment of the cFE. So, applications should +** use this function rather than trying to poke a length value directly +** into their SB message buffers. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \param[in] TotalLength The length to set (total size of the message, in bytes, +** including headers). +** +** \sa #CFE_SB_SetMsgId, #CFE_SB_SetUserDataLength, #CFE_SB_GetTotalMsgLength, +** #CFE_SB_SetMsgTime, #CFE_SB_TimeStampMsg, #CFE_SB_SetCmdCode, #CFE_SB_InitMsg +**/ +void CFE_SB_SetTotalMsgLength(CFE_SB_MsgPtr_t MsgPtr,uint16 TotalLength); + +/*****************************************************************************/ +/** +** \brief Gets the time field from a software bus message. +** +** \par Description +** This routine gets the time from a software bus message. +** +** \par Assumptions, External Events, and Notes: +** - If the underlying implementation of software bus messages does not +** include a time field, then this routine will return a zero time. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** \returns +** \retstmt The system time included in the software bus message header (if present), +** otherwise, returns a time value of zero. \endstmt +** \endreturns +** +** \sa #CFE_SB_GetUserData, #CFE_SB_GetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_GetTotalMsgLength, +** #CFE_SB_SetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum, #CFE_SB_MsgHdrSize +**/ +CFE_TIME_SysTime_t CFE_SB_GetMsgTime(CFE_SB_MsgPtr_t MsgPtr); + +/*****************************************************************************/ +/** +** \brief Sets the time field in a software bus message. +** +** \par Description +** This routine sets the time of a software bus message. Most applications +** will want to use #CFE_SB_TimeStampMsg instead of this function. But, +** when needed, #CFE_SB_SetMsgTime can be used to send a group of SB messages +** with identical time stamps. +** +** \par Assumptions, External Events, and Notes: +** - If the underlying implementation of software bus messages does not include +** a time field, then this routine will do nothing to the message contents +** and will return #CFE_SB_WRONG_MSG_TYPE. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \param[in] Time The time to include in the message. This will usually be a time +** returned by the function #CFE_TIME_GetTime(). +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_SB_WRONG_MSG_TYPE \retdesc \copydoc CFE_SB_WRONG_MSG_TYPE \endcode +** \endreturns +** +** \sa #CFE_SB_SetMsgId, #CFE_SB_SetUserDataLength, #CFE_SB_SetTotalMsgLength, +** #CFE_SB_GetMsgTime, #CFE_SB_TimeStampMsg, #CFE_SB_SetCmdCode, #CFE_SB_InitMsg +**/ +int32 CFE_SB_SetMsgTime(CFE_SB_MsgPtr_t MsgPtr, + CFE_TIME_SysTime_t Time); + +/*****************************************************************************/ +/** +** \brief Sets the time field in a software bus message with the current spacecraft time. +** +** \par Description +** This routine sets the time of a software bus message with the current +** spacecraft time. This will be the same time that is returned by the +** function #CFE_TIME_GetTime. +** +** \par Assumptions, External Events, and Notes: +** - If the underlying implementation of software bus messages does not +** include a time field, then this routine will do nothing. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \sa #CFE_SB_SetMsgId, #CFE_SB_SetUserDataLength, #CFE_SB_SetTotalMsgLength, +** #CFE_SB_SetMsgTime, #CFE_SB_SetCmdCode, #CFE_SB_InitMsg +**/ +void CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr); + +/*****************************************************************************/ +/** +** \brief Gets the command code field from a software bus message. +** +** \par Description +** This routine gets the command code from a software bus message (if +** SB messages are implemented as CCSDS packets, this will be the function +** code). +** +** \par Assumptions, External Events, and Notes: +** - If the underlying implementation of software bus messages does not +** include a command code field, then this routine will return a zero. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \returns +** \retstmt The command code included in the software bus message header (if present). +** Otherwise, returns a command code value of zero. \endstmt +** \endreturns +** +** \sa #CFE_SB_GetUserData, #CFE_SB_GetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_GetTotalMsgLength, +** #CFE_SB_GetMsgTime, #CFE_SB_SetCmdCode, #CFE_SB_GetChecksum, #CFE_SB_MsgHdrSize +**/ +uint16 CFE_SB_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr); + +/*****************************************************************************/ +/** +** \brief Sets the command code field in a software bus message. +** +** \par Description +** This routine sets the command code of a software bus message (if SB +** messages are implemented as CCSDS packets, this will be the function code). +** +** \par Assumptions, External Events, and Notes: +** - If the underlying implementation of software bus messages does not +** include a command code field, then this routine will do nothing to +** the message contents and will return #CFE_SB_WRONG_MSG_TYPE. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \param[in] CmdCode The command code to include in the message. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_SB_WRONG_MSG_TYPE \retdesc \copydoc CFE_SB_WRONG_MSG_TYPE \endcode +** \endreturns +** +** \sa #CFE_SB_SetMsgId, #CFE_SB_SetUserDataLength, #CFE_SB_SetTotalMsgLength, +** #CFE_SB_SetMsgTime, #CFE_SB_TimeStampMsg, #CFE_SB_GetCmdCode, #CFE_SB_InitMsg +**/ +int32 CFE_SB_SetCmdCode(CFE_SB_MsgPtr_t MsgPtr, + uint16 CmdCode); + +/*****************************************************************************/ +/** +** \brief Gets the checksum field from a software bus message. +** +** \par Description +** This routine gets the checksum (or other message integrity check +** value) from a software bus message. The contents and location of +** this field will depend on the underlying implementation of software +** bus messages. It may be a checksum, a CRC, or some other algorithm. +** Users should not call this function as part of a message integrity +** check (call #CFE_SB_ValidateChecksum instead). +** +** \par Assumptions, External Events, and Notes: +** - If the underlying implementation of software bus messages does not +** include a checksum field, then this routine will return a zero. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \returns +** \retstmt The checksum included in the software bus message header (if present), otherwise, +** returns a checksum value of zero. \endstmt +** \endreturns +** +** \sa #CFE_SB_GetUserData, #CFE_SB_GetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_GetTotalMsgLength, +** #CFE_SB_GetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum, #CFE_SB_MsgHdrSize, +** #CFE_SB_ValidateChecksum, #CFE_SB_GenerateChecksum +**/ +uint16 CFE_SB_GetChecksum(CFE_SB_MsgPtr_t MsgPtr); + +/*****************************************************************************/ +/** +** \brief Calculates and sets the checksum of a software bus message +** +** \par Description +** This routine calculates the checksum of a software bus message according +** to an implementation-defined algorithm. Then, it sets the checksum field +** in the message with the calculated value. The contents and location of +** this field will depend on the underlying implementation of software bus +** messages. It may be a checksum, a CRC, or some other algorithm. +** +** \par Assumptions, External Events, and Notes: +** - If the underlying implementation of software bus messages does not +** include a checksum field, then this routine will do nothing. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \sa #CFE_SB_ValidateChecksum, #CFE_SB_GetChecksum +**/ +void CFE_SB_GenerateChecksum(CFE_SB_MsgPtr_t MsgPtr); + +/*****************************************************************************/ +/** +** \brief Validates the checksum of a software bus message. +** +** \par Description +** This routine calculates the expected checksum of a software bus message +** according to an implementation-defined algorithm. Then, it checks the +** calculated value against the value in the message's checksum. If the +** checksums do not match, this routine will generate an event message +** reporting the error. +** +** \par Assumptions, External Events, and Notes: +** - If the underlying implementation of software bus messages does not +** include a checksum field, then this routine will always return \c TRUE. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \returns +** \retcode TRUE \retdesc The checksum field in the packet is valid. \endcode +** \retcode FALSE \retdesc The checksum field in the packet is not valid or the message type is wrong. \endcode +** \endreturns +** +** \sa #CFE_SB_GenerateChecksum, #CFE_SB_GetChecksum +**/ +boolean CFE_SB_ValidateChecksum(CFE_SB_MsgPtr_t MsgPtr); + +/****************************************************************************** +** Function: CFE_SB_MessageStringGet() +** +** Purpose: +** Copies a string out of a software bus message +** +** Strings within software bus messages have a defined/fixed maximum length, and +** may not necessarily be null terminated within the message. This presents a possible +** issue when using the C library functions to copy strings out of a message. +** +** This function should replace use of C library functions such as strcpy/strncpy +** when copying strings out of software bus messages to local storage buffers. +** +** Up to [SourceMaxSize] or [DestMaxSize-1] (whichever is smaller) characters will be +** coped from the source buffer to the destination buffer, and a NUL termination +** character will be written to the destination buffer as the last character. +** +** If the DefaultString pointer is non-NULL, it will be used in place of the source +** string if the source is an empty string. This is typically a string constant that +** comes from the platform configuration, allowing default values to be assumed for +** fields that are unspecified. +** +** IMPORTANT - the default string, if specified, must be null terminated. This will +** be the case if a string literal is passed in (the typical/expected use case). +** +** If the default is NULL, then only the source string will be copied, and the result +** will be an empty string if the source was empty. +** +** If the destination buffer is too small to store the entire string, it will be +** truncated, but it will still be null terminated. +** +** Arguments: +** DestStringPtr - pointer to destination buffer +** SourceStringPtr - pointer to source buffer (component of SB message definition) +** DefaultString - alternative string to use if the source is an empty string +** DestMaxSize - size of the destination storage buffer (must be at least 2) +** SourceMaxSize - size of the source buffer as defined by the message definition +** +** Returns: +** Length of result - number of characters copied, not including the terminating NUL. +** This should match the value that would be returned by "strlen(DestStringPtr)" +** +*/ +int32 CFE_SB_MessageStringGet(char *DestStringPtr, const char *SourceStringPtr, const char *DefaultString, uint32 DestMaxSize, uint32 SourceMaxSize); + +/****************************************************************************** +** Function: CFE_SB_MessageStringSet() +** +** Purpose: +** Copies a string into a software bus message +** +** Strings within software bus messages have a defined/fixed maximum length, and +** may not necessarily be null terminated within the message. This presents a possible +** issue when using the C library functions to copy strings out of a message. +** +** This performs a very similar function to "strncpy()" except that the sizes +** of _both_ buffers are passed in. Neither buffer is required to be null-terminated, +** but copying will stop after the first termination character is encountered. +** +** If the destination buffer is not completely filled by the source data (such as if +** the supplied string was shorter than the allotted length) the destination buffer +** will be padded with NUL characters up to the size of the buffer, similar to what +** strncpy() does. This ensures that the entire destination buffer is set. +** +** NOTE - if the source string buffer is already guaranteed to be null terminated, +** then there is no difference between the C library "strncpy()" function and this +** implementation. It is only necessary to use this when termination of the source +** buffer is not guaranteed. +** +** Arguments: +** DestStringPtr - pointer to destination buffer +** SourceStringPtr - pointer to source buffer (component of SB message definition) +** DestMaxSize - size of the destination storage buffer (must be at least 2) +** SourceMaxSize - size of the source buffer as defined by the message definition +** +** Returns: +** Length of result - number of actual data characters copied +** This should match the value that would be returned by "strlen(DestStringPtr)" +** +*/ +int32 CFE_SB_MessageStringSet(char *DestStringPtr, const char *SourceStringPtr, uint32 DestMaxSize, uint32 SourceMaxSize); + + +#endif /* _cfesb_ */ +/*****************************************************************************/ diff --git a/src/components/interface/cFE/cfe_sb_events.h b/src/components/interface/cFE/cfe_sb_events.h new file mode 100644 index 0000000000..e7b0d72b21 --- /dev/null +++ b/src/components/interface/cFE/cfe_sb_events.h @@ -0,0 +1,798 @@ +/* +** File: cfe_sb_events.h +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** +** Purpose: +** cFE Software Bus (SB) Event IDs +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** cFE Flight Software Application Developers Guide +** +** +** $Log: cfe_sb_events.h $ +** Revision 1.7 2011/12/20 10:52:41GMT-05:00 rmcgraw +** DCR15187:2 Removed event CFE_SB_MSGCNT_ERR1_EID (23) +** Revision 1.6 2009/05/08 11:29:10EDT rmcgraw +** DCR7631:1 Removed 2 events rergarding index error and renumbered events +** Revision 1.5 2009/02/10 11:24:46EST rmcgraw +** DCR1699:1 Removed pipe owner in five events +** Revision 1.4 2009/02/03 11:03:45EST rmcgraw +** DCR5801:2 Added event CFE_SB_DEST_BLK_ERR_EID +** Revision 1.3 2009/01/23 15:00:06EST rmcgraw +** DCR5802:1 Removed redundant events in cfe_sb_buf.c +** Revision 1.2 2008/12/08 12:07:07EST dkobe +** Updates to correct doxygen errors +** Revision 1.1 2008/04/17 08:05:23EDT ruperera +** Initial revision +** Member added to cfe project on tlserver3 +** Revision 1.21 2007/09/19 14:37:06EDT rjmcgraw +** Removed Use Count Error events 1 and 4 +** Revision 1.20 2007/07/12 16:46:22EDT rjmcgraw +** DCR4680:1 Removed events associated with SB event log +** Revision 1.19 2007/07/06 13:16:38EDT rjmcgraw +** DCR469:1 Added 3 events for new GetLastSender code +** Revision 1.18 2007/06/02 10:10:10EDT dlkobe +** Added doxygen comments for User's Guides +** Revision 1.17 2007/05/25 16:24:48EDT dlkobe +** Continued updating doxygen comments +** Revision 1.16 2007/05/25 15:59:30EDT rjmcgraw +** Added comments to events +** Revision 1.15 2007/03/23 09:50:16EST rjmcgraw +** DCR3217 Removed event 29 +** Revision 1.14 2007/03/19 14:46:00EST rjmcgraw +** Removed #define for create pipe duplicate name event id +** Revision 1.13 2007/03/16 15:30:36EST rjmcgraw +** New event for duplicate pipe name check +** Revision 1.12 2007/03/16 14:09:04EST rjmcgraw +** Added new event for array index out of range in subscribe +** Revision 1.11 2007/03/16 09:57:54EST rjmcgraw +** Added new events related to pipe owner checks +** +**************************************************************************/ +#ifndef _cfe_sb_events_ +#define _cfe_sb_events_ + +/* +** SB task event message ID's. +*/ +/* +** Event ID's +*/ + +/** \brief 'cFE SB Initialized' +** \event 'cFE SB Initialized' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is issued when the Software Bus Task completes its +** initialization. +**/ +#define CFE_SB_INIT_EID 1 + +/** \brief 'CreatePipeErr:Bad Input Arg:app=\%s,ptr=0x\%x,depth=\%d,maxdepth=\%d' +** \event 'CreatePipeErr:Bad Input Arg:app=\%s,ptr=0x\%x,depth=\%d,maxdepth=\%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the #CFE_SB_CreatePipe API receives a bad +** argument. In this case, a bad argument is defined by the following: +** A NULL PipeIdPtr, PipeDepth = 0 and PipeDepth > cfg param #CFE_SB_MAX_PIPE_DEPTH +**/ +#define CFE_SB_CR_PIPE_BAD_ARG_EID 2 + +/** \brief 'CreatePipeErr:Max Pipes(\%d)In Use.app \%s' +** \event 'CreatePipeErr:Max Pipes(\%d)In Use.app \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the #CFE_SB_CreatePipe API is called and +** the maximum number of pipes (defined by cfg param #CFE_SB_MAX_PIPES) are in use. +**/ +#define CFE_SB_MAX_PIPES_MET_EID 3 + + +/** \brief 'CreatePipeErr:OS_QueueCreate returned \%d,app \%s' +** \event 'CreatePipeErr:OS_QueueCreate returned \%d,app \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the #CFE_SB_CreatePipe API is called and +** the OS returns an error when the OS returns an error from the OS_QueueCreate API. +** The error status returned by the OS is displayed in the event. Most commonly, +** this event is displayed as a result of trying to create pipes with the same name. +**/ +#define CFE_SB_CR_PIPE_ERR_EID 4 + +/** \brief 'Pipe Created:name \%s,id \%d,app \%s' +** \event 'Pipe Created:name \%s,id \%d,app \%s' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This debug event message is issued when a pipe was successfully created in the +** #CFE_SB_CreatePipe API. +**/ +#define CFE_SB_PIPE_ADDED_EID 5 + + +/** \brief 'Subscribe Err:Bad Arg,MsgId 0x\%x,PipeId \%d,app \%s,scope \%d' +** \event 'Subscribe Err:Bad Arg,MsgId 0x\%x,PipeId \%d,app \%s,scope \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when one of the Subscribe API's are called +** with an invalid MsgId. An invalid MsgId is defined as being greater than the +** cfg param #CFE_SB_HIGHEST_VALID_MSGID. +** +**/ +#define CFE_SB_SUB_ARG_ERR_EID 6 + +/** \brief 'Duplicate Subscription,MsgId 0x\%x on \%s pipe,app \%s' +** \event 'Duplicate Subscription,MsgId 0x\%x on \%s pipe,app \%s' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This info event message is issued when a subscription request is received that +** already exists in the routing table. A duplicate subscription is defined by a +** matching MsgId and PipeId. No other parameters are used in detecting a duplicate +** subscription. +** NOTE: By default, SB filters this event. The EVS filter algorithm allows the +** first event to pass through the filter, but all subsequent events with this +** event id will be filtered. A command must be sent to unfilter this event if +** the user desires to see it. +**/ +#define CFE_SB_DUP_SUBSCRIP_EID 7 + +/** \brief 'Subscribe Err:Max Msgs(\%d)In Use,MsgId 0x\%x,pipe \%s,app \%s' +** \event 'Subscribe Err:Max Msgs(\%d)In Use,MsgId 0x\%x,pipe \%s,app \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when one of the SB subscribe APIs are called +** with a new MsgId, and SB cannot accommodate the new MsgId because the maximum +** number of MsgIds are in use. The maximum number of MsgIds is defined by cfg param +** #CFE_SB_MAX_MSG_IDS. This cfg param dictates the number of elements in the SB +** routing table. There is one element per MsgId. The user may monitor the routing +** table utilization figures (msgids currently in use, high water mark and max +** allowed) by sending the SB cmd to dump the SB statistics data. +**/ +#define CFE_SB_MAX_MSGS_MET_EID 8 + +/** \brief 'Subscribe Err:Max Dests(\%d)In Use For Msg 0x\%x,pipe \%s,app \%s' +** \event 'Subscribe Err:Max Dests(\%d)In Use For Msg 0x\%x,pipe \%s,app \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when a subscription request is received and +** all destinations for that MsgId are in use. The number of destinations per msgid +** is a configuration parameter named #CFE_SB_MAX_DEST_PER_PKT. A destination is +** defined as a pipe. +**/ +#define CFE_SB_MAX_DESTS_MET_EID 9 + +/** \brief 'Subscription Rcvd:MsgId 0x\%x on \%s(\%d),app \%s' +** \event 'Subscription Rcvd:MsgId 0x\%x on \%s(\%d),app \%s' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This debug event message is issued when a subscription is successfully made +** through one of the SB Subscribe API's +**/ +#define CFE_SB_SUBSCRIPTION_RCVD_EID 10 + +/** \brief 'UnSubscribe Err:Bad Arg,MsgId 0x\%x,PipeId \%d,app \%s,scope \%d' +** \event 'UnSubscribe Err:Bad Arg,MsgId 0x\%x,PipeId \%d,app \%s,scope \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when a request to unsubscribe fails due to +** an invalid msgid or an invalid pipeid in one of SB's unsubscribe API's. The msgid +** must be less than cfg param #CFE_SB_HIGHEST_VALID_MSGID and the pipeid must have +** been created and have a value less than cfg param #CFE_SB_MAX_PIPES. The SB pipe +** table may be viewed to verify its value or existence. +**/ +#define CFE_SB_UNSUB_ARG_ERR_EID 11 + +/** \brief 'Unsubscribe Err:No subs for Msg 0x\%x on \%s,app \%s' +** \event 'Unsubscribe Err:No subs for Msg 0x\%x on \%s,app \%s' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This info event message is issued when a request to unsubscribe fails due to +** a non existent msgid/pipeid combination in the SB routing table. The SB routing +** table may be viewed to see a list of valid msgid/pipeid combinations. +**/ +#define CFE_SB_UNSUB_NO_SUBS_EID 12 + +/** \brief 'Send Err:Bad input argument,Arg 0x\%x,App \%s' +** \event 'Send Err:Bad input argument,Arg 0x\%x,App \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the #CFE_SB_SendMsg API receives an +** invalid (possibly NULL) ptr as an argument. +**/ +#define CFE_SB_SEND_BAD_ARG_EID 13 + +/** \brief 'No subscribers for MsgId 0x\%x,sender \%s' +** \event 'No subscribers for MsgId 0x\%x,sender \%s' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This info event message is issued when the #CFE_SB_SendMsg API is called and there +** are no subscribers (therefore no destinations) for the message to be sent. Each +** time the SB detects this situation, the corresponding SB telemetry point is +** incremented.. +** NOTE: By default, SB filters this event. The EVS filter algorithm allows the +** first event to pass through the filter, but all subsequent events with this +** event id will be filtered. A command must be sent to unfilter this event if +** the user desires to see it. +**/ +#define CFE_SB_SEND_NO_SUBS_EID 14 + +/** \brief 'Send Err:Msg Too Big MsgId=0x\%x,app=\%s,size=\%d,MaxSz=\%d' +** \event 'Send Err:Msg Too Big MsgId=0x\%x,app=\%s,size=\%d,MaxSz=\%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the #CFE_SB_SendMsg API is called and the +** packet length field in the message header implies that the message size exceeds +** the max size defined by mission cfg param #CFE_SB_MAX_SB_MSG_SIZE. The request to +** send the message is denied, there is no partial packet sent. +**/ +#define CFE_SB_MSG_TOO_BIG_EID 15 + +/** \brief 'Send Err:Request for Buffer Failed. MsgId 0x\%x,app \%s,size \%d' +** \event 'Send Err:Request for Buffer Failed. MsgId 0x\%x,app \%s,size \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the #CFE_SB_SendMsg API fails to receive +** the necessary buffer memory from the ES memory pool. This could be an indication +** that the cfg param #CFE_SB_BUF_MEMORY_BYTES is set too low. To check this, send SB +** cmd to dump the SB statistics pkt and view the buffer memory parameters. +**/ +#define CFE_SB_GET_BUF_ERR_EID 16 + +/** \brief 'Send Err:Msg Limit Err MsgId 0x\%x,pipe \%s,sender \%s' +** \event 'Send Err:Msg Limit Err MsgId 0x\%x,pipe \%s,sender \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the #CFE_SB_SendMsg API cannot route the +** MsgId (displayed in event) to the pipe (displayed in the event) because the pipe +** currently contains the maximum number of messages of this type (MsgId). This is +** typically an indication that the receiver is not reading its pipe fast enough, or +** at all. A less typical scenerio is that the sender is sending a burst of pkts of +** this type (or MsgId) and the receiver (owner of 'pipe') cannot keep up. The +** subscriber of the message dictates this limit count in the 'MsgLim' parameter of +** the #CFE_SB_SubscribeEx API or uses the default value of 4 if using the +** #CFE_SB_Subscribe API. +**/ +#define CFE_SB_MSGID_LIM_ERR_EID 17 + +/** \brief 'Rcv Err:Bad Input Arg:BufPtr 0x\%x,pipe \%d,t/o \%d,app \%s' +** \event 'Rcv Err:Bad Input Arg:BufPtr 0x\%x,pipe \%d,t/o \%d,app \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when an invalid paramter is passed into the +** #CFE_SB_RcvMsg API. Two possibile problems would be the first parameter (*BufPtr) +** being NULL or the third paramter (TimeOut) being less than -1. +**/ +#define CFE_SB_RCV_BAD_ARG_EID 18 + +/** \brief 'Rcv Err:PipeId \%d does not exist,app \%s' +** \event 'Rcv Err:PipeId \%d does not exist,app \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when an invalid PipeId is passed into the +** #CFE_SB_RcvMsg API. The SB Pipe Table shows all valid PipeIds and may be viewed +** for verification. +**/ +#define CFE_SB_BAD_PIPEID_EID 19 + + +/** \brief 'Subscribe Err:Request for Destination Blk failed for Msg 0x\%x,Pipe \%s' +** \event 'Subscribe Err:Request for Destination Blk failed for Msg 0x\%x,Pipe \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the SB receives an error from the memory +** pool in the attempt to obtain a new destination block. Then memory pool statistics +** may be viewed by sending the related ES command. +**/ +#define CFE_SB_DEST_BLK_ERR_EID 20 + + +/** \brief 'Send Err:Invalid msgid in msg,MsgId 0x\%x,App \%s' +** \event 'Send Err:Invalid msgid in msg,MsgId 0x\%x,App \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the #CFE_SB_SendMsg API is called and +** the SB discovers that the message to send has a msg id that is invalid. It may be +** due to a msg id that is greater than cfg parameter #CFE_SB_HIGHEST_VALID_MSGID +**/ +#define CFE_SB_SEND_INV_MSGID_EID 21 + +/** \brief 'Sending Subscription Report Msg=0x\%x,Pipe=\%d,Stat=0x\%x' +** \event 'Sending Subscription Report Msg=0x\%x,Pipe=\%d,Stat=0x\%x' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This debug event message is issued when SB subscription reporting is enabled, +** (which is disabled by default) and a subscription is successfully received. +**/ +#define CFE_SB_SUBSCRIPTION_RPT_EID 22 + + +/** \brief 'Sending Unsubscription Report Msg=0x\%x,Pipe=\%d,Stat=0x\%x' +** \event 'Sending Unsubscription Report Msg=0x\%x,Pipe=\%d,Stat=0x\%x' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This debug event message is issued when SB subscription reporting is enabled, +** (which is disabled by default) and a subscription is successfully received. +**/ +#define CFE_SB_UNSUBSCRIPTION_RPT_EID 24 + + +/** \brief 'Pipe Overflow,MsgId 0x\%x,pipe \%s,stat 0x\%x,app \%s' +** \event 'Pipe Overflow,MsgId 0x\%x,pipe \%s,stat 0x\%x,app \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the #CFE_SB_SendMsg API is called and +** encounters an error when attempting to write the msg to the destination pipe +** (which is an underlying queue). This could indicate that the owner of the pipe is +** not readings its messages fast enough or at all. It may also mean that the +** pipe depth is not deep enough. The pipe depth is an input parameter to the +** #CFE_SB_CreatePipe API. +**/ +#define CFE_SB_Q_FULL_ERR_EID 25 + +/** \brief 'Pipe Write Err,MsgId 0x\%x,pipe \%s,stat 0x\%x,app \%s' +** \event 'Pipe Write Err,MsgId 0x\%x,pipe \%s,stat 0x\%x,app \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the #CFE_SB_SendMsg API is called and +** encounters an error when attempting to write the msg to the destination pipe +** (which is an underlying queue). More precisely, the OS API #OS_QueuePut has +** returned an unexpected error. The return code is displayed in the event. For +** more information, the user may look up the return code in the OSAL documention or +** source code. +**/ +#define CFE_SB_Q_WR_ERR_EID 26 + +/** \brief 'Pipe Read Err,pipe \%s,app \%s,stat 0x\%x' +** \event 'Pipe Read Err,pipe \%s,app \%s,stat 0x\%x' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the #CFE_SB_SendMsg API is called and +** encounters an error when attempting to read the msg from the destination pipe +** (which is an underlying queue). More precisely, the OS API #OS_QueueGet has +** returned an unexpected error. The return code is displayed in the event. For +** more information, the user may look up the return code in the OSAL documention or +** source code. +**/ +#define CFE_SB_Q_RD_ERR_EID 27 + +/** \brief 'No-op Cmd Rcvd' +** \event 'No-op Cmd Rcvd' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This info event message is issued in response an SB NO-OP command +**/ +#define CFE_SB_CMD0_RCVD_EID 28 + +/** \brief 'Reset Counters Cmd Rcvd' +** \event 'Reset Counters Cmd Rcvd' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This debug event message is issued in response an SB Reset Counters command +**/ +#define CFE_SB_CMD1_RCVD_EID 29 + + +/** \brief 'SB GetLastSender Err:Rcvd Null Ptr,Pipe=%d,App=%s' +** \event 'SB GetLastSender Err:Rcvd Null Ptr,Pipe=%d,App=%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when SB receives a Null pointer from the +** caller of CFE_SB_GetLastSenderId. +**/ +#define CFE_SB_LSTSNDER_ERR1_EID 30 + +/** \brief 'SB GetLastSender Err:Rcvd Invalid Pipe=%d,App=%s' +** \event 'SB GetLastSender Err:Rcvd Invalid Pipe=%d,App=%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when SB receives an invalid pipe from the +** caller of CFE_SB_GetLastSenderId. +**/ +#define CFE_SB_LSTSNDER_ERR2_EID 31 + + +/** \brief 'Software Bus Statistics packet sent' +** \event 'Software Bus Statistics packet sent' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This debug event message is issued when SB receives a cmd to send the SB +** statistics pkt. +**/ +#define CFE_SB_SND_STATS_EID 32 + +/** \brief 'Enbl Route Cmd:Route does not exist.Msg 0x\%x,Pipe \%d' +** \event 'Enbl Route Cmd:Route does not exist.Msg 0x\%x,Pipe \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when SB receives a cmd to enable a route that +** does not exist in the routing table. A route is defined by a MsgId, PipeId pair. +**/ +#define CFE_SB_ENBL_RTE1_EID 33 + +/** \brief 'Enabling Route,Msg 0x\%x,Pipe \%d' +** \event 'Enabling Route,Msg 0x\%x,Pipe \%d' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This debug event message is issued when SB receives a cmd to enable a route and +** the request is successfully executed. +**/ +#define CFE_SB_ENBL_RTE2_EID 34 + +/** \brief 'Enbl Route Cmd:Invalid Param.Msg 0x\%x,Pipe \%d' +** \event 'Enbl Route Cmd:Invalid Param.Msg 0x\%x,Pipe \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when SB receives a cmd to enable a route and +** the MsgId or PipeId does not pass the validation checks. The MsgId must be less +** than cfg param #CFE_SB_HIGHEST_VALID_MSGID. The PipeId must exist and be less than +** cfg param #CFE_SB_MAX_PIPES. The SB pipe table may be viewed to verify the PipeId +** existence. +**/ +#define CFE_SB_ENBL_RTE3_EID 35 + +/** \brief 'Disable Route Cmd:Route does not exist,Msg 0x\%x,Pipe \%d' +** \event 'Disable Route Cmd:Route does not exist,Msg 0x\%x,Pipe \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when SB receives a cmd to disable a route that +** does not exist in the routing table. A route is defined by a MsgId, PipeId pair. +**/ +#define CFE_SB_DSBL_RTE1_EID 36 + +/** \brief 'Route Disabled,Msg 0x\%x,Pipe \%d' +** \event 'Route Disabled,Msg 0x\%x,Pipe \%d' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This debug event message is issued when SB receives a cmd to disable a route and +** the request is successfully executed. +**/ +#define CFE_SB_DSBL_RTE2_EID 37 + +/** \brief 'Disable Route Cmd:Invalid Param.Msg 0x\%x,Pipe \%d' +** \event 'Disable Route Cmd:Invalid Param.Msg 0x\%x,Pipe \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when SB receives a cmd to disable a route and +** the MsgId or PipeId does not pass the validation checks. The MsgId must be less +** than cfg param #CFE_SB_HIGHEST_VALID_MSGID. The PipeId must exist and be less than +** cfg param #CFE_SB_MAX_PIPES. The SB pipe table may be viewed to verify the PipeId +** existence. +**/ +#define CFE_SB_DSBL_RTE3_EID 38 + +/** \brief '\%s written:Size=\%d,Entries=\%d' +** \event '\%s written:Size=\%d,Entries=\%d' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This debug event message is issued after the SB routing info file, pipe info +** file or the map info file is written and closed. This is done is response to +** the SB 'Send Routing Info' cmd, the SB 'Send pipe Info' cmd or the SB 'Send +** Map Info' cmd, respectively. +**/ +#define CFE_SB_SND_RTG_EID 39 + + +/** \brief 'Error creating file \%s, stat=0x\%x' +** \event 'Error creating file \%s, stat=0x\%x' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the SB 'Send Routing Info' cmd is +** received and the file create fails. The event displays the status received from +** the OS. +**/ +#define CFE_SB_SND_RTG_ERR1_EID 40 + + +/** \brief 'SB GetLastSender Err:Caller(\%s) is not the owner of pipe \%d' +** \event 'SB GetLastSender Err:Caller(\%s) is not the owner of pipe \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the caller of CFE_SB_GetLastSenderId is +** not the owner of the given pipe Id. +**/ +#define CFE_SB_GLS_INV_CALLER_EID 41 + + +/** \brief 'Invalid Cmd, Unexpected Command Code \%d' +** \event 'Invalid Cmd, Unexpected Command Code \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the SB receives a cmd that has an +** unexpected cmd code. +**/ +#define CFE_SB_BAD_CMD_CODE_EID 42 + +/** \brief 'Invalid Cmd, Unexpected Msg Id: 0x\%04x' +** \event 'Invalid Cmd, Unexpected Msg Id: 0x\%04x' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the SB receives a msg that has an +** unexpected msg id. +**/ +#define CFE_SB_BAD_MSGID_EID 43 + + +/** \brief 'Full Sub Pkt \%d Sent,Entries=\%d,Stat=0x\%x\n' +** \event 'Full Sub Pkt \%d Sent,Entries=\%d,Stat=0x\%x\n' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This debug event message is issued in response to the +** 'Send Previous Subscriptions' command and a full pkt segment is sent. +**/ +#define CFE_SB_FULL_SUB_PKT_EID 44 + +/** \brief 'Partial Sub Pkt \%d Sent,Entries=\%d,Stat=0x\%x' +** \event 'Partial Sub Pkt \%d Sent,Entries=\%d,Stat=0x\%x' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This debug event message is issued in response to the +** 'Send Previous Subscriptions' command and a partial pkt segment is sent. +**/ +#define CFE_SB_PART_SUB_PKT_EID 45 + + +/** \brief 'Pipe Delete Error:Bad Argument,PipedId \%d,Requestor \%s,Idx \%d,Stat \%d' +** \event 'Pipe Delete Error:Bad Argument,PipedId \%d,Requestor \%s,Idx \%d,Stat \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued from one of SB's subscribe API's when the +** function #CFE_SB_GetRoutingTblIdx returns an index that is out of range. This +** error is not expected and is an indication that the SB internal memory has been +** corrupted. +**/ +#define CFE_SB_DEL_PIPE_ERR1_EID 46 + +/** \brief 'Pipe Deleted:id \%d,owner \%s' +** \event 'Pipe Deleted:id \%d,owner \%s' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This debug event message is issued when the #CFE_SB_DeletePipe API is called and +** the request is successfully completed. +**/ +#define CFE_SB_PIPE_DELETED_EID 47 + +/** \brief 'Subscription Removed:Msg 0x\%x on pipe \%d,app \%s' +** \event 'Subscription Removed:Msg 0x\%x on pipe \%d,app \%s' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This debug event message is issued when #CFE_SB_Unsubscribe API is called +** and the request is successfully completed. +**/ +#define CFE_SB_SUBSCRIPTION_REMOVED_EID 48 + +/** \brief 'File write,byte cnt err,file \%s,request=\%d,actual=\%d' +** \event 'File write,byte cnt err,file \%s,request=\%d,actual=\%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when one of many SB's file write operations +** is unsuccessful. This event is a result of #CFE_FS_WriteHeader or OS_write +** returning something other than the number of bytes requested to be written. +** The requested value and the return value are displayed in the event. +**/ +#define CFE_SB_FILEWRITE_ERR_EID 49 + +/** \brief 'Subscribe Err:Invalid Pipe Id,Msg=0x\%x,PipeId=\%d,App \%s' +** \event 'Subscribe Err:Invalid Pipe Id,Msg=0x\%x,PipeId=\%d,App \%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the input PipeId has a value that is not +** listed in the pipe table. This typically means that the pipe does not exist. +** The pipe table may be viewed for verification. +**/ +#define CFE_SB_SUB_INV_PIPE_EID 50 + +/** \brief 'Subscribe Err:Caller(\%s) is not the owner of pipe \%d, Msg=0x\%x' +** \event 'Subscribe Err:Caller(\%s) is not the owner of pipe \%d, Msg=0x\%x' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when one of the SB subscribe API's are called +** and the requestor is not the owner of the pipe. Only the owner of the pipe may +** subscribe to messages on the pipe. +**/ +#define CFE_SB_SUB_INV_CALLER_EID 51 + +/** \brief 'Unsubscribe Err:Invalid Pipe Id Msg=0x\%x,Pipe=\%d,app=\%s' +** \event 'Unsubscribe Err:Invalid Pipe Id Msg=0x\%x,Pipe=\%d,app=\%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when one of the SB unsubscribe API's are +** called and the input parameter PipeId is not listed in the pipe table. +** This typically means that the pipe does not exist. The pipe table may be viewed +** for verification. +**/ +#define CFE_SB_UNSUB_INV_PIPE_EID 52 + +/** \brief 'Unsubscribe Err:Caller(\%s) is not the owner of pipe \%d,Msg=0x\%x' +** \event 'Unsubscribe Err:Caller(\%s) is not the owner of pipe \%d,Msg=0x\%x' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when one of the SB unsubscribe API's are +** called and the requestor is not the owner of the pipe (or ES). Only the owner of +** the pipe(or ES for cleanup purposes)may unsubscribe messages from a pipe. +**/ +#define CFE_SB_UNSUB_INV_CALLER_EID 53 + +/** \brief 'Pipe Delete Error:Caller(\%s) is not the owner of pipe \%d' +** \event 'Pipe Delete Error:Caller(\%s) is not the owner of pipe \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the #CFE_SB_DeletePipe API is called by a +** task that is not the owner of the pipe. Pipes may be deleted only by the task +** that created the pipe or ES(for cleanup purposes). +**/ +#define CFE_SB_DEL_PIPE_ERR2_EID 54 + + +#endif /* _cfe_sb_events_ */ + +/************************/ +/* End of File Comment */ +/************************/ + diff --git a/src/components/interface/cFE/cfe_sb_msg.h b/src/components/interface/cFE/cfe_sb_msg.h new file mode 100644 index 0000000000..3a18929162 --- /dev/null +++ b/src/components/interface/cFE/cfe_sb_msg.h @@ -0,0 +1,769 @@ +/****************************************************************************** +** File: cfe_sb_msg.h +** +** Copyright (c) 2004-2012, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** +** Purpose: +** This header file contains structure definitions for all SB command and +** telemetry packets +** +** Author: R.McGraw/SSI +** +** $Log: cfe_sb_msg.h $ +** Revision 1.11 2014/07/15 08:50:49GMT-05:00 rmcgraw +** DCR22588:1 Add spare byte to ena/dis packet route cmd +** Revision 1.10 2012/01/13 12:32:51EST acudmore +** Changed license text to reflect open source +** Revision 1.9 2011/12/20 10:53:44EST rmcgraw +** DCR17187:2 Changed MsgIdToPipeErrCnt to MsgLimErrCnt +** Revision 1.8 2009/05/08 11:29:41EDT rmcgraw +** DCR7631:1 Changed comment regarding internal error counter +** Revision 1.7 2009/04/01 15:22:38EDT rmcgraw +** DCR6296:4 Changed tlm item pk-mem-in-use to unmarked mem +** Revision 1.6 2009/02/26 17:47:24EST rmcgraw +** DCR6805:1 Corrected comment for InUse member of pipe depth stats +** Revision 1.5 2009/02/11 14:18:49EST rmcgraw +** DCR6269:1 Removed the 'Buf' in MemInUse names +** Revision 1.4 2009/02/06 12:55:55EST rmcgraw +** DCR5802:3 Removed two of four new telemetry items +** Revision 1.3 2009/02/05 16:19:38EST rmcgraw +** DCR5802:2 Added SB statistics to hk pkt +** Revision 1.2 2008/12/08 12:06:58EST dkobe +** Updates to correct doxygen errors +** Revision 1.1 2008/04/17 08:05:23EDT ruperera +** Initial revision +** Member added to cfe project on tlserver3 +** Revision 1.13 2007/09/25 15:39:07EDT rjmcgraw +** DCR5127 Added doxygen comments +** Revision 1.12 2007/09/19 15:31:59EDT rjmcgraw +** DCR5055 Removed SB event log items in HK tlm pkt and statistics pkt +** Revision 1.11 2007/09/18 13:50:59EDT rjmcgraw +** DCR5045:1 Added User Guide information in doxygen comments +** Revision 1.10 2007/06/07 13:07:48EDT dlkobe +** Added Command and Telemetry doxygen comments to TIME, EVS and SB +** Revision 1.9 2007/06/02 10:10:14EDT dlkobe +** Added doxygen comments for User's Guides +** Revision 1.8 2007/05/23 12:06:51EDT rjmcgraw +** Added doxygen comments +** Revision 1.7 2007/05/16 15:13:41EDT dlkobe +** Added MemPoolHandle members to HK packet +** Revision 1.6 2007/04/24 11:07:59EDT rjmcgraw +** Added PipeId to PipeDepthStats +** Revision 1.5 2007/04/24 09:39:29EDT rjmcgraw +** Reformatted SB statistics pkt structure and PipeDepthStats struct +** Revision 1.4 2007/04/19 15:47:23EDT rjmcgraw +** Moved subscription reporting structs to cfe_sb_msg.h +** Revision 1.2 2007/03/27 13:47:41EST rjmcgraw +** Added DupSubscriptionsCnt to HK Tlm +** Revision 1.1 2007/03/27 08:59:54EST rjmcgraw +** Initial revision +** Member added to project +** +******************************************************************************/ + +#ifndef _cfe_sb_msg_ +#define _cfe_sb_msg_ + +/* +** Includes +*/ +#include "common_types.h" +#include "cfe_sb.h" +#include "osconfig.h" +#include "cfe_es.h" + + +/**************************************** +** SB task command packet command codes +****************************************/ + +/** \cfesbcmd Software Bus No-Op +** +** \par Description +** This command performs no other function than to increment the +** command execution counter. The command may be used to verify +** general aliveness of the Software Bus task. +** +** \cfecmdmnemonic \SB_NOOP +** +** \par Command Structure +** #CFE_SB_CmdHdr_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \SB_CMDPC - command execution counter will +** increment +** - The #CFE_SB_CMD0_RCVD_EID informational event message will +** be generated +** +** \par Error Conditions +** There are no error conditions for this command. If the Software +** Bus receives the command, the event is sent (although it +** may be filtered by EVS) and the counter is incremented +** unconditionally. +** +** \par Criticality +** None +** +** \sa +*/ +#define CFE_SB_NOOP_CC 0 + +/** \cfesbcmd Software Bus Reset Counters +** +** \par Description +** This command resets the following counters within the Software +** Bus housekeeping telemetry: +** - Command Execution Counter (\SB_CMDPC) +** - Command Error Counter (\SB_CMDEC) +** +** \cfecmdmnemonic \SB_RESETCTRS +** +** \par Command Structure +** #CFE_SB_CmdHdr_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \SB_CMDPC - command execution counter will +** increment +** - The #CFE_SB_CMD1_RCVD_EID informational event message will +** be generated +** +** \par Error Conditions +** There are no error conditions for this command. If the Software +** Bus receives the command, the event is sent (although it +** may be filtered by EVS) and the counter is incremented +** unconditionally. +** +** \par Criticality +** This command is not inherently dangerous. However, it is +** possible for ground systems and on-board safing procedures +** to be designed such that they react to changes in the counter +** values that are reset by this command. +** +** \sa +*/ +#define CFE_SB_RESET_CTRS_CC 1 + +/** \cfesbcmd Send Software Bus Statistics +** +** \par Description +** This command will cause the SB task to send a statistics packet +** containing current utilization figures and high water marks which +** may be useful for checking the margin of the SB platform configuration +** settings. +** +** \cfecmdmnemonic \SB_DUMPSTATS +** +** \par Command Structure +** #CFE_SB_CmdHdr_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \SB_CMDPC - command execution counter will increment +** - Receipt of statistics packet with MsgId #CFE_SB_STATS_TLM_MID +** - The #CFE_SB_SND_STATS_EID debug event message will be generated. All +** debug events are filtered by default. +** +** \par Error Conditions +** There are no error conditions for this command. If the Software +** Bus receives the command, the debug event is sent and the counter +** is incremented unconditionally. +** +** \par Criticality +** This command is not inherently dangerous. It will create and send +** a message on the software bus. If performed repeatedly, it is +** possible that receiver pipes may overflow. +** +** \sa +*/ +#define CFE_SB_SEND_SB_STATS_CC 2 + +/** \cfesbcmd Write Software Bus Routing Info to a File +** +** \par Description +** This command will create a file containing the software bus routing +** information. The routing information contains information about every +** subscription that has been received through the SB subscription APIs. +** An abosulte path and filename may be specified in the command. +** If this command field contains an empty string (NULL terminator as +** the first character) the default file path and name is used. +** The default file path and name is defined in the platform +** configuration file as #CFE_SB_DEFAULT_ROUTING_FILENAME. +** +** \cfecmdmnemonic \SB_WRITEROUTING2FILE +** +** \par Command Structure +** #CFE_SB_WriteFileInfoCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \SB_CMDPC - command execution counter will increment. +** - Specified filename created at specified location. See description. +** - The #CFE_SB_SND_RTG_EID debug event message will be generated. All +** debug events are filtered by default. +** +** \par Error Conditions +** - Errors may occur during write operations to the file. Possible +** causes might be insufficient space in the file system or the +** filename or file path is improperly specified. +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \SB_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases. See #CFE_SB_SND_RTG_ERR1_EID and #CFE_SB_FILEWRITE_ERR_EID +** +** \par Criticality +** This command is not inherently dangerous. It will create a new +** file in the file system and could, if performed repeatedly without +** sufficient file management by the operator, fill the file system. +** +** \sa #CFE_SB_SEND_PIPE_INFO_CC, #CFE_SB_SEND_MAP_INFO_CC, #CFE_SB_WriteFileInfoCmd_t +*/ +#define CFE_SB_SEND_ROUTING_INFO_CC 3 + +/** \cfesbcmd Enable Software Bus Route +** +** \par Description +** This command will enable a particular destination. The destination +** is specified in terms of MsgID and PipeID. The MsgId and PipeID are +** parmaters in the command. All destinations are enabled by default. +** This command is needed only after a #CFE_SB_DISABLE_ROUTE_CC command +** is used. +** +** \cfecmdmnemonic \SB_ENAROUTE +** +** \par Command Structure +** #CFE_SB_EnRoutCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \SB_CMDPC - command execution counter will increment +** - View routing information #CFE_SB_SEND_ROUTING_INFO_CC to verify +** enable/disable state change +** - The #CFE_SB_ENBL_RTE2_EID debug event message will be generated. All +** debug events are filtered by default. +** - Destination will begin receiving messages. +** +** \par Error Conditions +** An Error may occur if the MsgId or PipeId parmaters do not pass +** validation or the destination does not exist. + +** Evidence of failure may be found in the following telemetry: +** - \b \c \SB_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases. See #CFE_SB_ENBL_RTE1_EID or #CFE_SB_ENBL_RTE3_EID +** +** \par Criticality +** This command is not inherently dangerous. +** +** \sa #CFE_SB_SEND_ROUTING_INFO_CC, #CFE_SB_DISABLE_ROUTE_CC, #CFE_SB_EnRoutCmd_t +*/ +#define CFE_SB_ENABLE_ROUTE_CC 4 + +/** \cfesbcmd Disable Software Bus Route +** +** \par Description +** This command will disable a particular destination. The destination +** is specified in terms of MsgID and PipeID. The MsgId and PipeID are +** parmaters in the command. All destinations are enabled by default. +** +** \cfecmdmnemonic \SB_DISROUTE +** +** \par Command Structure +** #CFE_SB_EnRoutCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \SB_CMDPC - command execution counter will increment +** - View routing information #CFE_SB_SEND_ROUTING_INFO_CC to verify +** enable/disable state change +** - The #CFE_SB_DSBL_RTE2_EID debug event message will be generated. All +** debug events are filtered by default. +** - Destination will stop receiving messages. +** +** \par Error Conditions +** An Error may occur if the MsgId or PipeId parmaters do not pass +** validation or the destination does not exist. + +** Evidence of failure may be found in the following telemetry: +** - \b \c \SB_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases. See #CFE_SB_DSBL_RTE1_EID or #CFE_SB_DSBL_RTE3_EID +** +** \par Criticality +** This command is not intended to be used in nominal conditions. It is +** possible to get into a state where a destination cannot be re-enabled +** without reseting the processor. For instance, sending this command +** with #CFE_SB_CMD_MID and the SB_Cmd_Pipe would inhibit any ground +** commanding to the software bus until the processor was reset. There +** are similar problems that may occur when using this command. +** +** \sa #CFE_SB_SEND_ROUTING_INFO_CC, #CFE_SB_ENABLE_ROUTE_CC, #CFE_SB_EnRoutCmd_t +*/ +#define CFE_SB_DISABLE_ROUTE_CC 5 + +/** \cfesbcmd Write Pipe Info to a File +** +** \par Description +** This command will create a file containing the software bus pipe +** information. The pipe information contains information about every +** pipe that has been created through the #CFE_SB_CreatePipe API. An +** abosulte path and filename may be specified in the command. +** If this command field contains an empty string (NULL terminator as +** the first character) the default file path and name is used. +** The default file path and name is defined in the platform +** configuration file as #CFE_SB_DEFAULT_PIPE_FILENAME. +** +** \cfecmdmnemonic \SB_WRITEPIPE2FILE +** +** \par Command Structure +** #CFE_SB_WriteFileInfoCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \SB_CMDPC - command execution counter will increment. +** - Specified filename created at specified location. See description. +** - The #CFE_SB_SND_RTG_EID debug event message will be generated. All +** debug events are filtered by default. +** +** \par Error Conditions +** - Errors may occur during write operations to the file. Possible +** causes might be insufficient space in the file system or the +** filename or file path is improperly specified. +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \SB_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases. See #CFE_SB_SND_RTG_ERR1_EID and #CFE_SB_FILEWRITE_ERR_EID +** +** \par Criticality +** This command is not inherently dangerous. It will create a new +** file in the file system and could, if performed repeatedly without +** sufficient file management by the operator, fill the file system. +** +** \sa #CFE_SB_SEND_ROUTING_INFO_CC, #CFE_SB_SEND_MAP_INFO_CC +*/ +#define CFE_SB_SEND_PIPE_INFO_CC 7 + +/** \cfesbcmd Write Map Info to a File +** +** \par This command will create a file containing the software bus message +** map information. The message map is a lookup table (an array of +** uint16s)that allows fast access to the correct routing table element +** during a softeware bus send operation. This is diasgnostic +** information that may be needed due to the dynamic nature of the +** cFE software bus. An abosulte path and filename may be specified +** in the command. If this command field contains an empty string +** (NULL terminator as the first character) the default file path and +** name is used. The default file path and name is defined in the +** platform configuration file as #CFE_SB_DEFAULT_MAP_FILENAME. +** +** \cfecmdmnemonic \SB_WRITEMAP2FILE +** +** \par Command Structure +** #CFE_SB_WriteFileInfoCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \SB_CMDPC - command execution counter will increment. +** - Specified filename created at specified location. See description. +** - The #CFE_SB_SND_RTG_EID debug event message will be generated. All +** debug events are filtered by default. +** +** \par Error Conditions +** - Errors may occur during write operations to the file. Possible +** causes might be insufficient space in the file system or the +** filename or file path is improperly specified. +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \SB_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases. See #CFE_SB_SND_RTG_ERR1_EID and #CFE_SB_FILEWRITE_ERR_EID +** +** \par Criticality +** This command is not inherently dangerous. It will create a new +** file in the file system and could, if performed repeatedly without +** sufficient file management by the operator, fill the file system. +** +** \sa #CFE_SB_SEND_ROUTING_INFO_CC, #CFE_SB_SEND_PIPE_INFO_CC +*/ +#define CFE_SB_SEND_MAP_INFO_CC 8 + +/** \cfesbcmd Enable Subscription Reporting Command +** +** \par This command will enable subscription reporting and is intended to +** be used only by the CFS SBN (Software Bus Networking) Application. +** It is not intended to be sent from the ground or used by operations. +** When subscription reporting is enabled, SB will generate +** and send a software bus packet for each subscription received. +** The software bus packet that is sent contains the information +** received in the subscription API. This subscription report is +** neeeded by SBN if offboard routing is required. +* +** \cfecmdmnemonic \SB_ENASUBRPTG +** +** \par Command Structure +** #CFE_SB_CmdHdr_t +** +** \par Command Verification +** Successful execution of this command will result in the sending +** of a packet (with the #CFE_SB_ONESUB_TLM_MID MsgId) for each +** subscription received by SB through the subscription APIs. +** +** \par Error Conditions +** None +** +** \par Criticality +** None +** +** \sa #CFE_SB_SubRprtMsg_t, #CFE_SB_DISABLE_SUB_REPORTING_CC, +** #CFE_SB_SEND_PREV_SUBS_CC +*/ +#define CFE_SB_ENABLE_SUB_REPORTING_CC 9 + +/** \cfesbcmd Disable Subscription Reporting Command +** +** \par This command will disable subscription reporting and is intended to +** be used only by the CFS SBN (Software Bus Networking) Application. +** It is not intended to be sent from the ground or used by operations. +** When subscription reporting is enabled, SB will generate +** and send a software bus packet for each subscription received. +** The software bus packet that is sent contains the information +** received in the subscription API. This subscription report is +** neeeded by SBN if offboard routing is required. +** +** \cfecmdmnemonic \SB_DISSUBRPTG +** +** \par Command Structure +** #CFE_SB_CmdHdr_t +** +** \par Command Verification +** Successful execution of this command will result in the suppression +** of packets (with the #CFE_SB_ONESUB_TLM_MID MsgId) for each +** subscription received by SB through the subscription APIs. +** +** \par Error Conditions +** None +** +** \par Criticality +** None +** +** \sa #CFE_SB_SubRprtMsg_t, #CFE_SB_ENABLE_SUB_REPORTING_CC, +** #CFE_SB_SEND_PREV_SUBS_CC +*/ +#define CFE_SB_DISABLE_SUB_REPORTING_CC 10 + +/** \cfesbcmd Send Previous Subscriptions Command +** +** \par This command generates a series of packets that contain information +** regarding all subscriptions previously received by SB. +** This command is intended to be used only by the CFS SBN(Software Bus +** Networking) Application. +** It is not intended to be sent from the ground or used by operations. +** When this command is received the software bus will generate and +** send a series of packets containing information about all subscription +** previously received. +** +** \cfecmdmnemonic \SB_SENDPREVSUBS +** +** \par Command Structure +** #CFE_SB_CmdHdr_t +** +** \par Command Verification +** Successful execution of this command will result in a series +** of packets (with the #CFE_SB_ALLSUBS_TLM_MID MsgId) being sent +** on the software bus. +** +** \par Error Conditions +** None +** +** \par Criticality +** None +** +** \sa #CFE_SB_PrevSubMsg_t, #CFE_SB_ENABLE_SUB_REPORTING_CC, +** #CFE_SB_DISABLE_SUB_REPORTING_CC +*/ +#define CFE_SB_SEND_PREV_SUBS_CC 11 + + +/**************************** +** SB Command Formats ** +*****************************/ + + +/** +** \brief Write File Info Commands +** +** This structure contains a generic definition used by three SB commands, +** 'Write Routing Info to File' #CFE_SB_SEND_ROUTING_INFO_CC, +** 'Write Pipe Info to File' #CFE_SB_SEND_PIPE_INFO_CC and +** 'Write Map Info to File' #CFE_SB_SEND_MAP_INFO_CC. +*/ +typedef struct{ + char Filename[OS_MAX_PATH_LEN];/**< \brief Path and Filename of data to be loaded */ +} CFE_SB_WriteFileInfoCmd_Payload_t; + +typedef struct{ + CFE_SB_CmdHdr_t Hdr;/**< \brief cFE Software Bus Command Message Header #CFE_SB_CmdHdr_t */ + CFE_SB_WriteFileInfoCmd_Payload_t Payload; +}CFE_SB_WriteFileInfoCmd_t; + + +/** +** \brief Enable/Disable Route Commands +** +** This structure contains a definition used by two SB commands, +** 'Enable Route' #CFE_SB_ENABLE_ROUTE_CC and 'Disable Route' #CFE_SB_DISABLE_ROUTE_CC. +** A route is the destination pipe for a particular message and is therefore defined +** as a MsgId and PipeId combination. +*/ +typedef struct { + + CFE_SB_MsgId_t MsgId;/**< \brief Message ID of route to be enabled or disabled #CFE_SB_MsgId_t */ + CFE_SB_PipeId_t Pipe;/**< \brief Pipe ID of route to be enabled or disabled #CFE_SB_PipeId_t */ + uint8 Spare;/**<\brief Spare byte to make command even number of bytes */ +} CFE_SB_EnRoutCmd_Payload_t; + +typedef struct{ + CFE_SB_CmdHdr_t Hdr;/**< \brief cFE Software Bus Command Message Header #CFE_SB_CmdHdr_t */ + CFE_SB_EnRoutCmd_Payload_t Payload; +} CFE_SB_EnRoutCmd_t; + + +/**************************** +** SB Telemetry Formats ** +*****************************/ + +/** +** \cfesbtlm Software Bus task housekeeping Packet +*/ +typedef struct { + + uint8 CommandCnt;/**< \cfetlmmnemonic \SB_CMDPC + \brief Count of valid commands received */ + uint8 CmdErrCnt;/**< \cfetlmmnemonic \SB_CMDEC + \brief Count of invalid commands received */ + uint8 NoSubscribersCnt;/**< \cfetlmmnemonic \SB_NOSUBEC + \brief Count pkts sent with no subscribers */ + uint8 MsgSendErrCnt;/**< \cfetlmmnemonic \SB_MSGSNDEC + \brief Count of message send errors */ + + uint8 MsgReceiveErrCnt;/**< \cfetlmmnemonic \SB_MSGRECEC + \brief Count of message receive errors */ + uint8 InternalErrCnt;/**< \cfetlmmnemonic \SB_INTERNALEC + \brief Count of queue read or write errors */ + uint8 CreatePipeErrCnt;/**< \cfetlmmnemonic \SB_NEWPIPEEC + \brief Count of errors in create pipe API */ + uint8 SubscribeErrCnt;/**< \cfetlmmnemonic \SB_SUBSCREC + \brief Count of errors in subscribe API */ + + uint8 Spare;/**< \cfetlmmnemonic \SB_SPARE + \brief Spare Byte */ + uint8 DupSubscriptionsCnt;/**< \cfetlmmnemonic \SB_DUPSUBCNT + \brief Count of duplicate subscriptions */ + uint8 Spare2Align[2];/**< \cfetlmmnemonic \SB_SPARE2ALIGN + \brief Spare bytes to ensure alignment */ + + uint16 PipeOverflowErrCnt;/**< \cfetlmmnemonic \SB_PIPEOVREC + \brief Count of pipe overflow errors */ + uint16 MsgLimErrCnt;/**< \cfetlmmnemonic \SB_MSGLIMEC + \brief Count of msg id to pipe errors */ + + CFE_ES_MemHandle_t MemPoolHandle;/**< \cfetlmmnemonic \SB_MEMPOOLHANDLE + \brief Handle to SB's Memory Pool */ + + uint32 MemInUse;/**< \cfetlmmnemonic \SB_MEMINUSE + \brief Memory in use */ + + uint32 UnmarkedMem;/**< \cfetlmmnemonic \SB_UNMARKEDMEM + \brief cfg param CFE_SB_BUF_MEMORY_BYTES minus Peak Memory in use */ +} CFE_SB_HKMsg_Payload_t; + +typedef struct{ + CFE_SB_TlmHdr_t Hdr;/**< \brief cFE Software Bus Telemetry Message Header */ + CFE_SB_HKMsg_Payload_t Payload; +} CFE_SB_HKMsg_t; + + +/** +** \brief SB Pipe Depth Statistics +** +** Used in SB Statistics Telemetry Packet #CFE_SB_StatMsg_t +*/ +typedef struct { + + CFE_SB_PipeId_t PipeId;/**< \cfetlmmnemonic \SB_PDPIPEID + \brief Pipe Id associated with the stats below */ + uint8 Spare;/**< \cfetlmmnemonic \SB_PDSPARE + \brief Spare byte to ensure alignment */ + uint16 Depth;/**< \cfetlmmnemonic \SB_PDDEPTH + \brief Number of messages the pipe can hold */ + uint16 InUse;/**< \cfetlmmnemonic \SB_PDINUSE + \brief Number of messages currently on the pipe */ + uint16 PeakInUse;/**< \cfetlmmnemonic \SB_PDPKINUSE + \brief Peak number of messages that have been on the pipe */ + +}CFE_SB_PipeDepthStats_t; + +/** +** \cfesbtlm SB Statistics Telemetry Packet +** +** SB Statistics packet sent (via CFE_SB_SendMsg) in response to #CFE_SB_SEND_SB_STATS_CC +*/ +typedef struct { + + uint32 MsgIdsInUse;/**< \cfetlmmnemonic \SB_SMMIDIU + \brief Current number of MsgIds with a destination */ + uint32 PeakMsgIdsInUse;/**< \cfetlmmnemonic \SB_SMPMIDIU + \brief Peak number of MsgIds with a destination */ + uint32 MaxMsgIdsAllowed;/**< \cfetlmmnemonic \SB_SMMMIDALW + \brief cFE Cfg Param \link #CFE_SB_MAX_MSG_IDS \endlink */ + + uint32 PipesInUse;/**< \cfetlmmnemonic \SB_SMPIU + \brief Number of pipes currently in use */ + uint32 PeakPipesInUse;/**< \cfetlmmnemonic \SB_SMPPIU + \brief Peak number of pipes since last reboot */ + uint32 MaxPipesAllowed;/**< \cfetlmmnemonic \SB_SMMPALW + \brief cFE Cfg Param \link #CFE_SB_MAX_PIPES \endlink */ + + uint32 MemInUse;/**< \cfetlmmnemonic \SB_SMBMIU + \brief Memory bytes currently in use for SB msg transfers */ + uint32 PeakMemInUse;/**< \cfetlmmnemonic \SB_SMPBMIU + \brief Peak memory bytes in use for SB msg transfers */ + uint32 MaxMemAllowed;/**< \cfetlmmnemonic \SB_SMMBMALW + \brief cFE Cfg Param \link #CFE_SB_BUF_MEMORY_BYTES \endlink */ + + uint32 SubscriptionsInUse;/**< \cfetlmmnemonic \SB_SMSIU + \brief Number of current subscriptions */ + uint32 PeakSubscriptionsInUse;/**< \cfetlmmnemonic \SB_SMPSIU + \brief Peak number of subscriptions */ + uint32 MaxSubscriptionsAllowed;/**< \cfetlmmnemonic \SB_SMMSALW + \brief product of \link #CFE_SB_MAX_MSG_IDS \endlink + and \link #CFE_SB_MAX_DEST_PER_PKT \endlink */ + + uint32 SBBuffersInUse;/**< \cfetlmmnemonic \SB_SMSBBIU + \brief Number of SB message buffers currently in use */ + uint32 PeakSBBuffersInUse;/**< \cfetlmmnemonic \SB_SMPSBBIU + \brief Max number of SB message buffers in use */ + + uint32 MaxPipeDepthAllowed;/**< \cfetlmmnemonic \SB_SMMPDALW + \brief cFE Cfg Param \link #CFE_SB_MAX_PIPE_DEPTH \endlink */ + CFE_SB_PipeDepthStats_t PipeDepthStats[CFE_SB_MAX_PIPES];/**< \cfetlmmnemonic \SB_SMPDS + \brief Pipe Depth Statistics #CFE_SB_PipeDepthStats_t*/ +} CFE_SB_StatMsg_Payload_t; + +typedef struct{ + CFE_SB_TlmHdr_t Hdr;/**< \brief cFE Software Bus Telemetry Message Header */ + CFE_SB_StatMsg_Payload_t Payload; +} CFE_SB_StatMsg_t; + + +/** +** \brief SB Routing File Entry +** +** Structure of one element of the routing information in response to #CFE_SB_SEND_ROUTING_INFO_CC +*/ +typedef struct{ + CFE_SB_MsgId_t MsgId;/**< \brief Message Id portion of the route */ + CFE_SB_PipeId_t PipeId;/**< \brief Pipe Id portion of the route */ + uint8 State;/**< \brief Route Enabled or Disabled */ + uint16 MsgCnt;/**< \brief Number of msgs with this MsgId sent to this PipeId */ + char AppName[OS_MAX_API_NAME];/**< \brief Pipe Depth Statistics */ + char PipeName[OS_MAX_API_NAME];/**< \brief Pipe Depth Statistics */ + }CFE_SB_RoutingFileEntry_t; + + +/** +** \brief SB Map File Entry +** +** Structure of one element of the map information in response to #CFE_SB_SEND_MAP_INFO_CC +*/ +typedef struct{ + uint16 MsgId;/**< \brief Message Id which has been subscribed to */ + uint16 Index;/**< \brief Routing table index where pipe destinations are found */ +}CFE_SB_MsgMapFileEntry_t; + + +/** +** \cfesbtlm SB Subscription Report Packet +** +** This structure defines the pkt sent by SB when a subscription or +** a request to unsubscribe is received while subscription reporting is enabled. +** By default subscription reporting is disabled. This feature is intended to be +** used primarily by Software Bus Networking Application (SBN) +** +** \sa #CFE_SB_ENABLE_SUB_REPORTING_CC, #CFE_SB_DISABLE_SUB_REPORTING_CC +*/ +typedef struct { + + uint8 SubType;/**< \brief Subscription or Unsubscription */ + CFE_SB_MsgId_t MsgId;/**< \brief MsgId subscribed or unsubscribe to */ + CFE_SB_Qos_t Qos;/**< \brief Quality of Service, used only for interprocessor communication */ + CFE_SB_PipeId_t Pipe;/**< \brief Destination pipe id to send above msg id */ + +} CFE_SB_SubRprtMsg_Payload_t; + +typedef struct{ + CFE_SB_TlmHdr_t Hdr;/**< \brief cFE Software Bus Telemetry Message Header */ + CFE_SB_SubRprtMsg_Payload_t Payload; +} CFE_SB_SubRprtMsg_t; + + +/** +** \brief SB Previous Subscriptions Entry +** +** This structure defines an entry used in the CFE_SB_PrevSubsPkt_t +** Intended to be used primarily by Software Bus Networking Application (SBN) +** +** Used in structure definition #CFE_SB_PrevSubMsg_t +*/ +typedef struct { + + CFE_SB_MsgId_t MsgId;/**< \brief MsgId portion of the subscription */ + CFE_SB_Qos_t Qos;/**< \brief Qos portion of the subscription */ + CFE_SB_PipeId_t Pipe;/**< \brief PipeId portion of the subscription */ + +}CFE_SB_SubEntries_t; + + +/** +** \cfesbtlm SB Previous Subscriptions Packet +** +** This structure defines the pkt(s) sent by SB that contains a list of all current +** subscriptions. This pkt is generated on cmd and intended to be used primarily by +** the Software Bus Networking Application (SBN). Typically, when the cmd is received +** there are more subscriptions than can fit in one pkt. The complete list of +** subscriptions is sent via a series of segmented pkts. +*/ +typedef struct { + + uint32 PktSegment;/**< \brief Pkt number(starts at 1) in the series */ + uint32 TotalSegments;/**< \brief Total number of pkts needed to complete the request */ + uint32 Entries;/**< \brief Number of entries in the pkt */ + CFE_SB_SubEntries_t Entry[CFE_SB_SUB_ENTRIES_PER_PKT];/**< \brief Array of #CFE_SB_SubEntries_t entries */ +} CFE_SB_PrevSubMsg_Payload_t; + +typedef struct{ + CFE_SB_TlmHdr_t Hdr;/**< \brief cFE Software Bus Telemetry Message Header */ + CFE_SB_PrevSubMsg_Payload_t Payload; +} CFE_SB_PrevSubMsg_t; + + +#endif /* _cfe_sb_msg_ */ +/*****************************************************************************/ diff --git a/src/components/interface/cFE/cfe_tbl.h b/src/components/interface/cFE/cfe_tbl.h new file mode 100644 index 0000000000..ad855dc466 --- /dev/null +++ b/src/components/interface/cFE/cfe_tbl.h @@ -0,0 +1,858 @@ +/* +** +** $Id: cfe_tbl.h 1.9 2014/08/24 16:59:51GMT-05:00 sstrege Exp $ +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Title: Table Services API Application Library Header File +** +** Purpose: +** Unit specification for Table services library functions and macros. +** +** Design Notes: +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** +** Notes: +** +** $Log: cfe_tbl.h $ +** Revision 1.9 2014/08/24 16:59:51GMT-05:00 sstrege +** Updated CFE_TBL_MAX_FULL_NAME_LEN definition to always fall on 4-byte boundary +** Revision 1.8 2010/10/27 16:34:31EDT dkobe +** Added CRC field to Table Buffer data structure +** Revision 1.7 2010/10/27 13:55:07EDT dkobe +** Added TBL Notification API +** Revision 1.6 2010/10/04 15:24:59EDT jmdagost +** Cleaned up copyright symbol. +** Revision 1.5 2009/05/01 16:38:54EDT dkobe +** Updated documentation for CFE_TBL_Register dealing with Validation functions +** Revision 1.4 2009/05/01 14:26:33EDT dkobe +** Modified return code contents to emphasize success vs failure of API calls +** Revision 1.3 2008/07/29 18:32:18EDT dkobe +** Added CFE_TBL_Modified API +** Revision 1.2 2008/07/29 15:55:19EDT dkobe +** Moved CFE_TBL_DumpToBuffer from cfe_tbl_internal.c to cfe_tbl_api.c +** Revision 1.1 2008/04/17 08:05:24EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.13 2007/05/23 11:22:00EDT David Kobe (dlkobe) +** Added doxygen formatting +** Revision 1.12 2007/04/28 14:48:57EDT dlkobe +** Baseline Implementation of Critical Tables +** Revision 1.11 2007/03/28 15:18:17EST rjmcgraw +** Moved file related defines from cfe_tbl.h to cfe_fs.h +** Revision 1.10 2006/11/03 15:41:43EST dlkobe +** Modified cfe_tbl.h so that the CFE_TBL_OPT_USR_DEF_ADDR +** macro includes the CFE_TBL_OPT_DUMP_ONLY option +** +**/ + +#ifndef _cfe_tbl_ +#define _cfe_tbl_ + +/********************* Include Files ************************/ +#include "common_types.h" /* Basic Data Types */ +#include "cfe_time.h" +#include "osconfig.h" + +/******************* Macro Definitions ***********************/ +#define CFE_TBL_OPT_BUFFER_MSK (0x0001) +#define CFE_TBL_OPT_SNGL_BUFFER (0x0000) +#define CFE_TBL_OPT_DBL_BUFFER (0x0001) + +#define CFE_TBL_OPT_LD_DMP_MSK (0x0002) +#define CFE_TBL_OPT_LOAD_DUMP (0x0000) +#define CFE_TBL_OPT_DUMP_ONLY (0x0002) + +#define CFE_TBL_OPT_USR_DEF_MSK (0x0004) +#define CFE_TBL_OPT_NOT_USR_DEF (0x0000) +#define CFE_TBL_OPT_USR_DEF_ADDR (0x0006) /**< \brief NOTE: Automatically includes #CFE_TBL_OPT_DUMP_ONLY option */ + +#define CFE_TBL_OPT_CRITICAL_MSK (0x0008) +#define CFE_TBL_OPT_NOT_CRITICAL (0x0000) +#define CFE_TBL_OPT_CRITICAL (0x0008) + +#define CFE_TBL_OPT_DEFAULT (CFE_TBL_OPT_SNGL_BUFFER | CFE_TBL_OPT_LOAD_DUMP) + +/** Computation for maximum length allowed for a table name.
+** NOTE: "+2" is for NULL Character and "." (i.e. - "AppName.TblName") */ +#define CFE_TBL_MAX_FULL_NAME_LEN_COMP (CFE_TBL_MAX_NAME_LENGTH + OS_MAX_API_NAME + 2) +/* Ensure the table name falls on a 4-byte boundary */ +#define CFE_TBL_MAX_FULL_NAME_LEN (((CFE_TBL_MAX_FULL_NAME_LEN_COMP + 3)/4)*4) + +#define CFE_TBL_BAD_TABLE_HANDLE (CFE_TBL_Handle_t) 0xFFFF + +/****************** Data Type Definitions *********************/ + +typedef int32 (*CFE_TBL_CallbackFuncPtr_t)(void *TblPtr); + +typedef int16 CFE_TBL_Handle_t; + +typedef enum +{ + CFE_TBL_SRC_FILE = 0, /**< When this option is selected, the \c SrcDataPtr + will be interpreted as a pointer to a null + terminated character string. The string should + specify the full path and filename of the file + containing the initial data contents of the table. */ + CFE_TBL_SRC_ADDRESS /**< When this option is selected, the \c SrcDataPtr will + be interpreted as a pointer to a memory location + that is the beginning of the initialization data + for loading the table OR, in the case of a "user defined" + dump only table, the address of the active table itself. + The block of memory is assumed to be of the same size + specified in the #CFE_TBL_Register function Size parameter. */ +} CFE_TBL_SrcEnum_t; + +typedef struct +{ + uint32 Size; /**< \brief Size, in bytes, of Table */ + uint32 NumUsers; /**< \brief Number of Apps with access to the table */ + uint32 FileCreateTimeSecs; /**< \brief File creation time from last file loaded into table */ + uint32 FileCreateTimeSubSecs; /**< \brief File creation time from last file loaded into table */ + uint32 Crc; /**< \brief Most recently calculated CRC by TBL services on table contents */ + CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \brief Time when Table was last updated */ + boolean TableLoadedOnce; /**< \brief Flag indicating whether table has been loaded once or not */ + boolean DumpOnly; /**< \brief Flag indicating Table is NOT to be loaded */ + boolean DblBuffered; /**< \brief Flag indicating Table has a dedicated inactive buffer */ + boolean UserDefAddr; /**< \brief Flag indicating Table address was defined by Owner Application */ + boolean Critical; /**< \brief Flag indicating Table contents are maintained in a CDS */ + char LastFileLoaded[OS_MAX_PATH_LEN]; /**< \brief Filename of last file loaded into table */ +} CFE_TBL_Info_t; + +/*************************** Function Prototypes ******************************/ +/** +** \brief Register a table with cFE to obtain Table Management Services +** +** \par Description +** When an application is created and initialized, it is responsible for creating its table images via +** the TBL API. The application must inform the Table Service of the table name, table size and selection +** of optional table features. +** +** \par Assumptions, External Events, and Notes: +** Note: This function call can block. Therefore, interrupt service routines should NOT create +** their own tables. An application should create any table(s) and provide the handle(s) +** to the interrupt service routine. +** +** \param[in] TblHandlePtr a pointer to a #CFE_TBL_Handle_t type variable that will be assigned the +** table's handle. The table handle is required for other API calls when +** accessing the data contained in the table. +** +** \param[in] Name The application-specific name. This name will be combined with the name of the +** application to produce a processor specific name of the form +** "ApplicationName.TableName". The processor specific name will be used in commands +** for modifying or viewing the contents of the table. +** +** \param[in] Size The size, in bytes, of the table to be created. This is the size that will be +** allocated as a shared memory resource between the Table Management Service and +** the calling application. +** +** \param[in] TblOptionFlags Flag bits indicating selected options for table. A bitwise OR of the following +** option flags: +** \arg #CFE_TBL_OPT_DEFAULT - The default setting for table options is a +** combination of #CFE_TBL_OPT_SNGL_BUFFER and +** #CFE_TBL_OPT_LOAD_DUMP. See below for a +** description of these two options. This option +** is mutually exclusive with the +** #CFE_TBL_OPT_DBL_BUFFER, #CFE_TBL_OPT_DUMP_ONLY +** and #CFE_TBL_OPT_USR_DEF_ADDR options. +** \arg #CFE_TBL_OPT_SNGL_BUFFER - When this option is selected, the table will use +** a shared session table for performing table +** modifications and a memory copy from the session +** table to the "active" table buffer will occur +** when the table is updated. This is the preferred +** option since it will minimize memory usage. +** This option is mutually exclusive with the +** #CFE_TBL_OPT_DBL_BUFFER option +** \arg #CFE_TBL_OPT_DBL_BUFFER - When this option is selected, two instances of +** the table are created. One is considered the +** "active" table and the other the "inactive" table. +** Whenever table modifications occur, they do not +** require the use of a common session table. +** Modifications occur in the "inactive" buffer. +** Then, when it is time to update the table, +** the pointer to the "active" table is changed to +** point to the "inactive" buffer thus making it +** the new "active" buffer. This feature is most +** useful for time critical applications (ie - +** interrupt service routines, etc). This option is +** mutually exclusive with the +** #CFE_TBL_OPT_SNGL_BUFFER and #CFE_TBL_OPT_DEFAULT +** option. +** \arg #CFE_TBL_OPT_LOAD_DUMP - When this option is selected, the Table Service +** is allowed to perform all operations on the +** specified table. This option is mutually +** exclusive with the #CFE_TBL_OPT_DUMP_ONLY option. +** \arg #CFE_TBL_OPT_DUMP_ONLY - When this option is selected, the Table Service +** will not perform table loads to this table. This +** does not prevent, however, a task from writing +** to the table via an address obtained with the +** #CFE_TBL_GetAddress API function. This option is +** mutually exclusive with the #CFE_TBL_OPT_LOAD_DUMP +** and #CFE_TBL_OPT_DEFAULT options. If the Application wishes +** to specify their own block of memory as the Dump Only table, +** they need to also include the #CFE_TBL_OPT_USR_DEF_ADDR option +** explained below. +** \arg #CFE_TBL_OPT_NOT_USR_DEF - When this option is selected, Table Services allocates +** memory for the table and, in the case of a double buffered +** table, it allocates the same amount of memory again for the +** second buffer. This option is mutually exclusive with +** the #CFE_TBL_OPT_USR_DEF_ADDR option. +** \arg #CFE_TBL_OPT_USR_DEF_ADDR- When this option is selected, the Table Service +** will not allocate memory for the table. Table Services +** will require the Application to identify the location of the +** active table buffer via the #CFE_TBL_Load function. This +** option implies the #CFE_TBL_OPT_DUMP_ONLY and the +** #CFE_TBL_OPT_SNGL_BUFFER options and is mutually +** exclusive of the #CFE_TBL_OPT_DBL_BUFFER option. +** \arg #CFE_TBL_OPT_CRITICAL- When this option is selected, the Table Service +** will automatically allocate space in the Critical Data Store (CDS) +** for the table and insure that the contents in the CDS are the same +** as the contents of the currently active buffer for the table. +** This option is mutually exclusive of the #CFE_TBL_OPT_USR_DEF_ADDR +** and #CFE_TBL_OPT_DUMP_ONLY options. It should also be noted that +** the use of this option with double buffered tables will prevent +** the update of the double buffered table from being quick and +** it could be blocked. Therefore, critical tables should not be +** updated by Interrupt Service Routines. +** +** \param[in] TblValidationFuncPtr is a pointer to a function that will be executed in the context of the Table +** Management Service when the contents of a table need to be validated. If set +** to NULL, then the Table Management Service will assume any data is valid. If +** the value is not NULL, it must be a pointer to a function with the following +** prototype:
+** int32 CallbackFunc(void *TblPtr);
+** where
+** TblPtr will be a pointer to the table data that is to be verified. When the +** function returns #CFE_SUCCESS, the data is considered valid and ready for a commit. +** When the function returns a negative value, the data is considered invalid and an +** Event Message will be issued containing the returned value. If the function should +** return a positive number, the table is considered invalid and the return code is +** considered invalid. Validation functions \b must return either #CFE_SUCCESS or a negative +** number (whose value is at the developer's discretion). The validation function +** will be executed in the Application's context so that Event Messages describing the +** validation failure are possible from within the function. +** +** \param[out] *TblHandlePtr Handle used to identify table to cFE when performing Table operations. +** This value is returned at the address specified by TblHandlePtr. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_TBL_INFO_RECOVERED_TBL \retdesc \copydoc CFE_TBL_INFO_RECOVERED_TBL \endcode +** \retcode \retdesc

\endcode +** \retcode #CFE_TBL_ERR_DUPLICATE_DIFF_SIZE \retdesc \copydoc CFE_TBL_ERR_DUPLICATE_DIFF_SIZE \endcode +** \retcode #CFE_TBL_ERR_DUPLICATE_NOT_OWNED \retdesc \copydoc CFE_TBL_ERR_DUPLICATE_NOT_OWNED \endcode +** \retcode #CFE_TBL_ERR_REGISTRY_FULL \retdesc \copydoc CFE_TBL_ERR_REGISTRY_FULL \endcode +** \retcode #CFE_TBL_ERR_HANDLES_FULL \retdesc \copydoc CFE_TBL_ERR_HANDLES_FULL \endcode +** \retcode #CFE_TBL_ERR_INVALID_SIZE \retdesc \copydoc CFE_TBL_ERR_INVALID_SIZE \endcode +** \retcode #CFE_TBL_ERR_INVALID_NAME \retdesc \copydoc CFE_TBL_ERR_INVALID_NAME \endcode +** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode +** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \endreturns +** +** \sa #CFE_TBL_Unregister, #CFE_TBL_Share +**/ +int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, /* Returned Handle */ + const char *Name, /* Application specific name */ + uint32 Size, /* Size, in bytes, of table */ + uint16 TblOptionFlags, /* Tbl Options Settings */ + CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr ); /* Ptr to func that validates tbl */ + +/*****************************************************************************/ +/** +** \brief Obtain handle of table registered by another application +** +** \par Description +** After a table has been created, other applications can gain access +** to that table via the table handle. In order for two or more +** applications to share a table, the applications that do not create +** the table must obtain the handle using this function. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TblHandlePtr A pointer to a #CFE_TBL_Handle_t type variable +** that will be assigned the table's handle. The +** table handle is required for other API calls +** when accessing the data contained in the table. +** +** \param[in] TblName The processor specific name of the table. It is important to note +** that the processor specific table name is different from the table +** name specified in the #CFE_TBL_Register API call. The processor +** specific table name includes the name of the application that created +** the table. The name would be of the form "ApplicationName.TableName". +** An example of this would be "ACS.TamParams" for a table called "TamParams" +** that was registered by the application called "ACS". +** +** \param[out] *TblHandlePtr Handle used to identify table to cFE when performing Table operations. +** This value is returned at the address specified by TblHandlePtr. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode \retdesc

\endcode +** \retcode #CFE_TBL_ERR_HANDLES_FULL \retdesc \copydoc CFE_TBL_ERR_HANDLES_FULL \endcode +** \retcode #CFE_TBL_ERR_INVALID_NAME \retdesc \copydoc CFE_TBL_ERR_INVALID_NAME \endcode +** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode +** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \endreturns +** +** \sa #CFE_TBL_Unregister, #CFE_TBL_Register +** +******************************************************************************/ +int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, /* Returned Handle */ + const char *TblName ); + +/*****************************************************************************/ +/** +** \brief Unregister a previously registered table and free associated resources +** +** \par Description +** When an application is being removed from the system, it should +** unregister those tables that it created. The application should +** call this function as a part of its cleanup process. The table +** will be removed from memory once all table addresses referencing +** it have been released. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, +** that identifies the Table to be unregistered. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode \retdesc

\endcode +** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode +** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode +** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode +** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \endreturns +** +** \sa #CFE_TBL_Share, #CFE_TBL_Register +** +******************************************************************************/ +int32 CFE_TBL_Unregister ( CFE_TBL_Handle_t TblHandle ); + +/*****************************************************************************/ +/** +** \brief Load a specified table with data from specified source +** +** \par Description +** Once an application has created a table (#CFE_TBL_Register), it must +** provide the values that initialize the contents of that table. The +** application accomplishes this with one of two different TBL API calls. +** This function call initializes the table with values that are held +** in a data structure. +** +** \par Assumptions, External Events, and Notes: +** This function call can block. Therefore, interrupt service routines +** should NOT initialize their own tables. An application should initialize +** any table(s) prior to providing the handle(s) to the interrupt service routine. +** +** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that +** identifies the Table to be loaded. +** +** \param[in] SrcType Flag indicating the nature of the given \c SrcDataPtr below. +** This value can be any one of the following: +** \arg #CFE_TBL_SRC_FILE - \copydoc CFE_TBL_SRC_FILE +** \arg #CFE_TBL_SRC_ADDRESS - \copydoc CFE_TBL_SRC_ADDRESS +** +** \param[in] SrcDataPtr Pointer to either a character string specifying a filename or +** a memory address of a block of binary data to be loaded into a table or, +** if the table was registered with the #CFE_TBL_OPT_USR_DEF_ADDR option, +** the address of the active table buffer. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_TBL_WARN_SHORT_FILE \retdesc \copydoc CFE_TBL_WARN_SHORT_FILE \endcode +** \retcode #CFE_TBL_WARN_PARTIAL_LOAD \retdesc \copydoc CFE_TBL_WARN_PARTIAL_LOAD \endcode +** \retcode \retdesc

\endcode +** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode +** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode +** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode +** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \retcode #CFE_TBL_ERR_DUMP_ONLY \retdesc \copydoc CFE_TBL_ERR_DUMP_ONLY \endcode +** \retcode #CFE_TBL_ERR_ILLEGAL_SRC_TYPE \retdesc \copydoc CFE_TBL_ERR_ILLEGAL_SRC_TYPE \endcode +** \retcode #CFE_TBL_ERR_LOAD_IN_PROGRESS \retdesc \copydoc CFE_TBL_ERR_LOAD_IN_PROGRESS \endcode +** \retcode #CFE_TBL_ERR_NO_BUFFER_AVAIL \retdesc \copydoc CFE_TBL_ERR_NO_BUFFER_AVAIL \endcode +** \retcode #CFE_TBL_ERR_FILE_NOT_FOUND \retdesc \copydoc CFE_TBL_ERR_FILE_NOT_FOUND \endcode +** \retcode #CFE_TBL_ERR_FILE_TOO_LARGE \retdesc \copydoc CFE_TBL_ERR_FILE_TOO_LARGE \endcode +** \retcode #CFE_TBL_ERR_BAD_CONTENT_ID \retdesc \copydoc CFE_TBL_ERR_BAD_CONTENT_ID \endcode +** \retcode #CFE_TBL_ERR_PARTIAL_LOAD \retdesc \copydoc CFE_TBL_ERR_PARTIAL_LOAD \endcode +** \endreturns +** +** \sa #CFE_TBL_Update, #CFE_TBL_Validate, #CFE_TBL_Manage +** +******************************************************************************/ +int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, + CFE_TBL_SrcEnum_t SrcType, + const void *SrcDataPtr ); + +/*****************************************************************************/ +/** +** \brief Update contents of a specified table, if an update is pending +** +** \par Description +** An application is \b required to perform a periodic check for an update +** for all the tables that it creates. Typically, the application that +** created the table would call this function at the start or conclusion +** of any routine processing cycle or at regular intervals. To determine +** whether an update is pending prior to making this call, the Application +** can use the #CFE_TBL_GetStatus API first. If a table update is pending, +** it will take place during this function call. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that +** identifies the Table to be updated. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_TBL_INFO_NO_UPDATE_PENDING \retdesc \copydoc CFE_TBL_INFO_NO_UPDATE_PENDING \endcode +** \retcode \retdesc

\endcode +** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode +** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode +** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode +** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \endreturns +** +** \sa #CFE_TBL_Load, #CFE_TBL_Validate, #CFE_TBL_Manage +** +******************************************************************************/ +int32 CFE_TBL_Update( CFE_TBL_Handle_t TblHandle ); + +/*****************************************************************************/ +/** +** \brief Obtain the current address of the contents of the specified table +** +** \par Description +** When a table has been created and initialized, it is available to +** any application that can identify it with its unique handle. In +** order to view the data contained in the table, an application must +** call this function or #CFE_TBL_GetAddresses. +** +** \par Assumptions, External Events, and Notes: +** -# This call can be a blocking call when the table is not double buffered +** and is shared with another application of lower priority that just happens +** to be in the middle of a table update of the specific table. If this occurs, +** the application performing the table update will automatically have its +** priority elevated in order to release the resource as soon as possible. +** -# An application must always release the returned table address using the +** #CFE_TBL_ReleaseAddress or #CFE_TBL_ReleaseAddresses function prior to +** either a #CFE_TBL_Update call or any blocking call (e.g. - pending on software +** bus message, etc). Table updates cannot occur while table addresses have not +** been released. +** +** \param[in] TblPtr The address of a pointer that will be loaded with the address of +** the first byte of the table. This pointer can then be typecast +** by the calling application to the appropriate table data structure. +** +** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that +** identifies the Table whose address is to be returned. +** +** \param[out] *TblPtr Address of the first byte of data associated with the specified table. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_TBL_INFO_UPDATED \retdesc \copydoc CFE_TBL_INFO_UPDATED \endcode +** \retcode \retdesc

\endcode +** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode +** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode +** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode +** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \retcode #CFE_TBL_ERR_UNREGISTERED \retdesc \copydoc CFE_TBL_ERR_UNREGISTERED \endcode +** \retcode #CFE_TBL_ERR_NEVER_LOADED \retdesc \copydoc CFE_TBL_ERR_NEVER_LOADED \endcode +** \endreturns +** +** \sa #CFE_TBL_ReleaseAddress, #CFE_TBL_GetAddresses, #CFE_TBL_ReleaseAddresses +** +******************************************************************************/ +int32 CFE_TBL_GetAddress( void **TblPtr, + CFE_TBL_Handle_t TblHandle ); + +/*****************************************************************************/ +/** +** \brief Release previously obtained pointer to the contents of the specified table +** +** \par Description +** Each application is \b required to release a table address obtained through +** the #CFE_TBL_GetAddress function. +** +** \par Assumptions, External Events, and Notes: +** An application must always release the returned table address using the +** #CFE_TBL_ReleaseAddress function prior to either a #CFE_TBL_Update call +** or any blocking call (e.g. - pending on software bus message, etc). +** Table updates cannot occur while table addresses have not been released. +** +** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that +** identifies the Table whose address is to be released. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_TBL_INFO_UPDATED \retdesc \copydoc CFE_TBL_INFO_UPDATED \endcode +** \retcode \retdesc

\endcode +** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode +** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode +** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode +** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \retcode #CFE_TBL_ERR_NEVER_LOADED \retdesc \copydoc CFE_TBL_ERR_NEVER_LOADED \endcode +** \endreturns +** +** \sa #CFE_TBL_GetAddress, #CFE_TBL_GetAddresses, #CFE_TBL_ReleaseAddresses +** +******************************************************************************/ +int32 CFE_TBL_ReleaseAddress( CFE_TBL_Handle_t TblHandle ); + +/*****************************************************************************/ +/** +** \brief Obtain the current addresses of an array of specified tables +** +** \par Description +** When a table has been created and initialized, it is available to +** any application that can identify it with its unique handle. In +** order to view the data contained in the table, an application must +** call this function or #CFE_TBL_GetAddresses. +** +** \par Assumptions, External Events, and Notes: +** -# This call can be a blocking call when the table is not double buffered +** and is shared with another application of lower priority that just happens +** to be in the middle of a table update of the specific table. If this occurs, +** the application performing the table update will automatically have its +** priority elevated in order to release the resource as soon as possible. +** -# An application must always release the returned table address using the +** #CFE_TBL_ReleaseAddress or #CFE_TBL_ReleaseAddresses function prior to +** either a #CFE_TBL_Update call or any blocking call (e.g. - pending on software +** bus message, etc). Table updates cannot occur while table addresses have not +** been released. +** +** \param[in] TblPtrs Array of Pointers to variables that calling Application +** wishes to hold the start addresses of the Tables. +** +** \param[in] NumTables Size of TblPtrs and TblHandles arrays. +** +** \param[in] TblHandles Array of Table Handles, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, +** of those tables whose start addresses are to be obtained. +** +** \param[out] *TblPtrs Array of addresses of the first byte of data associated with the +** specified tables. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_TBL_INFO_UPDATED \retdesc \copydoc CFE_TBL_INFO_UPDATED \endcode +** \retcode \retdesc

\endcode +** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode +** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode +** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode +** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \retcode #CFE_TBL_ERR_UNREGISTERED \retdesc \copydoc CFE_TBL_ERR_UNREGISTERED \endcode +** \retcode #CFE_TBL_ERR_NEVER_LOADED \retdesc \copydoc CFE_TBL_ERR_NEVER_LOADED \endcode +** \endreturns +** +** \sa #CFE_TBL_GetAddress, #CFE_TBL_ReleaseAddress, #CFE_TBL_ReleaseAddresses +** +******************************************************************************/ +int32 CFE_TBL_GetAddresses( void **TblPtrs[], + uint16 NumTables, + const CFE_TBL_Handle_t TblHandles[] ); + +/*****************************************************************************/ +/** +** \brief Release the addresses of an array of specified tables +** +** \par Description +** Each application is \b required to release a table address obtained through +** the #CFE_TBL_GetAddress function. +** +** \par Assumptions, External Events, and Notes: +** An application must always release the returned table address using the +** #CFE_TBL_ReleaseAddress function prior to either a #CFE_TBL_Update call +** or any blocking call (e.g. - pending on software bus message, etc). +** Table updates cannot occur while table addresses have not been released. +** +** \param[in] NumTables Size of TblHandles array. +** +** \param[in] TblHandles Array of Table Handles, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, +** of those tables whose start addresses are to be released. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_TBL_INFO_UPDATED \retdesc \copydoc CFE_TBL_INFO_UPDATED \endcode +** \retcode \retdesc

\endcode +** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode +** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode +** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode +** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \retcode #CFE_TBL_ERR_NEVER_LOADED \retdesc \copydoc CFE_TBL_ERR_NEVER_LOADED \endcode +** \endreturns +** +** \sa #CFE_TBL_GetAddress, #CFE_TBL_ReleaseAddress, #CFE_TBL_GetAddresses +** +******************************************************************************/ +int32 CFE_TBL_ReleaseAddresses( uint16 NumTables, + const CFE_TBL_Handle_t TblHandles[] ); + +/*****************************************************************************/ +/** +** \brief Perform steps to validate the contents of a table image. +** +** \par Description +** An application is \b required to perform a periodic check for an update +** or a validation request for all the tables that it creates. Typically, +** the application that created the table would call this function at the +** start or conclusion of any routine processing cycle. To determine whether +** a validation request is pending prior to making this call, the Application +** can use the #CFE_TBL_GetStatus API first. If a table validation is pending, +** the Application would call this function to perform the necessary actions. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that +** identifies the Table to be managed. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_TBL_INFO_NO_VALIDATION_PENDING \retdesc \copydoc CFE_TBL_INFO_NO_VALIDATION_PENDING \endcode +** \retcode \retdesc

\endcode +** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode +** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode +** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode +** \endreturns +** +** \sa #CFE_TBL_Update, #CFE_TBL_Manage, #CFE_TBL_Load +** +******************************************************************************/ +int32 CFE_TBL_Validate( CFE_TBL_Handle_t TblHandle ); + +/*****************************************************************************/ +/** +** \brief Perform standard operations to maintain a table. +** +** \par Description +** An application is \b required to perform a periodic check for an update +** or a validation request for all the tables that it creates. Typically, +** the application that created the table would call this function at the +** start or conclusion of any routine processing cycle. If a table update +** or validation request is pending, this function would perform either or +** both before returning. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that +** identifies the Table to be managed. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_TBL_INFO_UPDATED \retdesc \copydoc CFE_TBL_INFO_UPDATED \endcode +** \retcode \retdesc

\endcode +** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode +** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode +** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode +** \endreturns +** +** \sa #CFE_TBL_Update, #CFE_TBL_Validate, #CFE_TBL_Load, #CFE_TBL_DumpToBuffer +** +******************************************************************************/ +int32 CFE_TBL_Manage( CFE_TBL_Handle_t TblHandle ); + +/*****************************************************************************/ +/** +** \brief Obtain current status of pending actions for a table. +** +** \par Description +** An application is \b required to perform a periodic check for an update +** or a validation request for all the tables that it creates. Typically, +** the application that created the table would call this function at the +** start or conclusion of any routine processing cycle. If a table update +** or validation request is pending, the Application should follow up with +** a call to #CFE_TBL_Update or #CFE_TBL_Validate respectively. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that +** identifies the Table to be managed. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_TBL_INFO_UPDATE_PENDING \retdesc \copydoc CFE_TBL_INFO_UPDATE_PENDING \endcode +** \retcode #CFE_TBL_INFO_VALIDATION_PENDING \retdesc \copydoc CFE_TBL_INFO_VALIDATION_PENDING \endcode +** \retcode #CFE_TBL_INFO_DUMP_PENDING \retdesc \copydoc CFE_TBL_INFO_DUMP_PENDING \endcode +** \retcode \retdesc

\endcode +** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode +** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode +** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode +** \endreturns +** +** \sa #CFE_TBL_Manage, #CFE_TBL_Update, #CFE_TBL_Validate, #CFE_TBL_GetInfo +** +******************************************************************************/ +int32 CFE_TBL_GetStatus( CFE_TBL_Handle_t TblHandle ); + + +/*****************************************************************************/ +/** +** \brief Obtain characteristics/information of/about a specified table. +** +** \par Description +** This API provides the registry information associated with the specified +** table. The function fills the given data structure with the data found +** in the Table Registry. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TblInfoPtr A pointer to a CFE_TBL_Info_t data structure that is to be populated +** with table characteristics and information. +** +** \param[in] TblName The processor specific name of the table. It is important to note +** that the processor specific table name is different from the table +** name specified in the #CFE_TBL_Register API call. The processor +** specific table name includes the name of the application that created +** the table. The name would be of the form "ApplicationName.TableName". +** An example of this would be "ACS.TamParams" for a table called "TamParams" +** that was registered by the application called "ACS". +** +** \param[out] *TblInfoPtr Description of the tables characteristics and registry information stored in +** the #CFE_TBL_Info_t data structure format. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode \retdesc

\endcode +** \retcode #CFE_TBL_ERR_INVALID_NAME \retdesc \copydoc CFE_TBL_ERR_INVALID_NAME \endcode +** \endreturns +** +** \sa #CFE_TBL_GetStatus +** +******************************************************************************/ +int32 CFE_TBL_GetInfo( CFE_TBL_Info_t *TblInfoPtr, const char *TblName ); + +/*****************************************************************************/ +/** +** \brief Copies the contents of a Dump Only Table to a shared buffer +** +** \par Description +** Copies contents of a Dump Only table to a shared buffer so that it +** can be written to a file by the Table Services routine. This function +** is called by the Application that owns the table in response to a #CFE_TBL_INFO_DUMP_PENDING +** status obtained via #CFE_TBL_GetStatus. +** +** \par Assumptions, External Events, and Notes: +** -# If the table does not have a dump pending status, nothing will occur (no error, no dump) +** -# Applications may wish to use this function in lieu of #CFE_TBL_Manage for their Dump Only tables +** +** \param[in] TblHandle Handle of Table to be dumped. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode \retdesc

\endcode +** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode +** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode +** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode +** \endreturns +** +** \sa #CFE_TBL_Manage +** +******************************************************************************/ +int32 CFE_TBL_DumpToBuffer( CFE_TBL_Handle_t TblHandle ); + +/*****************************************************************************/ +/** +** \brief Notify cFE Table Services that table contents have been modified by the Application +** +** \par Description +** This API notifies Table Services that the contents of the specified table has been +** modified by the Application. This notification is important when a table has been +** registered as "Critical" because Table Services can then update the contents of the +** table kept in the Critical Data Store. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TblHandle Handle of Table that was modified. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode \retdesc

\endcode +** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode +** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode +** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode +** \endreturns +** +** \sa #CFE_TBL_Manage +** +******************************************************************************/ +int32 CFE_TBL_Modified( CFE_TBL_Handle_t TblHandle ); + + +/*****************************************************************************/ +/** +** \brief Instruct cFE Table Services to notify Application via message when table requires management +** +** \par Description +** This API instructs Table Services to send a message to the calling Application +** whenever the specified table requires management by the application. This feature +** allows applications to avoid polling table services via the #CFE_TBL_Manage call +** to determine whether a table requires updates, validation, etc. This API should +** be called following the #CFE_TBL_Register API whenever the owning application requires +** this feature. +** +** \par Assumptions, External Events, and Notes: +** - Only the application that owns the table is allowed to register a notification message +** +** \param[in] TblHandle Handle of Table with which the message should be associated. +** +** \param[in] MsgId Message ID to be used in notification message sent by Table Services. +** +** \param[in] CommandCode Command Code value to be placed in secondary header of message +** sent by Table Services. +** +** \param[in] Parameter Application defined value to be passed as a parameter in the +** message sent by Table Services. Suggested use includes an application's +** table index that allows the same MsgId and Command Code to be used for +** all table management notifications. +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode \retdesc

\endcode +** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode +** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode +** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode +** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode +** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode +** \endreturns +** +** \sa #CFE_TBL_Register +** +******************************************************************************/ +int32 CFE_TBL_NotifyByMessage(CFE_TBL_Handle_t TblHandle, uint32 MsgId, uint16 CommandCode, uint32 Parameter); + +#endif /* _cfe_tbl_ */ diff --git a/src/components/interface/cFE/cfe_tbl_events.h b/src/components/interface/cFE/cfe_tbl_events.h new file mode 100644 index 0000000000..661d1bc7f4 --- /dev/null +++ b/src/components/interface/cFE/cfe_tbl_events.h @@ -0,0 +1,1082 @@ +/* +** +** $Id: cfe_tbl_events.h 1.9 2014/08/19 13:38:15GMT-05:00 sstrege Exp $ +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Title: Table Services API Event ID Header File +** +** Purpose: +** Identifies event codes for event messages issued by Table Services. +** +** Design Notes: +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** +** Notes: +** +** $Log: cfe_tbl_events.h $ +** Revision 1.9 2014/08/19 13:38:15GMT-05:00 sstrege +** Fixed doxygen warning +** Revision 1.8 2011/12/28 14:00:18EST lwalling +** Add definition for CFE_TBL_SPACECRAFT_ID_ERR_EID and CFE_TBL_PROCESSOR_ID_ERR_EID +** Revision 1.7 2011/11/14 17:58:05EST lwalling +** Event EID mentioned in previous log entry should have been CFE_TBL_LOAD_EXCEEDS_SIZE_ERR_EID +** Revision 1.6 2011/11/14 17:42:30EST lwalling +** Modified event text and argument list for CFE_TBL_FILE_INCOMPLETE_ERR_EID +** Revision 1.5 2010/10/27 13:53:54EDT dkobe +** Added error event for Notification Message send failure +** Revision 1.4 2010/10/25 15:01:12EDT jmdagost +** Corrected bad apostrophe in prologue. +** Revision 1.3 2010/10/04 15:24:56EDT jmdagost +** Cleaned up copyright symbol. +** Revision 1.2 2009/05/01 12:41:44EDT dkobe +** Corrected a few doxygen comments +** Revision 1.1 2008/04/17 08:05:24EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.28 2007/07/11 11:51:44EDT David Kobe (dlkobe) +** Corrected erroneously assigned Event ID for CFE_TBL_ASSUMED_VALID_INF_EID +** Revision 1.27 2007/07/07 09:22:29EDT dlkobe +** Added event (CFE_TBL_LOAD_PENDING_ERR_EID) for attempt to load pending load table +** Revision 1.26 2007/07/07 07:53:35EDT dlkobe +** Added CFE_TBL_ASSUMED_VALID_INF_EID event message +** Revision 1.25 2007/06/02 10:10:12EDT dlkobe +** Added doxygen comments for User's Guides +** Revision 1.24 2007/05/25 16:24:50EDT dlkobe +** Continued updating doxygen comments +** Revision 1.23 2007/05/23 11:21:58EDT dlkobe +** Added doxygen formatting +** Revision 1.22 2007/05/15 11:18:08EDT rjmcgraw +** DCR78:11 Removed event CFE_TBL_EXIT_ERR_EID +** Revision 1.21 2007/05/04 15:54:39EDT dlkobe +** Added event messages associated with deleting a critical table's CDS +** Revision 1.20 2007/03/16 14:59:41EST dlkobe +** Using file version 1.14 and applying all changes since to avoid corrupted versions. +** +** +**/ + +#ifndef _cfe_tbl_events_ +#define _cfe_tbl_events_ + +/******************* Macro Definitions ***********************/ +/* +** Event message ID's +*/ + +/** \name Informational Event Message IDs */ +/** \{ */ +/** \brief 'Task Initialized' +** \event 'Task Initialized' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always automatically issued when the Table Services +** Task completes its Initialization. +**/ +#define CFE_TBL_INIT_INF_EID 1 + +/** \name Command Response Informational Event Message IDs */ +/** \{ */ + +/** \brief 'No-op command' +** \event 'No-op command' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always automatically issued in response +** to a cFE Table Services \link #CFE_TBL_NOOP_CC NO-OP command \endlink +**/ +#define CFE_TBL_NOOP_INF_EID 10 + +/** \brief 'Reset Counters command' +** \event 'Reset Counters command' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always automatically issued in response +** to a cFE Table Services \link #CFE_TBL_RESET_CC Reset Counters command \endlink +**/ +#define CFE_TBL_RESET_INF_EID 11 + +/** \brief 'Successful load of '\%s' into '\%s' working buffer' +** \event 'Successful load of '\%s' into '\%s' working buffer' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always generated after a successful execution of +** a cFE Table Services \link #CFE_TBL_LOAD_CC Load Table command \endlink +**/ +#define CFE_TBL_FILE_LOADED_INF_EID 12 + +/** \brief 'Successfully overwrote '\%s' with Table '\%s'' +** \event 'Successfully overwrote '\%s' with Table '\%s'' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always generated after a successful execution of +** a cFE Table Services \link #CFE_TBL_DUMP_CC Dump Table command \endlink where +** the command specified target filename was the same as a file already present +** in the onboard filesystem. If the specified file did not exist, the event +** message would have been #CFE_TBL_WRITE_DUMP_INF_EID. +**/ +#define CFE_TBL_OVERWRITE_DUMP_INF_EID 13 + +/** \brief 'Successfully dumped Table '\%s' to '\%s'' +** \event 'Successfully dumped Table '\%s' to '\%s'' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always generated after a successful execution of +** a cFE Table Services \link #CFE_TBL_DUMP_CC Dump Table command \endlink where +** the command specified target filename was a currently non-existent file. If +** the file did already exist, the event message would have been +** #CFE_TBL_OVERWRITE_DUMP_INF_EID. +**/ +#define CFE_TBL_WRITE_DUMP_INF_EID 14 + +/** \brief 'Successfully overwrote '\%s' with Table Registry' +** \event 'Successfully overwrote '\%s' with Table Registry' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is always generated after a successful execution of +** a cFE Table Services \link #CFE_TBL_DUMP_REG_CC Dump Table Registry command \endlink where +** the command specified target filename was the same as a file already present +** in the onboard filesystem. If the specified file did not exist, the event +** message would have been #CFE_TBL_WRITE_REG_DUMP_INF_EID. +**/ +#define CFE_TBL_OVERWRITE_REG_DUMP_INF_EID 15 + +/** \brief 'Tbl Services issued validation request for '\%s'' +** \event 'Tbl Services issued validation request for '\%s'' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon successful execution of +** a cFE Table Services \link #CFE_TBL_VALIDATE_CC Validate Table command \endlink. +** It should be noted, however, that this Event Message does NOT indicate completion of +** the Table Validation. It is ONLY indicating that the appropriate flag has been +** set to NOTIFY the table's owning Application that a Validation has been requested. +** Completion of the Validation is indicated by either the #CFE_TBL_VALIDATION_INF_EID or +** #CFE_TBL_VALIDATION_ERR_EID event messages. +**/ +#define CFE_TBL_VAL_REQ_MADE_INF_EID 16 + +/** \brief 'Tbl Services notifying App that '\%s' has a load pending' +** \event 'Tbl Services notifying App that '\%s' has a load pending' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon successful execution of +** a cFE Table Services \link #CFE_TBL_ACTIVATE_CC Activate Table command \endlink. +** It should be noted, however, that this Event Message does NOT indicate completion of +** the Table Activation. It is ONLY indicating that the appropriate flag has been +** set to NOTIFY the table's owning Application that an Update has been requested. +** Completion of the Update is indicated by either the #CFE_TBL_UPDATE_SUCCESS_INF_EID or +** #CFE_TBL_UPDATE_ERR_EID event messages. +**/ +#define CFE_TBL_LOAD_PEND_REQ_INF_EID 17 + +/** \brief 'Table Registry entry for '\%s' will be telemetered' +** \event 'Table Registry entry for '\%s' will be telemetered' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is generated upon successful execution of +** a cFE Table Services \link #CFE_TBL_TLM_REG_CC Telemeter Table Registry Entry command \endlink. +** Subsequent Table Services Housekeeping Telemetry should contain the desired Table Registry Entry data. +**/ +#define CFE_TBL_TLM_REG_CMD_INF_EID 18 + +/** \brief 'Table Load Aborted for '\%s'' +** \event 'Table Load Aborted for '\%s'' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated upon successful execution of +** a cFE Table Services \link #CFE_TBL_ABORT_LOAD_CC Abort Table Load command \endlink. +**/ +#define CFE_TBL_LOAD_ABORT_INF_EID 21 + +/** \brief 'Successfully dumped Table Registry to '\%s':Size=\%d,Entries=\%d' +** \event 'Successfully dumped Table Registry to '\%s':Size=\%d,Entries=\%d' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is always generated after a successful execution of +** a cFE Table Services \link #CFE_TBL_DUMP_REG_CC Dump Table Registry command \endlink where +** the command specified target filename was a currently non-existent file. If +** the file did already exist, the event message would have been +** #CFE_TBL_OVERWRITE_REG_DUMP_INF_EID. +**/ +#define CFE_TBL_WRITE_REG_DUMP_INF_EID 22 + +/** \brief 'Tbl Services assumes '\%s' is valid. No Validation Function has been registered' +** \event 'Tbl Services assumes '\%s' is valid. No Validation Function has been registered' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated when Table Services has received a Validation Command +** for a table that never specified a Validation Function when it was registered via the +** #CFE_TBL_Register API. +**/ +#define CFE_TBL_ASSUMED_VALID_INF_EID 23 +/** \} */ + + +/** \name Command Error Event Message IDs */ +/** \{ */ +/** \brief 'Invalid message ID -- ID = 0x\%X' +** \event 'Invalid message ID -- ID = 0x\%X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a message has arrived on +** the cFE Table Services Application's Message Pipe that has a +** Message ID that is neither #CFE_TBL_SEND_HK_MID or #CFE_TBL_CMD_MID. +** Most likely, the cFE Software Bus routing table has become corrupt +** and is sending messages targeted for other Applications to the cFE +** Table Services Application. +** +** The \c ID field in the event message identifies +** the message ID (in hex) that was found in the message. +**/ +#define CFE_TBL_MID_ERR_EID 50 + +/** \brief 'Invalid command code -- ID = 0x\%X, CC = \%d' +** \event 'Invalid command code -- ID = 0x\%X, CC = \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a message with the #CFE_TBL_CMD_MID +** message ID has arrived but whose Command Code is not one of the command +** codes specified in \link #CFE_TBL_NOOP_CC cfe_tbl_msg.h \endlink. This +** problem is most likely to occur when: +** -# A Message ID meant for another Application became corrupted and was +** set equal to #CFE_TBL_CMD_MID. +** -# The Command Code field in the Message became corrupted. +** -# The command database at the ground station has been corrupted. +** +** The \c ID field in the event message specifies the Message ID (in hex) and the +** \c CC field specifies the Command Code (in decimal) found in the message. +**/ +#define CFE_TBL_CC1_ERR_EID 51 + +/** \brief 'Invalid cmd pkt -- ID = 0x\%X, CC = \%d, Len = \%d' +** \event 'Invalid cmd pkt -- ID = 0x\%X, CC = \%d, Len = \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a message with the #CFE_TBL_CMD_MID +** message ID has arrived but whose packet length does not match the expected +** length for the specified command code. +** +** The \c ID field in the event message specifies the Message ID (in hex), the \c CC field +** specifies the Command Code (in decimal) and \c Len specifies the message Length (in decimal) +** found in the message. +**/ +#define CFE_TBL_LEN_ERR_EID 52 + +/** \brief 'Unable to open file '\%s' for table load, Status = 0x\%08X' +** \event 'Unable to open file '\%s' for table load, Status = 0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated upon receipt of a +** \link #CFE_TBL_LOAD_CC Load Table command \endlink when +** the specified file containing the table image to be loaded +** cannot be opened. Possible causes for this are: +** +** -# The filename was misspelled +** -# The path to the file was incorrect +** -# The length of the filename and/or path exceeds the +** allowable length (see #OS_MAX_PATH_LEN and #OS_MAX_FILE_NAME, respectively) +** +** The \c Status field in the event message indicates the error code returned by the #OS_open +** API. +**/ +#define CFE_TBL_FILE_ACCESS_ERR_EID 53 + +/** \brief 'Unable to read std header for '\%s', Status = 0x\%08X' +** \event 'Unable to read std header for '\%s', Status = 0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a read failure occurs during the reading of the +** \link #CFE_FS_Header_t cFE Standard File Header \endlink of a table image file specified +** either by an Application calling the #CFE_TBL_Load API or in response to a command to +** Table Services requesting a table image file be loaded into an inactive buffer. +** +** The \c Status field of the event message contains the error code returned by #CFE_FS_ReadHeader. +**/ +#define CFE_TBL_FILE_STD_HDR_ERR_EID 54 + +/** \brief 'Unable to read tbl header for '\%s', Status = 0x\%08X' +** \event 'Unable to read tbl header for '\%s', Status = 0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a read failure occurs during the reading of the +** \link #CFE_TBL_File_Hdr_t cFE Table File Secondary Header \endlink of a table image file specified +** either by an Application calling the #CFE_TBL_Load API or in response to a command to +** Table Services requesting a table image file be loaded into an inactive buffer. +** +** The \c Status field of the event message contains the error code returned by #OS_read. +**/ +#define CFE_TBL_FILE_TBL_HDR_ERR_EID 55 + +/** \brief 'Unable to send Hk Packet (Status=0x\%08X)' +** \event 'Unable to send Hk Packet (Status=0x\%08X)' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when failure occurs while attempting to send the +** Housekeeping Message over the Software Bus. +** +** The \c Status field of the event message contains the error code returned by #CFE_SB_SendMsg. +**/ +#define CFE_TBL_FAIL_HK_SEND_ERR_EID 56 + +/** \brief 'Unable to locate '\%s' in Table Registry' +** \event 'Unable to locate '\%s' in Table Registry' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a command that specifies a table name +** has a table name that is not found in the Table Registry. Most likely causes +** for this are: +** -# Table name was misspelled in the command. +** -# The Application that Registered the Table has either failed to run or +** has been terminated thus removing the Table from the Registry. +** -# The Table Registry has become corrupted. +**/ +#define CFE_TBL_NO_SUCH_TABLE_ERR_EID 57 + +/** \brief 'File '\%s' is not a cFE file type, ContentType = 0x\%08X' +** \event 'File '\%s' is not a cFE file type, ContentType = 0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when either an Application calls the #CFE_TBL_Load API +** or a Table Load command has been received and the specified file has a \link #CFE_FS_Header_t +** cFE Standard File Header \endlink whose \link #CFE_FS_Header_t::ContentType Content Type \endlink +** is not equal to the expected #CFE_FS_FILE_CONTENT_ID. Most likely causes for this are: +** -# The specified file is not a cFE compatible file. +** -# The specified file has been created with bad "endianess" (headers should always conform to +** a big endian format). +** -# The specified file has become corrupted. +** +** The \c ContentType field specified in the event message contains the content type that was found +** in the specified file. +**/ +#define CFE_TBL_FILE_TYPE_ERR_EID 58 + +/** \brief 'File subtype for '\%s' is wrong. Subtype = 0x\%08X' +** \event 'File subtype for '\%s' is wrong. Subtype = 0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when either an Application calls the #CFE_TBL_Load API +** or a Table Load command has been received and the specified file has a \link #CFE_FS_Header_t +** cFE Standard File Header \endlink whose \link #CFE_FS_Header_t::SubType Sub Type \endlink +** is not equal to the expected #CFE_FS_TBL_IMG_SUBTYPE. Most likely causes for this are: +** -# The specified file is not a cFE table image file. +** -# The specified file has been created with bad "endianess" (headers should always conform to +** a big endian format). +** -# The specified file has become corrupted. +** +** The \c SubType field specified in the event message contains the sub type that was found +** in the specified file. +**/ +#define CFE_TBL_FILE_SUBTYPE_ERR_EID 59 + +/** \brief 'No working buffers available for table '\%s'' +** \event 'No working buffers available for table '\%s'' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when either a Table Load Command for a Single Buffered Table +** or a Table Dump Command for a Dump Only Table has been sent AND there are no Shared Buffers +** available to hold either the load image or the dump image. To free a Shared Buffer, either +** a previously loaded table image must be activated or aborted OR the operator has to wait for +** previously dumped Dump Only tables have had a chance to be written to a file (which occurs +** whenever the cFE Table Services receives a Housekeeping Request). +**/ +#define CFE_TBL_NO_WORK_BUFFERS_ERR_EID 60 + +/** \brief 'Internal Error (Status=0x\%08X)' +** \event 'Internal Error (Status=0x\%08X)' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Load command was issued and the cFE Table Services +** is unable to allocate a working table buffer for an unexpected reason. +** +** The \c Status field provides the return status from the function that was to provide a working buffer. +**/ +#define CFE_TBL_INTERNAL_ERROR_ERR_EID 61 + +/** \brief 'Error creating dump file '\%s', Status=0x\%08X' +** \event 'Error creating dump file '\%s', Status=0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Dump or Table Registry Dump command was +** received and the cFE Table Services is unable to create the specified file. +** +** The \c Status field provides the return status from the #OS_creat function call. +**/ +#define CFE_TBL_CREATING_DUMP_FILE_ERR_EID 62 + +/** \brief 'Error writing cFE File Header to '\%s', Status=0x\%08X' +** \event 'Error writing cFE File Header to '\%s', Status=0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Dump or Table Registry Dump command was +** received and the cFE Table Services is unable to write the standard cFE File Header +** to the specified file. +** +** The \c Status field provides the return status from the #CFE_FS_WriteHeader function call. +**/ +#define CFE_TBL_WRITE_CFE_HDR_ERR_EID 63 + +/** \brief 'Error writing Tbl image File Header to '\%s', Status=0x\%08X' +** \event 'Error writing Tbl image File Header to '\%s', Status=0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Dump command was received and the +** cFE Table Services is unable to write the standard cFE Table Image Header to the specified file. +** +** The \c Status field provides the return status from the #OS_write function call. +**/ +#define CFE_TBL_WRITE_TBL_HDR_ERR_EID 64 + +/** \brief 'Error writing Tbl image to '\%s', Status=0x\%08X' +** \event 'Error writing Tbl image to '\%s', Status=0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Dump command was received and the +** cFE Table Services is unable to write the contents of the specified Table image to +** the specified file. +** +** The \c Status field provides the return status from the #OS_write function call. +**/ +#define CFE_TBL_WRITE_TBL_IMG_ERR_EID 65 + +/** \brief 'No Inactive Buffer for Table '\%s' present' +** \event 'No Inactive Buffer for Table '\%s' present' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Dump or a Table Validate command for an +** Inactive Table Buffer was received and there isn't an Inactive Table Buffer associated +** with the specified Table. +**/ +#define CFE_TBL_NO_INACTIVE_BUFFER_ERR_EID 66 + +/** \brief 'Too many Table Validations have been requested' +** \event 'Too many Table Validations have been requested' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Validate command was received and there are +** no more free Validation Result Blocks available. The number of simultaneous validations that +** can be pending is specified by the configuration parameter #CFE_TBL_MAX_NUM_VALIDATIONS +** which is found in the cfe_platform_cfg.h file. +** +** Validation Commands lock one of the Validation Result Blocks upon receipt of the validation +** command until the result of the Validation, performed by the table's owning Application, has +** been reported in a Table Services Housekeeping Request Message. +**/ +#define CFE_TBL_TOO_MANY_VALIDATIONS_ERR_EID 67 + +/** \brief 'Error writing Registry to '\%s', Status=0x\%08X' +** \event 'Error writing Registry to '\%s', Status=0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Registry Dump command was received and the +** cFE Table Services is unable to write the entire contents of the Table Registry to +** the specified file. +** +** The \c Status field provides the return status from the #OS_write function call. +**/ +#define CFE_TBL_WRITE_TBL_REG_ERR_EID 68 + +/** \brief 'Cannot abort load of '\%s'. No load started.' +** \event 'Cannot abort load of '\%s'. No load started.' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Abort Load command is received and the command specified +** table is not currently in the process of being loaded. +**/ +#define CFE_TBL_LOAD_ABORT_ERR_EID 69 + +/** \brief 'Cannot activate table '\%s'. No Inactive image available' +** \event 'Cannot activate table '\%s'. No Inactive image available' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Activate Table command is received and the command specified +** table does not currently have an inactive buffer associated with it. +**/ +#define CFE_TBL_ACTIVATE_ERR_EID 70 + +/** \brief 'Incomplete load of '\%s' into '\%s' working buffer' +** \event 'Incomplete load of '\%s' into '\%s' working buffer' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Load Table command is received and the Table Services +** is unable to load the number of bytes specified in the Table Image Header of the command +** specified file from the file into the Inactive Buffer. +**/ +#define CFE_TBL_FILE_INCOMPLETE_ERR_EID 71 + +/** \brief 'Cannot load '\%s' (\%d) at offset \%d in '\%s' (\%d)' +** \event 'Cannot load '\%s' (\%d) at offset \%d in '\%s' (\%d)' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Load Table command is received and the Table Header in +** the specified Table Image file identifies a number of bytes with a specified starting offset +** that would exceed the size of the specified table. For example, if a table had 10 bytes and +** the Table Header indicated that the Table Image in the file contains 7 bytes that starts at +** offset 5, then the data content would have exceeded the 10 byte limit of the table. +** +** The numbers in parenthesis in the event message text indicate the data size (in bytes) for +** the specified load file and the registered size for the specified table. +**/ +#define CFE_TBL_LOAD_EXCEEDS_SIZE_ERR_EID 72 + +/** \brief 'Table Hdr in '\%s' indicates no data in file' +** \event 'Table Hdr in '\%s' indicates no data in file' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Load Table command is received and the Table Header in +** the specified Table Image file claims the file contains no data. +**/ +#define CFE_TBL_ZERO_LENGTH_LOAD_ERR_EID 73 + +/** \brief ''\%s' has partial load for uninitialized table '\%s'' +** \event ''\%s' has partial load for uninitialized table '\%s'' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Load Table command is received and the Table Header in +** the specified Table Image file indicates the starting offset for the table is non-zero and the +** table has never been previously, completely loaded. Partial Table loads are only allowed after +** the table has had a successful load. +**/ +#define CFE_TBL_PARTIAL_LOAD_ERR_EID 74 + +/** \brief 'File '\%s' has more data than Tbl Hdr indicates (\%d)' +** \event 'File '\%s' has more data than Tbl Hdr indicates (\%d)' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Load Table command is received and Table Services is +** able to locate more data in the specified Table Image file than the Table Header claims is present. +**/ +#define CFE_TBL_FILE_TOO_BIG_ERR_EID 75 + +/** \brief 'Too many Dump Only Table Dumps have been requested' +** \event 'Too many Dump Only Table Dumps have been requested' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Dump command for a Dump-Only Table was received and there are +** no more free Dump Only Control Blocks available. The number of simultaneous Dump Only Tables that +** can be pending is specified by the configuration parameter #CFE_TBL_MAX_SIMULTANEOUS_LOADS which +** is found in the cfe_platform_cfg.h file. +**/ +#define CFE_TBL_TOO_MANY_DUMPS_ERR_EID 76 + +/** \brief 'A dump for '\%s' is already pending' +** \event 'A dump for '\%s' is already pending' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Dump command for a Dump-Only Table was received and +** Table Services hasn't finished processing the previous Table Dump command for the same Table. +**/ +#define CFE_TBL_DUMP_PENDING_ERR_EID 77 + +/** \brief 'Illegal attempt to activate dump-only table '\%s'' +** \event 'Illegal attempt to activate dump-only table '\%s'' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Activate command for a Dump-Only Table was received. +** By definition, Dump-Only tables are not allowed to be loaded with any new data. +**/ +#define CFE_TBL_ACTIVATE_DUMP_ONLY_ERR_EID 78 + +/** \brief 'Attempted to load DUMP-ONLY table '\%s' from '\%s'' +** \event 'Attempted to load DUMP-ONLY table '\%s' from '\%s'' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Load command for a Dump-Only Table was received. +** By definition, Dump-Only tables are not allowed to be loaded with any new data. +**/ +#define CFE_TBL_LOADING_A_DUMP_ONLY_ERR_EID 79 + +/** \brief 'Cmd for Table '\%s' had illegal buffer parameter (0x\%08X)' +** \event 'Cmd for Table '\%s' had illegal buffer parameter (0x\%08X)' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when either a Table Validate command or a Table Dump Command +** contains a buffer identifier that does not equal either of the valid values +** (see #CFE_TBL_DumpCmd_t::ActiveTblFlag or #CFE_TBL_ValidateCmd_t::ActiveTblFlag) +** +** The parameter in the Event Message indicates (in hex) the value found for the ActiveTblFlag in the command. +**/ +#define CFE_TBL_ILLEGAL_BUFF_PARAM_ERR_EID 80 + +/** \brief 'Cannot activate table '\%s'. Inactive image not Validated' +** \event 'Cannot activate table '\%s'. Inactive image not Validated' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Activate command is received specifying +** a Table Image that has not been Validated. If a table has a validation function associated with it +** (as defined by the owning Application when the Table is first Registered), then the Inactive Image +** MUST be successfully Validated prior to Activation. +**/ +#define CFE_TBL_UNVALIDATED_ERR_EID 81 + +/** \brief ''\%s' found in Table Registry. CDS cannot be deleted until table is unregistered' +** \event ''\%s' found in Table Registry. CDS cannot be deleted until table is unregistered' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Delete Critical Data Store command is received specifying +** a Table Image that is still registered. Critical Table Images cannot be removed from the CDS until the +** table is first removed from the Registry. Unload the owning application and try again. +**/ +#define CFE_TBL_IN_REGISTRY_ERR_EID 82 + +/** \brief 'Table '\%s' is in Critical Table Registry but CDS is not tagged as a table' +** \event 'Table '\%s' is in Critical Table Registry but CDS is not tagged as a table' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Delete Critical Data Store command is received specifying +** a CDS name for a Critical Data Store that is NOT a critical table image. To delete CDSs that are not +** Critical Table Images, the Executive Services command #CFE_ES_DELETE_CDS_CC must be used. +**/ +#define CFE_TBL_NOT_CRITICAL_TBL_ERR_EID 83 + +/** \brief 'Table '\%s' is not found in Critical Table Registry' +** \event 'Table '\%s' is not found in Critical Table Registry' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Delete Critical Data Store command is received specifying +** a table name that cannot be found in the Critical Table Registry. If a Critical Data Store exists with +** the specified name, then the Critical Table Registry has somehow gotten out of sync with the CDS. +** Otherwise, the likely cause of this error is a misspelled table name in the command. +**/ +#define CFE_TBL_NOT_IN_CRIT_REG_ERR_EID 84 + +/** \brief 'Unable to locate '\%s' in CDS Registry' +** \event 'Unable to locate '\%s' in CDS Registry' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a Table Delete Critical Data Store command is received specifying +** a table name that WAS found in the Critical Table Registry but its associated entry in the Critical Data +** Store Registry was not found. Somehow the two entities have become out of synch. +**/ +#define CFE_TBL_CDS_NOT_FOUND_ERR_EID 85 + +/** \brief 'Error while deleting '\%s' from CDS, See SysLog.(Err=0x\%08X)' +** \event 'Error while deleting '\%s' from CDS, See SysLog.(Err=0x\%08X)' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an unexpected error was encountered during the deletion of the CDS. +** The System Log should have more precise information on the nature of the error. +**/ +#define CFE_TBL_CDS_DELETE_ERR_EID 86 + +/** \brief 'CDS '\%s' owning app is still active' +** \event 'CDS '\%s' owning app is still active' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an attempt is made to delete a CDS while an application with the +** same name as the CDS Prefix is still registered in the system. Owning applications must not be active +** before an associated CDS can be deleted. +**/ +#define CFE_TBL_CDS_OWNER_ACTIVE_ERR_EID 87 + +/** \brief 'Attempted to load table '\%s' while previous load is still pending' +** \event 'Attempted to load table '\%s' while previous load is still pending' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an attempt is made to load a table while a previous load is still +** pending. The most likely cause of this is the owning application is waiting for an appropriate time to +** load the table with the specified contents. In order to override this load, the user would be required +** to issue the \link #CFE_TBL_ABORT_LOAD_CC Abort Load Command \endlink. +**/ +#define CFE_TBL_LOADING_PENDING_ERR_EID 88 + +/** \brief 'Manage Notification Pkt Error(MsgId=0x\%08X, CC=0x\%04X, Param=0x\%08X, Status=0x\%08X)' +** \event 'Manage Notification Pkt Error(MsgId=0x\%08X, CC=0x\%04X, Param=0x\%08X, Status=0x\%08X)' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when a table management notification message +** fails to be sent via the software bus. +** +** The \c MsgId is the message ID of the table management notification message that was attempted to be sent, +** the \c CC is the command code, the \c Param is the application specified command parameter and the \c Status +** is the error code returned by the #CFE_SB_SendMsg API call. +**/ +#define CFE_TBL_FAIL_NOTIFY_SEND_ERR_EID 89 +/** \} */ + +/** \name API Informational Event Message IDs */ +/** \{ */ + +/** \brief 'Successfully loaded '\%s' from '\%s'' +** \event 'Successfully loaded '\%s' from '\%s'' +** +** \par Type: DEBUG (the first time) and INFORMATION (normally) +** +** \par Cause: +** +** This event message is generated when a Table is successfully updated by its owning Application +** with the contents of the Application specified file or memory area. This Event Message only +** appears when an Application successfully calls the #CFE_TBL_Load API. +**/ +#define CFE_TBL_LOAD_SUCCESS_INF_EID 35 + +/** \brief '\%s validation successful for Inactive '\%s'' +** \event '\%s validation successful for Inactive '\%s'' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated when a Table Image is successfully validated by its owning +** Application via the Validation function specified by the owning Application when the table +** was first registered. +**/ +#define CFE_TBL_VALIDATION_INF_EID 36 + +/** \brief '\%s Successfully Updated '\%s'' +** \event '\%s Successfully Updated '\%s'' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated when a Table's Active Buffer is successfully updated with the contents +** of its Inactive Buffer. +**/ +#define CFE_TBL_UPDATE_SUCCESS_INF_EID 37 + +/** \brief 'Successfully removed '\%s' from CDS' +** \event 'Successfully removed '\%s' from CDS' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated when a Critical Table's CDS has been successfully deleted. +**/ +#define CFE_TBL_CDS_DELETED_INFO_EID 38 +/** \} */ + + + +/** \name API Error Event Message IDs */ +/** \{ */ +/** \brief '\%s Failed to Register '\%s', Status=0x\%08X' +** \event '\%s Failed to Register '\%s', Status=0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Application calls #CFE_TBL_Register unsuccessfully. +** +** The \c Status field of the Event Message can be used to identify the reason for the failure +** by looking it up in the cfe_error.h file +**/ +#define CFE_TBL_REGISTER_ERR_EID 90 + +/** \brief '\%s Failed to Share '\%s', Status=0x\%08X' +** \event '\%s Failed to Share '\%s', Status=0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Application calls #CFE_TBL_Share unsuccessfully. +** +** The \c Status field of the Event Message can be used to identify the reason for the failure +** by looking it up in the cfe_error.h file +**/ +#define CFE_TBL_SHARE_ERR_EID 91 + +/** \brief '\%s Failed to Unregister '\%s', Status=0x\%08X' +** \event '\%s Failed to Unregister '\%s', Status=0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Application calls #CFE_TBL_Unregister unsuccessfully. +** +** The \c Status field of the Event Message can be used to identify the reason for the failure +** by looking it up in the cfe_error.h file +**/ +#define CFE_TBL_UNREGISTER_ERR_EID 92 + +/** \brief '\%s Failed to Load '\%s' from \%s, Status=0x\%08X" +** \event '\%s Failed to Load '\%s' from \%s, Status=0x\%08X" +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Application calls #CFE_TBL_Load unsuccessfully. +** +** The \c Status field of the Event Message can be used to identify the reason for the failure +** by looking it up in the cfe_error.h file +**/ +#define CFE_TBL_LOAD_ERR_EID 93 + +/** \brief '\%s Failed to Load '\%s' (Invalid Source Type)" +** \event '\%s Failed to Load '\%s' (Invalid Source Type)" +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Application calls #CFE_TBL_Load with a bad value for +** the \c SrcType parameter. The \c SrcType must be one of the values specified by #CFE_TBL_SrcEnum_t. +**/ +#define CFE_TBL_LOAD_TYPE_ERR_EID 94 + +/** \brief '\%s Failed to Update '\%s', Status=0x\%08X" +** \event '\%s Failed to Update '\%s', Status=0x\%08X" +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Application calls #CFE_TBL_Update (or, via an internal call, +** the #CFE_TBL_Manage) API and the Table fails to properly update. +** +** The \c Status parameter in the Event Message can be used to identify the reason for the failure +** by looking it up in the cfe_error.h file. +**/ +#define CFE_TBL_UPDATE_ERR_EID 95 + +/** \brief '\%s validation failed for Inactive '\%s', Status=0x\%08X" +** \event '\%s validation failed for Inactive '\%s', Status=0x\%08X" +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an Application calls #CFE_TBL_Validate (or, via an internal call, +** the #CFE_TBL_Manage) API and the Table fails its Validation. +** +** The \c Status parameter in the Event Message contains the status code returned by the Table's +** Validation function as defined by the owning Application when the Table was Registered. +**/ +#define CFE_TBL_VALIDATION_ERR_EID 96 + +/** \brief 'Unable to verify Spacecraft ID for '\%s', ID = 0x\%08X' +** \event 'Unable to verify Spacecraft ID for '\%s', ID = 0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when either an Application calls the #CFE_TBL_Load API or a Table +** Load command has been received and the specified table file has failed Spacecraft ID validation. +** Verification of Spacecraft ID in table files is enabled/disabled via #CFE_TBL_VALID_SCID_COUNT, +** defined in the platform configuration header file. This event message can only be generated if +** #CFE_TBL_VALID_SCID_COUNT has a non-zero value and the table file has a \link #CFE_FS_Header_t +** cFE Standard File Header \endlink whose \link #CFE_FS_Header_t::SpacecraftID Spacecraft ID \endlink +** does not match one of the values defined for Spacecraft ID verification in the platform config file. +** The most likely causes for this error are: +** -# The specified table file is not intended for this spacecraft. +** -# The specified table file has been created with bad "endianess" (headers should always conform to +** a big endian format). +** -# The specified table file has become corrupted. +** -# The definition for #CFE_TBL_VALID_SCID_COUNT is not large enough to include all of the valid +** Spacecraft ID entries in the platform config file. +** -# There is no entry for this Spacecraft ID in the platform config file list of valid Spacecraft ID's. +** +** The \c ID field specified in the event message contains the Spacecraft ID that was found +** in the specified table file. +**/ +#define CFE_TBL_SPACECRAFT_ID_ERR_EID 97 + +/** \brief 'Unable to verify Processor ID for '\%s', ID = 0x\%08X' +** \event 'Unable to verify Processor ID for '\%s', ID = 0x\%08X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when either an Application calls the #CFE_TBL_Load API or a Table +** Load command has been received and the specified table file has failed Processor ID validation. +** Verification of Processor ID in table files is enabled/disabled via #CFE_TBL_VALID_PRID_COUNT, +** defined in the platform configuration header file. This event message can only be generated if +** #CFE_TBL_VALID_PRID_COUNT has a non-zero value and the table file has a \link #CFE_FS_Header_t +** cFE Standard File Header \endlink whose \link #CFE_FS_Header_t::ProcessorID Processor ID \endlink +** does not match one of the values defined for Processor ID verification in the platform config file. +** The most likely causes for this error are: +** -# The specified table file is not intended for this processor. +** -# The specified table file has been created with bad "endianess" (headers should always conform to +** a big endian format). +** -# The specified table file has become corrupted. +** -# The definition for #CFE_TBL_VALID_PRID_COUNT is not large enough to include all of the valid +** Processor ID entries in the platform config file. +** -# There is no entry for this Processor ID in the platform config file list of valid Processor ID's. +** +** The \c ID field specified in the event message contains the Processor ID that was found +** in the specified table file. +**/ +#define CFE_TBL_PROCESSOR_ID_ERR_EID 98 + +/** \} */ + + + +#endif /* _cfe_tbl_events_ */ + +/************************/ +/* End of File Comment */ +/************************/ diff --git a/src/components/interface/cFE/cfe_tbl_filedef.h b/src/components/interface/cFE/cfe_tbl_filedef.h new file mode 100644 index 0000000000..32cd4aa814 --- /dev/null +++ b/src/components/interface/cFE/cfe_tbl_filedef.h @@ -0,0 +1,122 @@ +/* +** +** $Id: cfe_tbl_filedef.h 1.6 2014/08/26 16:41:40GMT-05:00 sstrege Exp $ +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Title: ELF2CFETBL Utility Header File for Table Images +** +** Purpose: +** This header file provides a data structure definition and macro definition +** required in source code that is intended to be compiled into a cFE compatible +** Table Image file. +** +** Design Notes: +** +** Typically, a user would include this file in a ".c" file that contains nothing +** but a desired instantiation of values for a table image along with the macro +** defined below. After compilation, the resultant elf file can be processed using +** the 'elf2cfetbl' utility to generate a file that can be loaded onto a cFE flight +** system and successfully loaded into a table using the cFE Table Services. +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** +** Notes: +** +** $Log: cfe_tbl_filedef.h $ +** Revision 1.6 2014/08/26 16:41:40GMT-05:00 sstrege +** Updated CFE_TBL_FILDEF_MAX_NAME_LEN to be set equal to CFE_TBL_MAX_FULL_NAME_LEN +** Revision 1.5 2014/06/03 10:35:05EDT lwalling +** Updated CFE_TBL_FILEDEF macro to include reference to OS_USED macro +** Revision 1.4 2010/11/15 10:00:47EST dkobe +** Modified definition of CFE_TBL_FileDef_t to ensure longword alignment +** Revision 1.3 2010/10/25 15:01:11EDT jmdagost +** Corrected bad apostrophe in prologue. +** Revision 1.2 2010/10/04 15:24:57EDT jmdagost +** Cleaned up copyright symbol. +** Revision 1.1 2008/04/17 08:05:25EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.1.1.2 2006/11/17 16:46:55EST David Kobe (dlkobe) +** Updated with Doxygen formatted comments +*/ + +/* +** Ensure that header is included only once... +*/ +#ifndef _cfe_tbl_filedef_ +#define _cfe_tbl_filedef_ + +#include "cfe.h" + +/* CFE_TBL_MAX_FULL_NAME_LEN is defined in cfe_tbl.h and includes alignment bytes */ +#define CFE_TBL_FILDEF_MAX_NAME_LEN (CFE_TBL_MAX_FULL_NAME_LEN) + +/* Compute number of additional bytes needed to make */ +/* CFE_FS_HDR_DESC_MAX_LEN rounded up to nearest longword boundary */ +#define CFE_TBL_FILEDEF_FS_HDR_ALIGN32 (CFE_FS_HDR_DESC_MAX_LEN - ((CFE_FS_HDR_DESC_MAX_LEN/4)*4)) + +/* Allocate enough space for maximum table description length plus alignment bytes */ +#define CFE_TBL_FILDEF_FS_HDR_LEN (CFE_FS_HDR_DESC_MAX_LEN + CFE_TBL_FILEDEF_FS_HDR_ALIGN32) + +/* Compute number of additional bytes needed to make */ +/* OS_MAX_FILE_NAME rounded up to nearest longword boundary */ +#define CFE_TBL_FILEDEF_OS_FILE_ALIGN32 (OS_MAX_FILE_NAME - ((OS_MAX_FILE_NAME/4)*4)) + +/* Allocate enough space for maximum file name length plus alignment bytes */ +#define CFE_TBL_FILDEF_OS_FILE_LEN (OS_MAX_FILE_NAME + CFE_TBL_FILEDEF_OS_FILE_ALIGN32) + +typedef struct +{ + uint32 Reserved; /**< Future Use: NumTblSegments in File? */ + uint32 Offset; /**< Byte Offset at which load should commence */ + uint32 NumBytes; /**< Number of bytes to load into table */ + char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< Fully qualified name of table to load */ +} CFE_TBL_File_Hdr_t; + + +typedef struct +{ + char ObjectName[64]; /**< \brief Name of instantiated variable that contains desired table image */ + char TableName[CFE_TBL_FILDEF_MAX_NAME_LEN]; /**< \brief Name of Table as defined onboard */ + char Description[CFE_TBL_FILDEF_FS_HDR_LEN]; /**< \brief Description of table image that is included in cFE File Header */ + char TgtFilename[CFE_TBL_FILDEF_OS_FILE_LEN]; /**< \brief Default filename to be used for output of elf2cfetbl utility */ + uint32 ObjectSize; /**< \brief Size, in bytes, of instantiated object */ +} CFE_TBL_FileDef_t; + +/** The CFE_TBL_FILEDEF macro can be used to simplify the declaration of a table image when using the elf2cfetbl utility. +** An example of the source code and how this macro would be used is as follows: \code + + #include "cfe_tbl_filedef.h" + + typedef struct + { + int Int1; + int Int2; + int Int3; + char Char1; + } MyTblStruct_t; + + MyTblStruct_t MyTblStruct = { 0x01020304, 0x05060708, 0x090A0B0C, 0x0D }; + + CFE_TBL_FILEDEF(MyTblStruct, MyApp.TableName, Table Utility Test Table, MyTblDefault.bin ) + +\endcode +*/ + +#define CFE_TBL_FILEDEF(ObjName, TblName, Desc, Filename) static OS_USED CFE_TBL_FileDef_t CFE_TBL_FileDef={#ObjName, #TblName, #Desc, #Filename, sizeof(ObjName)}; + +/*************************************************************************/ + +#endif /* _cfe_tbl_filedef_ */ + +/************************/ +/* End of File Comment */ +/************************/ diff --git a/src/components/interface/cFE/cfe_tbl_msg.h b/src/components/interface/cFE/cfe_tbl_msg.h new file mode 100644 index 0000000000..a612091faa --- /dev/null +++ b/src/components/interface/cFE/cfe_tbl_msg.h @@ -0,0 +1,851 @@ +/* +** $Id: cfe_tbl_msg.h 1.9 2014/08/19 13:49:24GMT-05:00 sstrege Exp $ +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Purpose: cFE Table Services (TBL) SB message definitions header file +** +** Author: D.Kobe/Hammers +** +** Notes: +** +** $Log: cfe_tbl_msg.h $ +** Revision 1.9 2014/08/19 13:49:24GMT-05:00 sstrege +** Fixed doxygen warning +** Revision 1.8 2014/06/09 18:27:05EDT lwalling +** Removed pad bytes from TBL housekeeping packet +** Revision 1.7 2014/06/09 10:30:25EDT lwalling +** Add LastTableLoaded to TBL housekeeping structure +** Revision 1.6 2010/10/27 16:33:44EDT dkobe +** Added CRC to Registry Entry Telemetry Message +** Revision 1.5 2010/10/27 13:54:24EDT dkobe +** Added command message data structure for TBL notification messages +** Revision 1.4 2010/10/25 15:01:11EDT jmdagost +** Corrected bad apostrophe in prologue. +** Revision 1.3 2010/10/04 15:24:58EDT jmdagost +** Cleaned up copyright symbol. +** Revision 1.2 2008/12/08 12:07:10EST dkobe +** Updates to correct doxygen errors +** Revision 1.1 2008/04/17 08:05:25EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.20 2007/09/27 15:53:53EDT David Kobe (dlkobe) +** Added relevant "See Also" doxygen comment references. +** Revision 1.19 2007/07/05 15:39:17EDT dlkobe +** Added Critical Table Flag to Tbl Registry Record Tlm Command +** Revision 1.18 2007/06/07 13:07:46EDT dlkobe +** Added Command and Telemetry doxygen comments to TIME, EVS and SB +** Revision 1.17 2007/06/02 10:10:11EDT dlkobe +** Added doxygen comments for User's Guides +** Revision 1.16 2007/05/25 16:24:49EDT dlkobe +** Continued updating doxygen comments +** Revision 1.14 2007/05/16 15:13:39EDT dlkobe +** Added MemPoolHandle members to HK packet +** Revision 1.13 2007/05/04 15:55:06EDT dlkobe +** Added Delete CDS Command +** Revision 1.12 2006/11/10 15:14:35GMT-05:00 dlkobe +** Updated comments to conform with doxygen +** Revision 1.11 2006/10/31 12:21:44GMT-05:00 dlkobe +** Removed all references to the TBL_MOD_DUMP_ONLY option command +** +*/ + +/* +** Ensure that header is included only once... +*/ +#ifndef _cfe_tbl_msg_ +#define _cfe_tbl_msg_ + +/* +** Required header files... +*/ +#include "cfe.h" + +/*************************************************************************/ + +/* +** Table task command packet command codes +*/ +/** \name Table Services Command Codes */ +/** \{ */ + +/** \cfetblcmd Table No-Op +** +** \par Description +** This command performs no other function than to increment the +** command execution counter. The command may be used to verify +** general aliveness of the Table Services task. +** +** \cfecmdmnemonic \TBL_NOOP +** +** \par Command Structure +** #CFE_TBL_NoArgsCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TBL_CMDPC - command execution counter will +** increment +** - The #CFE_TBL_NOOP_INF_EID informational event message will +** be generated +** +** \par Error Conditions +** There are no error conditions for this command. If the Table +** Services receives the command, the event is sent (although it +** may be filtered by EVS) and the counter is incremented +** unconditionally. +** +** \par Criticality +** None +** +** \sa +*/ +#define CFE_TBL_NOOP_CC 0 + +/** \cfetblcmd Table Reset Counters +** +** \par Description +** This command resets the following counters within the Table +** Services housekeeping telemetry: +** - Command Execution Counter (\TBL_CMDPC) +** - Command Error Counter (\TBL_CMDEC) +** - Successful Table Validations Counter (\TBL_VALSUCCESSCTR) +** - Failed Table Validations Counter (\TBL_VALFAILEDCTR) +** - Number of Table Validations Requested (\TBL_VALREQCTR) +** +** \cfecmdmnemonic \TBL_RESETCTRS +** +** \par Command Structure +** #CFE_TBL_NoArgsCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \TBL_CMDPC - command execution counter will +** increment +** - The #CFE_TBL_RESET_INF_EID debug event message will be +** generated +** +** \par Error Conditions +** There are no error conditions for this command. If the Table +** Services receives the command, the event is sent (although it +** may be filtered by EVS) and the counter is incremented +** unconditionally. +** +** \par Criticality +** This command is not inherently dangerous. However, it is +** possible for ground systems and on-board safing procedures +** to be designed such that they react to changes in the counter +** values that are reset by this command. +** +** \sa +*/ +#define CFE_TBL_RESET_CC 1 + +/** \cfetblcmd Load Table +** +** \par Description +** This command loads the contents of the specified file into +** an inactive buffer for the table specified within the file. +** +** \cfecmdmnemonic \TBL_LOAD +** +** \par Command Structure +** #CFE_TBL_LoadCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with +** the following telemetry: +** - \b \c \TBL_CMDPC - command execution counter will +** increment +** - The #CFE_TBL_FILE_LOADED_INF_EID informational event message +** will be generated +** +** \par Error Conditions +** This command can fail for the following reasons: +** - Table name found in table image file's table header is not found +** in table registry (ie - The table associated with the table image +** in the file has not been registered by an application). +** - The table image file's header indicates the file contains 'x' +** number of bytes of data but the file contains less. +** - No working buffers are available for the load. This would indicate +** that too many single-buffered table loads are in progress at the same +** time. +** - The table image file's header indicates the data to be loaded is +** beyond the size of the table. Either the number of bytes in the +** file are too many or the starting offset into the table is too high. +** - The table image file's header indicates there is no data in the +** file (ie - Number of bytes to load is zero). +** - An attempt is being made to load an uninitialized table with a file +** containing only a partial table image. +** - The table image file was unable to be opened. Either the file does +** not exist at the specified location, the filename is in error, or +** the file system has been corrupted. +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \TBL_CMDEC - command error counter will increment +** - Command specific error event messages are issued for all error cases +** +** \par Criticality +** This command is not inherently dangerous. It is performing the first +** step of loading a table and can be aborted (using the Abort Table Load +** command described below) without affecting the contents of the active +** table image. +** +** \sa #CFE_TBL_DUMP_CC, #CFE_TBL_VALIDATE_CC, #CFE_TBL_ACTIVATE_CC, #CFE_TBL_ABORT_LOAD_CC +*/ +#define CFE_TBL_LOAD_CC 2 + +/** \cfetblcmd Dump Table +** +** \par Description +** This command will cause the Table Services to put the contents +** of the specified table buffer into the command specified file. +** +** \cfecmdmnemonic \TBL_DUMP +** +** \par Command Structure +** #CFE_TBL_DumpCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TBL_CMDPC - command execution counter will +** increment +** - Either the #CFE_TBL_OVERWRITE_DUMP_INF_EID OR the +** #CFE_TBL_WRITE_DUMP_INF_EID informational event message will +** be generated +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - A single buffered table's inactive buffer was requested to be +** dumped and no such buffer is currently allocated. +** - Error occurred during write operation to file. Possible causes +** might be insufficient space in the file system or the filename +** or file path is improperly specified. +** - The specified table name was not found in the table registry. +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \TBL_CMDEC - command error counter will increment +** - A command specific error event message is issued for all error +** cases +** +** \par Criticality +** This command is not inherently dangerous. It will create a new +** file in the file system and could, if performed repeatedly without +** sufficient file management by the operator, fill the file system. +** +** \sa #CFE_TBL_LOAD_CC, #CFE_TBL_VALIDATE_CC, #CFE_TBL_ACTIVATE_CC, #CFE_TBL_ABORT_LOAD_CC +*/ +#define CFE_TBL_DUMP_CC 3 + +/** \cfetblcmd Validate Table +** +** \par Description +** This command will cause Table Services to calculate the Data Integrity +** Value for the specified table and to notify the owning application that +** the table's validation function should be executed. The results of both +** the Data Integrity Value computation and the validation function are +** reported in Table Services Housekeeping Telemetry. +** +** \cfecmdmnemonic \TBL_VALIDATE +** +** \par Command Structure +** #CFE_TBL_ValidateCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the following +** telemetry: +** - \b \c \TBL_CMDPC - command execution counter will increment +** - \b \c \TBL_VALREQCTR - table validation request counter will increment +** - \b \c \TBL_LASTVALCRC - calculated data integrity value will be updated +** - The #CFE_TBL_VAL_REQ_MADE_INF_EID debug event message (indicating the +** application is being notified of a validation request) +** +** If the specified table has an associated validation function, then the +** following telemetry will also change: +** - Either \b \c \TBL_VALSUCCESSCTR OR \b \c \TBL_VALFAILEDCTR will +** increment +** - \b \c \TBL_VALCOMPLTDCTR - table validations performed counter will +** increment +** - \b \c \TBL_LASTVALS - table validation function return status will +** update +** - The #CFE_TBL_VALIDATION_INF_EID informational event message (indicating the +** validation function return status) will be generated +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - A single buffered table's inactive buffer was requested to be dumped +** and no such buffer is currently allocated. +** - Too many validations have been requested simultaneously. The operator +** must wait for one or more applications to perform their table validation +** functions before trying again. +** - The specified table name was not found in the table registry. +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \TBL_CMDEC - command error counter will increment +** - Command specific error event message are issued for all error cases +** +** \par Criticality +** The success or failure of a table validation does not have any immediate +** impact on table contents. The results are sent to the operator in telemetry +** and the operator must determine whether the results are acceptable and send a +** command to activate the validated table image. +** +** \sa #CFE_TBL_LOAD_CC, #CFE_TBL_DUMP_CC, #CFE_TBL_ACTIVATE_CC, #CFE_TBL_ABORT_LOAD_CC +*/ +#define CFE_TBL_VALIDATE_CC 4 + +/** \cfetblcmd Activate Table +** +** \par Description +** This command will cause Table Services to notify a table's owner +** that an update is pending. The owning application will then update +** the contents of the active table buffer with the contents of the +** associated inactive table buffer at a time of their convenience. +** +** \cfecmdmnemonic \TBL_ACTIVATE +** +** \par Command Structure +** #CFE_TBL_ActivateCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TBL_CMDPC - command execution counter will +** increment +** - The #CFE_TBL_UPDATE_SUCCESS_INF_EID informational event message +** will be generated +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - A single buffered table's inactive buffer was requested to be +** dumped and no such buffer is currently allocated. +** - The specified table name was not found in the table registry. +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \TBL_CMDEC - command error counter will increment +** - Command specific error event message are issued for all +** error cases +** +** \par Criticality +** This command will cause the contents of the specified table to be +** updated with the contents in the inactive table buffer. +** +** \sa #CFE_TBL_LOAD_CC, #CFE_TBL_DUMP_CC, #CFE_TBL_VALIDATE_CC, #CFE_TBL_ABORT_LOAD_CC +*/ +#define CFE_TBL_ACTIVATE_CC 5 + +/** \cfetblcmd Dump Table Registry +** +** \par Description +** This command will cause Table Services to write some of the +** contents of the Table Registry to the command specified file. +** This allows the operator to see the current state and configuration +** of all tables that have been registered with the cFE. +** +** \cfecmdmnemonic \TBL_WRITEREG2FILE +** +** \par Command Structure +** #CFE_TBL_DumpRegCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TBL_CMDPC - command execution counter will +** increment +** - The generation of either #CFE_TBL_OVERWRITE_REG_DUMP_INF_EID +** or #CFE_TBL_WRITE_REG_DUMP_INF_EID debug event messages +** - The specified file should appear (or be updated) at the +** specified location in the file system +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - Error occurred during write operation to file. Possible +** causes might be insufficient space in the file system +** or the filename or file path is improperly specified. +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \TBL_CMDEC - command error counter will increment +** - An Error specific event message +** +** \par Criticality +** This command is not inherently dangerous. It will create a new +** file in the file system and could, if performed repeatedly without +** sufficient file management by the operator, fill the file system. +** +** \sa #CFE_TBL_TLM_REG_CC +*/ +#define CFE_TBL_DUMP_REG_CC 6 + +/** \cfetblcmd Telemeter One Table Registry Entry +** +** \par Description +** This command will cause Table Services to telemeter the contents +** of the Table Registry for the command specified table. +** +** \cfecmdmnemonic \TBL_TLMREG +** +** \par Command Structure +** #CFE_TBL_TlmRegCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TBL_CMDPC - command execution counter will increment +** - Receipt of a Table Registry Info Packet (see #CFE_TBL_TblRegPacket_t) +** - The #CFE_TBL_TLM_REG_CMD_INF_EID debug event message will +** be generated +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The specified table name was not found in the table registry. +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \TBL_CMDEC - command error counter will increment +** - Error specific event message +** +** \par Criticality +** This command is not inherently dangerous. It will generate +** additional telemetry. +** +** \sa #CFE_TBL_DUMP_REG_CC +*/ +#define CFE_TBL_TLM_REG_CC 7 + +/** \cfetblcmd Delete Critical Table from Critical Data Store +** +** \par Description +** This command will delete the Critical Data Store (CDS) associated +** with the specified Critical Table. Note that any table still +** present in the Table Registry is unable to be deleted from +** the Critical Data Store. All Applications that are accessing +** the critical table must release and unregister their access +** before the CDS can be deleted. +** +** \cfecmdmnemonic \TBL_DELETECDS +** +** \par Command Structure +** #CFE_TBL_DelCDSCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TBL_CMDPC - command execution counter will +** increment +** - The #CFE_TBL_CDS_DELETED_INFO_EID informational event message +** will be generated +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The specified table name was not found in the critical data +** store registry +** - The specified table name WAS found in the table registry (all +** registrations/sharing of the table must be unregistered before +** the table's CDS can be deleted) +** - The table's owning application is still active +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \TBL_CMDEC - command error counter will increment +** - Error specific event message +** +** \par Criticality +** This command will cause the loss of the specified table's contents +** before the owning Application was terminated. +** +** \sa #CFE_ES_DUMP_CDS_REG_CC, #CFE_ES_DELETE_CDS_CC +*/ +#define CFE_TBL_DELETE_CDS_CC 8 + +/** \cfetblcmd Abort Table Load +** +** \par Description +** This command will cause Table Services to discard the contents of +** a table buffer that was previously loaded with the data in a file +** as specified by a Table Load command. For single buffered tables, +** the allocated shared working buffer is freed and becomes available +** for other Table Load commands. +** +** \cfecmdmnemonic \TBL_LOADABORT +** +** \par Command Structure +** #CFE_TBL_AbortLdCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TBL_CMDPC - command execution counter will increment +** - The #CFE_TBL_LOAD_ABORT_INF_EID informational event message +** is generated +** - If the load was aborted for a single buffered table, the +** \b \c \TBL_NUMFREESHRBUF telemetry point should increment +** +** \par Error Conditions +** This command may fail for the following reason(s): +** - The specified table name was not found in the table registry. +** - The specified table did not have a load in progress to be aborted. +** +** Evidence of failure may be found in the following telemetry: +** - \b \c \TBL_CMDEC - command error counter will increment +** - Error specific event message +** +** \par Criticality +** This command will cause the loss of data put into an inactive table buffer. +** +** \sa #CFE_TBL_LOAD_CC, #CFE_TBL_DUMP_CC, #CFE_TBL_VALIDATE_CC, #CFE_TBL_ACTIVATE_CC +*/ +#define CFE_TBL_ABORT_LOAD_CC 9 +/** \} */ + +/* +** Validate Command Buffer Selection Parameters +*/ +/** \name Validate and Dump Command Buffer Selection Parameters */ +/** \{ */ +#define CFE_TBL_INACTIVE_BUFFER 0 +#define CFE_TBL_ACTIVE_BUFFER 1 +/** \} */ + +/*************************************************************************/ + +/********************************/ +/* Command Message Data Formats */ +/********************************/ +/** +** \brief Generic "no arguments" command +** +** This command structure is used for commands that do not have any parameters. +** This includes: +** -# The Housekeeping Request Message +** -# The No-Op Command (For details, see #CFE_TBL_NOOP_CC) +** -# The Reset Counters Command (For details, see #CFE_TBL_RESET_CC) +*/ +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + +} CFE_TBL_NoArgsCmd_t; + +/** +** \brief Load Table Command +** +** For command details, see #CFE_TBL_LOAD_CC +** +**/ +typedef struct +{ + char LoadFilename[OS_MAX_PATH_LEN]; /**< \brief Filename (and path) of data to be loaded */ + /**< ASCII Character string containing full path + filename for file to be loaded */ +} CFE_TBL_LoadCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_TBL_LoadCmd_Payload_t Payload; +} CFE_TBL_LoadCmd_t; + +/** +** \brief Dump Table Command +** +** For command details, see #CFE_TBL_DUMP_CC +*/ +typedef struct +{ + uint16 ActiveTblFlag; /**< \brief #CFE_TBL_INACTIVE_BUFFER=Inactive Table, + #CFE_TBL_ACTIVE_BUFFER=Active Table */ + /**< Selects either the "Inactive" + (#CFE_TBL_INACTIVE_BUFFER) buffer or the + "Active" (#CFE_TBL_ACTIVE_BUFFER) buffer + to be dumped */ + char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Full name of table to be dumped */ + /**< ASCII string containing full table name + identifier of table to be dumped */ + char DumpFilename[OS_MAX_PATH_LEN]; /**< \brief Full Filename where data is to be written */ + /**< ASCII string containing full path of filename + where data is to be dumped */ +} CFE_TBL_DumpCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_TBL_DumpCmd_Payload_t Payload; +} CFE_TBL_DumpCmd_t; + +/** +** \brief Validate Table Command +** +** For command details, see #CFE_TBL_VALIDATE_CC +*/ +typedef struct +{ + uint16 ActiveTblFlag; /**< \brief #CFE_TBL_INACTIVE_BUFFER=Inactive Table, + #CFE_TBL_ACTIVE_BUFFER=Active Table */ + /**< Selects either the "Inactive" + (#CFE_TBL_INACTIVE_BUFFER) buffer or the + "Active" (#CFE_TBL_ACTIVE_BUFFER) buffer + to be validated */ + char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Full Name of Table to be validated */ + /**< ASCII string containing full table name + identifier of table to be validated */ +} CFE_TBL_ValidateCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_TBL_ValidateCmd_Payload_t Payload; +} CFE_TBL_ValidateCmd_t; + +/** +** \brief Activate Table Command +** +** For command details, see #CFE_TBL_ACTIVATE_CC +*/ +typedef struct +{ + char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Full Name of Table to be activated */ + /**< ASCII string containing full table name + identifier of table to be activated */ +} CFE_TBL_ActivateCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_TBL_ActivateCmd_Payload_t Payload; +} CFE_TBL_ActivateCmd_t; + +/** +** \brief Dump Registry Command +** +** For command details, see #CFE_TBL_DUMP_REG_CC +*/ +typedef struct +{ + char DumpFilename[OS_MAX_PATH_LEN]; /**< \brief Full Filename where dumped data is to be + written */ + /**< ASCII string containing full path of filename + where registry is to be dumped */ +} CFE_TBL_DumpRegCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_TBL_DumpRegCmd_Payload_t Payload; +} CFE_TBL_DumpRegCmd_t; + +/** +** \brief Telemeter Table Registry Entry Command +** +** For command details, see #CFE_TBL_TLM_REG_CC +*/ +typedef struct +{ + char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Full Name of Table whose registry entry + is to be telemetered */ + /**< ASCII string containing full table name + identifier of table whose registry entry is + to be telemetered via #CFE_TBL_TblRegPacket_t */ +} CFE_TBL_TlmRegCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_TBL_TlmRegCmd_Payload_t Payload; +} CFE_TBL_TlmRegCmd_t; + +/** +** \brief Delete Critical Table CDS Command +** +** For command details, see #CFE_TBL_DELETE_CDS_CC +*/ +typedef struct +{ + char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Full Name of Table whose CDS is + to be deleted */ + /**< ASCII string containing full table name + identifier of a critical table whose + CDS is to be deleted */ +} CFE_TBL_DelCDSCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_TBL_DelCDSCmd_Payload_t Payload; +} CFE_TBL_DelCDSCmd_t; + +/** +** \brief Abort Load Command +** +** For command details, see #CFE_TBL_ABORT_LOAD_CC +*/ +typedef struct +{ + char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Full Name of Table whose load is to be aborted */ + /**< ASCII string containing full table name + identifier of a table whose load is to be aborted */ +} CFE_TBL_AbortLdCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_TBL_AbortLdCmd_Payload_t Payload; +} CFE_TBL_AbortLdCmd_t; + + +/*************************************************************************/ +/******************************************/ +/* Generated Command Message Data Formats */ +/******************************************/ +/** +** \brief Table Management Notification Message +** +** \par Description +** Whenever an application that owns a table calls the #CFE_TBL_NotifyByMessage API +** following the table registration, Table services will generate the following +** command message with the application specified message ID, command code and +** parameter whenever the table requires management (e.g. - loads and validations). +*/ +typedef struct +{ + uint32 Parameter; /**< \brief Application specified command parameter */ +} CFE_TBL_NotifyCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ + CFE_TBL_NotifyCmd_Payload_t Payload; +} CFE_TBL_NotifyCmd_t; + +/*************************************************************************/ +/**********************************/ +/* Telemetry Message Data Formats */ +/**********************************/ +/** +** \cfetbltlm Table Services Housekeeping Packet +**/ +typedef struct +{ + /* + ** Task command interface counters... + */ + uint8 CmdCounter; /**< \cfetlmmnemonic \TBL_CMDPC + \brief Count of valid commands received */ + uint8 ErrCounter; /**< \cfetlmmnemonic \TBL_CMDEC + \brief Count of invalid commands received */ + + /* + ** Table Registry Statistics + */ + uint16 NumTables; /**< \cfetlmmnemonic \TBL_NUMTABLES + \brief Number of Tables Registered */ + uint16 NumLoadPending; /**< \cfetlmmnemonic \TBL_NUMUPDATESPEND + \brief Number of Tables pending on Applications for their update */ + + /* + ** Last Table Validation Results + */ + uint16 ValidationCtr; /**< \cfetlmmnemonic \TBL_VALCOMPLTDCTR + \brief Number of completed table validations */ + uint32 LastValCrc; /**< \cfetlmmnemonic \TBL_LASTVALCRC + \brief Data Integrity Value computed for last table validated */ + int32 LastValStatus; /**< \cfetlmmnemonic \TBL_LASTVALS + \brief Returned status from validation function for last table validated */ + boolean ActiveBuffer; /**< \cfetlmmnemonic \TBL_LASTVALBUF + \brief Indicator of whether table buffer validated was 0=Inactive, 1=Active */ + char LastValTableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \cfetlmmnemonic \TBL_LASTVALTBLNAME + \brief Name of last table validated */ + uint8 SuccessValCtr; /**< \cfetlmmnemonic \TBL_VALSUCCESSCTR + \brief Total number of successful table validations */ + uint8 FailedValCtr; /**< \cfetlmmnemonic \TBL_VALFAILEDCTR + \brief Total number of unsuccessful table validations */ + uint8 NumValRequests; /**< \cfetlmmnemonic \TBL_VALREQCTR + \brief Number of times Table Services has requested validations from Apps */ + + /* + ** Ground system interface information + */ + uint8 NumFreeSharedBufs; /**< \cfetlmmnemonic \TBL_NUMFREESHRBUF + \brief Number of free Shared Working Buffers */ + uint8 ByteAlignPad1; /**< \cfetlmmnemonic \TBL_BYTEALIGNPAD1 + \brief Spare byte to ensure longword alignment */ + CFE_ES_MemHandle_t MemPoolHandle; /**< \cfetlmmnemonic \TBL_MEMPOOLHANDLE + \brief Handle to TBL's memory pool */ + CFE_TIME_SysTime_t LastUpdateTime; /**< \cfetlmmnemonic \TBL_LASTUPDTIME + \brief Time of last table update */ + char LastUpdatedTbl[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \cfetlmmnemonic \TBL_LASTUPDTBLNAME + \brief Name of the last table updated */ + char LastFileLoaded[OS_MAX_PATH_LEN]; /**< \cfetlmmnemonic \TBL_LASTFILELOADED + \brief Path and Name of last table image file loaded */ + char LastFileDumped[OS_MAX_PATH_LEN]; /**< \cfetlmmnemonic \TBL_LASTFILEDUMPED + \brief Path and Name of last file dumped to */ + char LastTableLoaded[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \cfetlmmnemonic \TBL_LASTTABLELOADED + \brief Name of the last table loaded */ +} CFE_TBL_HkPacket_Payload_t; + +typedef struct +{ + uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; /**< \brief cFE Software Bus Telemetry Message Header */ + CFE_TBL_HkPacket_Payload_t Payload; +} CFE_TBL_HkPacket_t; + + +/** +** \cfetbltlm Table Registry Info Packet +**/ +typedef struct +{ + uint32 Size; /**< \cfetlmmnemonic \TBL_SIZE + \brief Size, in bytes, of Table */ + uint32 Crc; /**< \cfetlmmnemonic \TBL_CRC + \brief Most recently calculated CRC of Table */ + cpuaddr ActiveBufferAddr; /**< \cfetlmmnemonic \TBL_ACTBUFADD + \brief Address of Active Buffer */ + cpuaddr InactiveBufferAddr; /**< \cfetlmmnemonic \TBL_IACTBUFADD + \brief Address of Inactive Buffer */ + cpuaddr ValidationFuncPtr; /**< \cfetlmmnemonic \TBL_VALFUNCPTR + \brief Ptr to Owner App's function that validates tbl contents */ + CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \cfetlmmnemonic \TBL_TIMELASTUPD + \brief Time when Table was last updated */ + uint32 FileCreateTimeSecs; /**< \cfetlmmnemonic \TBL_FILECSECONDS + \brief File creation time from last file loaded into table */ + uint32 FileCreateTimeSubSecs; /**< \cfetlmmnemonic \TBL_FILECSUBSECONDS + \brief File creation time from last file loaded into table */ + boolean TableLoadedOnce; /**< \cfetlmmnemonic \TBL_LOADEDONCE + \brief Flag indicating whether table has been loaded once or not */ + boolean LoadPending; /**< \cfetlmmnemonic \TBL_UPDATEPNDNG + \brief Flag indicating an inactive buffer is ready to be copied */ + boolean DumpOnly; /**< \cfetlmmnemonic \TBL_DUMPONLY + \brief Flag indicating Table is NOT to be loaded */ + boolean DblBuffered; /**< \cfetlmmnemonic \TBL_DBLBUFFERED + \brief Flag indicating Table has a dedicated inactive buffer */ + char Name[CFE_TBL_MAX_FULL_NAME_LEN];/**< \cfetlmmnemonic \TBL_NAME + \brief Processor specific table name */ + char LastFileLoaded[OS_MAX_PATH_LEN];/**< \cfetlmmnemonic \TBL_LASTFILEUPD + \brief Filename of last file loaded into table */ + char OwnerAppName[OS_MAX_API_NAME]; /**< \cfetlmmnemonic \TBL_OWNERAPP + \brief Name of owning application */ + boolean Critical; /**< \cfetlmmnemonic \TBL_CRITICAL + \brief Indicates whether table is Critical or not */ + uint8 ByteAlign4; /**< \cfetlmmnemonic \TBL_SPARE4 + \brief Spare byte to maintain byte alignment */ +} CFE_TBL_TblRegPacket_Payload_t; + +typedef struct +{ + uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; /**< \brief cFE Software Bus Telemetry Message Header */ + CFE_TBL_TblRegPacket_Payload_t Payload; +} CFE_TBL_TblRegPacket_t; + +/*************************************************************************/ + +#endif /* _cfe_tbl_msg_ */ + +/************************/ +/* End of File Comment */ +/************************/ diff --git a/src/components/interface/cFE/cfe_time.h b/src/components/interface/cFE/cfe_time.h new file mode 100644 index 0000000000..3362ac5349 --- /dev/null +++ b/src/components/interface/cFE/cfe_time.h @@ -0,0 +1,939 @@ +/* +** $Id: cfe_time.h 1.6 2014/08/17 17:23:30GMT-05:00 sstrege Exp $ +** +** Purpose: cFE Time Services (TIME) library API header file +** +** Author: S.Walling/Microtel +** +** Notes: +** +** $Log: cfe_time.h $ +** Revision 1.6 2014/08/17 17:23:30GMT-05:00 sstrege +** Fixed doxygen compiler warnings. +** Revision 1.5 2011/11/30 15:10:46EST jmdagost +** Replaced ifdef/ifndef preprocessor tests with if...==TRUE/if...!=TRUE tests +** Revision 1.4 2008/12/08 12:07:21EST dkobe +** Updates to correct doxygen errors +** Revision 1.3 2008/08/07 09:17:43EDT dkobe +** Doxygen comments corrected for CFE_TIME_RegisterSynchCallback +** and CFE_TIME_UnregisterSynchCallback +** Revision 1.2 2008/08/06 22:42:28EDT dkobe +** Added CFE_TIME_RegisterSynchCallback, CFE_TIME_UnregisterSynchCallback and CFE_TIME_CleanUpApp +** Revision 1.1 2008/04/17 08:05:25EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.9 2007/05/23 11:22:00EDT David Kobe (dlkobe) +** Added doxygen formatting +** Revision 1.8 2007/03/07 12:03:35EST njyanchik +** There were errors in the previous change package, so I fixed them +** Revision 1.7 2007/03/07 10:43:45EST njyanchik +** I made a new API called CFE_TIME_GetClockInfo that is functionally equivilant to CFE_TIME_GetStateFlags. The reason I made a new function is because this function +** will get changed in a future DCR (3191). +** Revision 1.5 2006/11/21 15:58:50EST rjmcgraw +** Added #define CFE_TIME_PRINTED_STRING_SIZE 24 +** Revision 1.4 2006/11/09 15:25:04EST wfmoleski +** Modified the function prototypes for ExternalMET, ExternalGPS and ExternalTime from int32 to void. +** Revision 1.3 2006/05/04 09:29:00EDT njyanchik +** Added MET to default spacecraft time conversion +** API is CFE_TIME_SysTime_t CFE_TIME_MET2SCTime (CFE_TIME_SysTime_t METTime) +** Revision 1.2 2005/07/21 15:28:21EDT lswalling +** Add Time print API function +** Revision 1.1 2005/06/09 10:57:51EDT rperera +** Initial revision +*/ + +/* +** Ensure that header is included only once... +*/ +#ifndef _cfe_time_ +#define _cfe_time_ + + +/* +** Required header files... +*/ +#include "common_types.h" + + +/* +** Defines +*/ +#define CFE_TIME_PRINTED_STRING_SIZE 24 /**< \brief Required size of buffer to be passed into #CFE_TIME_Print (includes null terminator) */ + +/* +** Type definition (system time)... +*/ +/** +** \brief Data structure used to hold system time values +** +** \par Description +** The #CFE_TIME_SysTime_t data structure is used to hold time +** values. Time is referred to as the elapsed time (in seconds +** and subseconds) since a specified epoch time. The subseconds +** field contains the number of 2^(-32) second intervals that have +** elapsed since the epoch. +** +*/ +typedef struct +{ + uint32 Seconds; /**< \brief Number of seconds since epoch */ + uint32 Subseconds; /**< \brief Number of subseconds since epoch (LSB = 2^(-32) seconds) */ +} CFE_TIME_SysTime_t; + +/* +** Type definition (clock state)... +*/ +/** +** \brief Enumerated types identifying the quality of the current time +** +** \par Description +** The #CFE_TIME_ClockState_t enumerations identify the three recognized states of the current time. +** If the clock has never been successfully synchronized with the primary onboard clock source, the +** time is conisdered to be #CFE_TIME_INVALID. If the time is currently synchronized (i.e. - the +** primary synchronization mechanism has not been dropped for any significant amount of time), then +** the current time is considered to be #CFE_TIME_VALID. If the time had, at some point in the past, +** been synchronized, but the synchronization with the primary onboard clock has since been lost, then +** the time is considered to be #CFE_TIME_FLYWHEEL. Since different clocks drift at different rates +** from one another, the accuracy of the time while in #CFE_TIME_FLYWHEEL is dependent upon the time +** spent in that state. +*/ +typedef enum +{ + CFE_TIME_INVALID = -1, /**< The spacecraft time has not been set since the last clock + ** reset. Times returned by clock routines have no relationship + ** to any ground-based time reference. + */ + CFE_TIME_VALID = 0, /**< The spacecraft time has been set at least once since the last + ** clock reset, and it is synchronized with the primary on-board + ** time base. Times returned by clock routines can be trusted. + */ + CFE_TIME_FLYWHEEL = 1 /**< The spacecraft time has been set at least once since the last + ** clock reset, but it is not currently synchronized with the + ** primary on-board time base. Times returned by clock routines + ** are a "best guess" based on a non-optimal oscillator. + */ +} CFE_TIME_ClockState_t; + +/* +** Type definition (time comparison results)... +*/ +/** +** \brief Enumerated types identifying the relative relationships of two times +** +** \par Description +** Since time fields contain numbers that are relative to an epoch time, then it is possible for a time value +** to be "negative". This can lead to some confusion about what relationship exists between two time values. +** To resolve this confusion, the cFE provides the API #CFE_TIME_Compare which returns these enumerated values. +*/ +typedef enum +{ + CFE_TIME_A_LT_B = -1, /**< \brief The first specified time is considered to be before the second specified time */ + CFE_TIME_EQUAL = 0, /**< \brief The two specified times are considered to be equal */ + CFE_TIME_A_GT_B = 1 /**< \brief The first specified time is considered to be after the second specified time */ +} CFE_TIME_Compare_t; + +/* +** Type definition (time portion the ES Reset data structure) +*/ +/** +** \brief Time related variables that are maintained through a Processor Reset +** +** \par Description +** The #CFE_TIME_ResetVars_t data structure contains those variables that are maintained +** in an area of memory that is not cleared during a Processor Reset. This allows the +** cFE Time Service to maintain time to the best of its ability after a Processor Reset. +*/ +typedef struct +{ + uint32 Signature; /**< \brief Data validation signature used to verify data structure contents*/ + int16 LeapSeconds; /**< \brief Leap seconds value */ + uint16 ClockSignal; /**< \brief Current clock signal selection */ + CFE_TIME_SysTime_t CurrentMET; /**< \brief Current Mission Elapsed Time (MET) */ + CFE_TIME_SysTime_t CurrentSTCF; /**< \brief Current Spacecraft Time Correlation Factor (STCF) */ + CFE_TIME_SysTime_t CurrentDelay; /**< \brief Current time client delay value */ + +} CFE_TIME_ResetVars_t; + +/** +** \brief Time Synchronization Callback Function Ptr Type +** +** \par Description +** Applications that wish to get direct notification of the receipt of the cFE Time Synchronization signal +** (typically a 1 Hz signal), must register a callback function with the following prototype via the +** #CFE_TIME_RegisterSynchCallback API. +*/ +typedef int32 (*CFE_TIME_SynchCallbackPtr_t)(void); + +/* +** Function prototypes (get time)... +*/ +/*****************************************************************************/ +/** +** \brief Get the current spacecraft time +** +** \par Description +** This routine returns the current spacecraft time. The time returned +** is either TAI (no leap seconds) or UTC (including leap seconds). This choice +** is made in the mission configuration file by defining either #CFE_TIME_CFG_DEFAULT_TAI +** or #CFE_TIME_CFG_DEFAULT_UTC as TRUE at compile time. To maintain re-usability +** across missions, most applications should be using this function +** (or #CFE_TIME_GetTime) rather than the specific routines for getting UTC/TAI directly. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** \retcode #CFE_TIME_SysTime_t \retdesc The current spacecraft time \endcode +** \endreturns +** +** \sa #CFE_TIME_GetTAI, #CFE_TIME_GetUTC, #CFE_TIME_GetMET, +** #CFE_TIME_GetMETseconds, #CFE_TIME_GetMETsubsecs +** +******************************************************************************/ +CFE_TIME_SysTime_t CFE_TIME_GetTime(void); /* returns default time (see default time selection above) */ + +/*****************************************************************************/ +/** +** \brief Get the current TAI time +** +** \par Description +** This routine returns the current TAI time to the caller. TAI is an +** international time standard that does not include leap seconds. +** This routine should only be used in situations where TAI is absolutely +** required. Applications that call #CFE_TIME_GetTAI() may not be portable +** to all missions. Maintenance of correct TAI in flight is not guaranteed +** under all mission operations scenarios. To maintain re-usability across +** missions, most applications should be using #CFE_TIME_GetTime(), rather +** than the specific routines for getting UTC/TAI directly. +** +** \par Assumptions, External Events, and Notes: +** -# The "TAI" time returned is referenced to the mission-defined time epoch, +** which may or may not be the same as the standard TAI epoch. +** -# Even though TAI does not include leap seconds, the time returned by this +** function can still jump forward or backward without warning when the +** spacecraft clock is set or adjusted by operators. Applications using +** this function must be able to handle these time discontinuities gracefully. +** +** \returns +** \retcode #CFE_TIME_SysTime_t \retdesc The current TAI time \endcode +** \endreturns +** +** \sa #CFE_TIME_GetTime, #CFE_TIME_GetUTC, #CFE_TIME_GetMET, +** #CFE_TIME_GetMETseconds, #CFE_TIME_GetMETsubsecs +** +******************************************************************************/ +CFE_TIME_SysTime_t CFE_TIME_GetTAI(void); /* returns time computed as TAI (MET + STCF) */ + +/*****************************************************************************/ +/** +** \brief Get the current UTC time +** +** \par Description +** This routine returns the current UTC time to the caller. This routine +** should only be used in situations where UTC is absolutely required. +** Applications that call #CFE_TIME_GetUTC() may not be portable to all +** missions. Maintenance of correct UTC in flight is not guaranteed under +** all mission operations scenarios. If UTC is maintained in flight, it will +** jump backwards occasionally due to leap second adjustments. To maintain +** re-usability across missions, most applications should be using +** #CFE_TIME_GetTime(), rather than the specific routines for getting +** UTC/TAI directly. +** +** \par Assumptions, External Events, and Notes: +** Note: The "UTC" time returned is referenced to the mission-defined time epoch, +** which may or may not be the same as the standard UTC epoch. +** +** \returns +** \retcode #CFE_TIME_SysTime_t \retdesc The current UTC time \endcode +** \endreturns +** +** \sa #CFE_TIME_GetTime, #CFE_TIME_GetTAI, #CFE_TIME_GetMET, +** #CFE_TIME_GetMETseconds, #CFE_TIME_GetMETsubsecs +** +******************************************************************************/ +CFE_TIME_SysTime_t CFE_TIME_GetUTC(void); /* returns time computed as UTC (MET + STCF - Leap Seconds) */ + +/*****************************************************************************/ +/** +** \brief Convert specified MET into Spacecraft Time +** +** \par Description +** This function returns Spacecraft Time given MET. Note that Spacecraft +** Time is returned as either UTC or TAI depeneding on whether the mission +** configuration parameter #CFE_TIME_CFG_DEFAULT_UTC or #CFE_TIME_CFG_DEFAULT_TAI +** was set to TRUE at compile time. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] METTime The MET to be converted. +** +** \returns +** \retcode #CFE_TIME_SysTime_t \retdesc Spacecraft Time (UTC or TAI) corresponding to the specified MET \endcode +** \endreturns +** +** \sa #CFE_TIME_GetMET, #CFE_TIME_GetMETseconds, #CFE_TIME_GetMETsubsecs, +** #CFE_TIME_Sub2MicroSecs, #CFE_TIME_Micro2SubSecs, #CFE_TIME_CFE2FSSeconds, #CFE_TIME_FS2CFESeconds +** +******************************************************************************/ +CFE_TIME_SysTime_t CFE_TIME_MET2SCTime (CFE_TIME_SysTime_t METTime); /* returns given MET time as the default spacecraft time */ + +/* +** Function prototypes (get parts of time)... +*/ + +/*****************************************************************************/ +/** +** \brief Get the current value of the spacecraft time correction factor (STCF). +** +** \par Description +** This routine returns the current value of the spacecraft time correction +** factor. This is the delta time between the MET and the TAI time. +** Applications cannot set or adjust the STCF; that can only be done +** through ground commands. However, science applications may want to +** include the STCF in their data products to aid in time correlation +** during downstream science data processing. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** \retcode #CFE_TIME_SysTime_t \retdesc The current STCF \endcode +** \endreturns +** +** \sa #CFE_TIME_GetLeapSeconds, #CFE_TIME_GetClockState, #CFE_TIME_GetClockInfo +** +******************************************************************************/ +CFE_TIME_SysTime_t CFE_TIME_GetSTCF(void); /* returns STCF (does not include leap seconds calculation) */ + +/*****************************************************************************/ +/** +** \brief Get the current value of the Mission Elapsed Time (MET). +** +** \par Description +** This routine returns the current mission-elapsed time (MET). MET is +** usually derived from a hardware-based clock that is not adjusted +** during normal operations. Callers of this routine should not assume +** that the MET return value has any specific relationship to any +** ground-based time standard. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** \retcode #CFE_TIME_SysTime_t \retdesc The current MET \endcode +** \endreturns +** +** \sa #CFE_TIME_GetTime, #CFE_TIME_GetTAI, #CFE_TIME_GetUTC, +** #CFE_TIME_GetMETseconds, #CFE_TIME_GetMETsubsecs, #CFE_TIME_MET2SCTime +** +******************************************************************************/ +CFE_TIME_SysTime_t CFE_TIME_GetMET(void); /* returns MET (both seconds and sub-seconds) */ + + +/*****************************************************************************/ +/** +** \brief Get the current seconds count of the mission-elapsed time. +** +** \par Description +** This routine is the same as #CFE_TIME_GetMET(), except that it +** returns only the integer seconds portion of the MET time. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** \retstmt The current MET seconds \endstmt +** \endreturns +** +** \sa #CFE_TIME_GetTime, #CFE_TIME_GetTAI, #CFE_TIME_GetUTC, #CFE_TIME_GetMET, +** #CFE_TIME_GetMETsubsecs, #CFE_TIME_MET2SCTime +** +******************************************************************************/ +uint32 CFE_TIME_GetMETseconds(void); /* returns MET "seconds" portion of current time */ + +/*****************************************************************************/ +/** +** \brief Get the current sub-seconds count of the mission-elapsed time. +** +** \par Description +** This routine is the same as #CFE_TIME_GetMET(), except that it +** returns only the integer sub-seconds portion of the MET time. +** Each count is equal to 2^(-32) seconds. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** \retstmt The current MET sub-seconds \endstmt +** \endreturns +** +** \sa #CFE_TIME_GetTime, #CFE_TIME_GetTAI, #CFE_TIME_GetUTC, #CFE_TIME_GetMET, +** #CFE_TIME_GetMETseconds, #CFE_TIME_MET2SCTime +** +******************************************************************************/ +uint32 CFE_TIME_GetMETsubsecs(void); /* returns MET "sub-seconds" portion of current time */ + +/*****************************************************************************/ +/** +** \brief Get the current value of the leap seconds counter. +** +** \par Description +** This routine returns the current value of the leap seconds counter. +** This is the delta seconds between international atomic time (TAI) +** and universal coordinated time (UTC). Applications cannot set or +** adjust the leap seconds; that can only be done through ground commands. +** However, science applications may want to include the leap seconds +** counter in their data products to aid in time correlation during +** downstream science data processing. Note that some mission operations +** teams do not maintain the leap seconds count, preferring to adjust the +** STCF instead. Users of this function should check with their mission +** ops team to see how they are planning to handle leap seconds. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** \retstmt The current leap seconds. \endstmt +** \endreturns +** +** \sa #CFE_TIME_GetSTCF, #CFE_TIME_GetClockState, #CFE_TIME_GetClockInfo +** +******************************************************************************/ +int16 CFE_TIME_GetLeapSeconds(void); /* returns Leap Seconds portion of current time */ + +/* +** Function prototypes (get time status)... +*/ + +/*****************************************************************************/ +/** +** \brief Get the current state of the spacecraft clock. +** +** \par Description +** This routine returns the spacecraft clock state. Applications that +** are highly dependent on valid time may want to call this routine +** before taking actions based on the times returned by the various +** clock routines +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** \retcode #CFE_TIME_ClockState_t \retdesc The current spacecraft clock state \endcode +** \endreturns +** +** \sa #CFE_TIME_GetSTCF, #CFE_TIME_GetLeapSeconds, #CFE_TIME_GetClockInfo +** +******************************************************************************/ +CFE_TIME_ClockState_t CFE_TIME_GetClockState(void); /* returns current spacecraft clock state */ + +/*****************************************************************************/ +/** +** \brief Provides information about the spacecraft clock. +** +** \par Description +** This routine returns information on the spacecraft clock in a bit mask. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** \retstmt Spacecraft clock information. To extract the information from the +** returned value, the following masks can be used as in the following:
+** if ((ReturnValue & CFE_TIME_FLAG_xxxxxx) == CFE_TIME_FLAG_xxxxxx) then +** the following definition of the \c CFE_TIME_FLAG_xxxxxx is true.
\endstmt +** \retcode #CFE_TIME_FLAG_CLKSET \retdesc \copydoc CFE_TIME_FLAG_CLKSET \endcode +** \retcode #CFE_TIME_FLAG_FLYING \retdesc \copydoc CFE_TIME_FLAG_FLYING \endcode +** \retcode #CFE_TIME_FLAG_SRCINT \retdesc \copydoc CFE_TIME_FLAG_SRCINT \endcode +** \retcode #CFE_TIME_FLAG_SIGPRI \retdesc \copydoc CFE_TIME_FLAG_SIGPRI \endcode +** \retcode #CFE_TIME_FLAG_SRVFLY \retdesc \copydoc CFE_TIME_FLAG_SRVFLY \endcode +** \retcode #CFE_TIME_FLAG_CMDFLY \retdesc \copydoc CFE_TIME_FLAG_CMDFLY \endcode +** \retcode #CFE_TIME_FLAG_ADDADJ \retdesc \copydoc CFE_TIME_FLAG_ADDADJ \endcode +** \retcode #CFE_TIME_FLAG_ADD1HZ \retdesc \copydoc CFE_TIME_FLAG_ADD1HZ \endcode +** \retcode #CFE_TIME_FLAG_ADDTCL \retdesc \copydoc CFE_TIME_FLAG_ADDTCL \endcode +** \retcode #CFE_TIME_FLAG_SERVER \retdesc \copydoc CFE_TIME_FLAG_SERVER \endcode +** \retcode #CFE_TIME_FLAG_GDTONE \retdesc \copydoc CFE_TIME_FLAG_GDTONE \endcode +** \retcode #CFE_TIME_FLAG_UNUSED \retdesc \copydoc CFE_TIME_FLAG_UNUSED \endcode +** \endreturns +** +** \sa #CFE_TIME_GetSTCF, #CFE_TIME_GetLeapSeconds, #CFE_TIME_GetClockState +** +******************************************************************************/ +uint16 CFE_TIME_GetClockInfo(void); /* returns clock information */ + + +/* +** Function prototypes (add/subtract/compare time)... +*/ + +/*****************************************************************************/ +/** +** \brief Adds two time values +** +** \par Description +** This routine adds the two specified times and returns the result. +** Normally, at least one of the input times should be a value representing +** a delta time. Adding two absolute times together will not cause an error, +** but the result will probably be meaningless. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] Time1 The first time to be added. +** +** \param[in] Time2 The second time to be added. +** +** \returns +** \retstmt The sum of the two times, in the #CFE_TIME_SysTime_t format described above. +** If the sum is greater than the maximum value that can be stored in a +** #CFE_TIME_SysTime_t, the result will roll over (this is not considered an error). \endstmt +** \endreturns +** +** \sa #CFE_TIME_Subtract, #CFE_TIME_Compare +** +******************************************************************************/ +CFE_TIME_SysTime_t CFE_TIME_Add(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Time2); /* (Time1 + Time2) */ + +/*****************************************************************************/ +/** +** \brief Subtracts two time values +** +** \par Description +** This routine subtracts time2 from time1 and returns the result. The +** time values can represent either absolute or delta times, but not all +** combinations make sense. +** - AbsTime - AbsTime = DeltaTime +** - AbsTime - DeltaTime = AbsTime +** - DeltaTime - DeltaTime = DeltaTime +** - DeltaTime - AbsTime = garbage +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] Time1 The base time. +** +** \param[in] Time2 The time to be subtracted from the base time. +** +** \returns +** \retstmt The result of subtracting the two times, in the #CFE_TIME_SysTime_t +** format. If the subtraction results in an underflow, the result will +** roll over (this is not considered an error). \endstmt +** \endreturns +** +** \sa #CFE_TIME_Add, #CFE_TIME_Compare +** +******************************************************************************/ +CFE_TIME_SysTime_t CFE_TIME_Subtract(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Time2); /* (Time1 - Time2) */ + +/*****************************************************************************/ +/** +** \brief Compares two time values +** +** \par Description +** This routine compares two time values to see which is "greater". It +** is important that applications use this function rather than trying +** to directly compare the component pieces of times. This function will +** handle roll-over cases seamlessly, which may not be intuitively obvious. +** The cFE's internal representation of time "rolls over" when the 32 bit +** seconds count reaches 0xFFFFFFFF. Also, subtracting a delta time from +** an absolute time close to the epoch could result in "roll under". The +** strange cases that result from these situations can be handled by defining +** the comparison function for times as follows: +** Plot the two times on the circumference of a circle where 0 is at the +** top and 0x80000000 is at the bottom. If the shortest arc from time A +** to time B runs clockwise around the circle, then time A is less than +** time B. If the shortest arc from A to B runs counter-clockwise, then +** time A is greater than time B. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TimeA The first time to compare. +** +** \param[in] TimeB The second time to compare. +** +** \returns +** \retstmt The result of comparing the two times, one of: \endstmt +** \retcode #CFE_TIME_EQUAL \retdesc \copydoc CFE_TIME_EQUAL \endcode +** \retcode #CFE_TIME_A_GT_B \retdesc \copydoc CFE_TIME_A_GT_B \endcode +** \retcode #CFE_TIME_A_LT_B \retdesc \copydoc CFE_TIME_A_LT_B \endcode +** \endreturns +** +** \sa #CFE_TIME_Add, #CFE_TIME_Subtract +** +******************************************************************************/ +CFE_TIME_Compare_t CFE_TIME_Compare(CFE_TIME_SysTime_t TimeA, CFE_TIME_SysTime_t TimeB); /* (TimeA <=> TimeB) */ + +/* +** Function prototypes (convert sub-seconds)... +*/ + +/*****************************************************************************/ +/** +** \brief Converts a sub-seconds count to an equivalent number of microseconds +** +** \par Description +** This routine converts from a sub-seconds count +** (each tick is 1 / 2^32 seconds) to microseconds (each tick is 1e-06 seconds). +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] SubSeconds The sub-seconds count to convert. +** +** \returns +** \retstmt The equivalent number of microseconds. \endstmt +** \endreturns +** +** \sa #CFE_TIME_MET2SCTime, #CFE_TIME_Micro2SubSecs, +** #CFE_TIME_CFE2FSSeconds, #CFE_TIME_FS2CFESeconds +** +******************************************************************************/ +uint32 CFE_TIME_Sub2MicroSecs(uint32 SubSeconds); /* convert sub-seconds (1/2^32) to micro-seconds (1/1000000) */ + +/*****************************************************************************/ +/** +** \brief Converts a number of microseconds to an equivalent sub-seconds count. +** +** \par Description +** This routine converts from microseconds (each tick is 1e-06 seconds) +** to a subseconds count (each tick is 1 / 2^32 seconds). +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MicroSeconds The sub-seconds count to convert. +** +** \returns +** \retstmt The equivalent number of subseconds. If the number of microseconds +** passed in is greater than one second, (i.e. > 999,999), the return +** value is equal to \c 0xffffffff. \endstmt +** \endreturns +** +** \sa #CFE_TIME_MET2SCTime, #CFE_TIME_Sub2MicroSecs, +** #CFE_TIME_CFE2FSSeconds, #CFE_TIME_FS2CFESeconds +** +******************************************************************************/ +uint32 CFE_TIME_Micro2SubSecs(uint32 MicroSeconds); /* convert micro-seconds (1/1000000) to sub-seconds (1/2^32) */ + +/* +** Function prototypes (convert cFE and file system time formats)... +*/ + +/*****************************************************************************/ +/** +** \brief Converts cFE seconds into the File System's seconds +** +** \par Description +** File systems use specific time epochs for their time tagging of files. +** Since spacecraft systems rarely use an epoch that matches a particular +** file system, this function provides a mechanism to translate a given +** spacecraft time (in seconds) to the file system's time. The conversion +** is controlled by the configuration parameter #CFE_TIME_FS_FACTOR which +** is set equal to the number of seconds between the spacecraft's epoch and +** the file system's epoch. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] SecondsCFE The spacecraft time, in seconds, to be converted. +** +** \returns +** \retstmt The equivalent time, in seconds, for the file system. \endstmt +** \endreturns +** +** \sa #CFE_TIME_MET2SCTime, #CFE_TIME_Sub2MicroSecs, #CFE_TIME_Micro2SubSecs, +** #CFE_TIME_FS2CFESeconds +** +******************************************************************************/ +uint32 CFE_TIME_CFE2FSSeconds(uint32 SecondsCFE); + +/*****************************************************************************/ +/** +** \brief Converts a file system's seconds into cFE seconds +** +** \par Description +** File systems use specific time epochs for their time tagging of files. +** Since spacecraft systems rarely use an epoch that matches a particular +** file system, this function provides a mechanism to translate a file +** system time (in seconds) into the spacecraft time (in seconds). The +** conversion is controlled by the configuration parameter #CFE_TIME_FS_FACTOR +** which is set equal to the number of seconds between the spacecraft's epoch and +** the file system's epoch. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] SecondsFS The file system time, in seconds, to be converted. +** +** \returns +** \retstmt The equivalent time, in seconds, for the spacecraft. \endstmt +** \endreturns +** +** \sa #CFE_TIME_MET2SCTime, #CFE_TIME_Sub2MicroSecs, #CFE_TIME_Micro2SubSecs, +** #CFE_TIME_CFE2FSSeconds +** +******************************************************************************/ +uint32 CFE_TIME_FS2CFESeconds(uint32 SecondsFS); + +/* +** Function prototypes (convert time to string)... +*/ + +/*****************************************************************************/ +/** +** \brief Print a time value as a string +** +** \par Description +** This routine prints the specified time to the specified string buffer +** in the following format:

+** \c yyyy-ddd-hh:mm:ss.xxxxx\\0

+** where: +** - \c yyyy = year +** - \c ddd = Julian day of the year +** - \c hh = hour of the day (0 to 23) +** - \c mm = minute (0 to 59) +** - \c ss = second (0 to 59) +** - \c xxxxx = subsecond formatted as a decimal fraction (1/4 second = 0.25000) +** - \c \\0 = trailing null +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] PrintBuffer Pointer to a character array of at least +** #CFE_TIME_PRINTED_STRING_SIZE characters in length +** +** \param[in] TimeToPrint The time to print into the character array. +** +** \param[out] *PrintBuffer The time as a character string as described above. +** +** \sa +** +******************************************************************************/ +void CFE_TIME_Print(char *PrintBuffer, CFE_TIME_SysTime_t TimeToPrint); + +/* +** Function prototypes (1hz tone signal processor)... +*/ + +/*****************************************************************************/ +/** +** \brief Provides the 1 Hz signal from an external source +** +** \par Description +** This routine provides a method for cFE TIME software to be notified +** of the occurance of the 1Hz tone signal without knowledge of the +** specific hardware design. Regardless of the source of the tone, +** this routine should be called as soon as possible after detection +** to allow cFE TIME software the opportunity to latch the local clock +** as close as possible to the instant of the tone. +** +** \par Assumptions, External Events, and Notes: +** - This routine may be called directly from within the context of an +** interrupt handler. +** +** \sa #CFE_TIME_ExternalMET, #CFE_TIME_ExternalGPS, #CFE_TIME_ExternalTime +** +******************************************************************************/ +void CFE_TIME_ExternalTone(void); /* OK to call from ISR */ + +/* +** Function prototypes (external time source)... +** +** If a Time Server has been configured to accept external time +** data, then one of the following functions will be enabled. +** +** If the Time Server has also been commanded to use the external +** time data (as opposed to getting time data from a local MET) +** then the Time Server will use the external data in computing +** time. +** +** However, regardless whether the external time data is accepted +** by the Time Server, these functions also act as the signal to +** create and distribute the "time at the tone" command packet. +*/ + + +/*****************************************************************************/ +/** +** \brief Provides the Mission Elapsed Time from an external source +** +** \par Description +** This routine provides a method to provide cFE TIME with MET acquired +** from an external source. There is a presumption that this function +** will be called at the appropriate time (relative to the tone) such +** that this call may be used by cFE TIME as the signal to generate the +** "time at the tone" data command. The "time at the tone" data command +** must arrive within the configuration parameter specified window for +** tone signal and data packet verification.

+** The MET value at the tone "should" have zero subseconds. Although the +** interface accepts non-zero values for sub-seconds, it may be harmful +** to other applications that expect zero subseconds at the moment of the +** tone. Any decision to use non-zero subseconds should be carefully considered. +** +** \par Assumptions, External Events, and Notes: +** - This routine is included in the API only when 3 specific configuration +** parameters are set to TRUE. The first is #CFE_TIME_CFG_SERVER which defines +** this instantiation of cFE TIME as a time server (not a client). The +** second required configuration parameter is #CFE_TIME_CFG_SOURCE which +** enables time source selection commands to the cFE TIME task, and further +** enables configuration definitions for the selected type of external time +** data. The third configuration parameter required for this routine is +** #CFE_TIME_CFG_SRC_MET, which indicates that the external time data consists +** of MET. +** +** \param[in] NewMET The MET value at the next (or previous) 1 Hz tone signal. +** +** \sa #CFE_TIME_ExternalTone, #CFE_TIME_ExternalGPS, #CFE_TIME_ExternalTime +** +******************************************************************************/ +void CFE_TIME_ExternalMET(CFE_TIME_SysTime_t NewMET); + + +/*****************************************************************************/ +/** +** \brief Provide the time from an external source that has data common to GPS receivers. +** +** \par Description +** This routine provides a method to provide cFE TIME with current time +** data acquired from an external source. There is a presumption that +** this function will be called at the appropriate time (relative to the +** tone) such that this call may be used by cFE TIME as the signal to +** generate the "time at the tone" data command. The "time at the tone" +** data command must arrive within the configuration parameter specified +** window for tone signal and data packet verification.

+** Internally, cFE TIME will calculate a new STCF as the difference between +** this new time value and the spacecraft MET value at the tone. This allows +** cFE TIME to always calculate time as the sum of MET and STCF. The value +** of STCF will change only as much as the drift factor between spacecraft +** MET and the external time source. +** +** \par Assumptions, External Events, and Notes: +** - This routine is included in the API only when 3 specific configuration +** parameters are set to TRUE. The first is #CFE_TIME_CFG_SERVER which defines this +** instantiation of cFE TIME as a time server (not a client). The second +** required configuration parameter is #CFE_TIME_CFG_SOURCE which enables +** time source selection commands to the cFE TIME task, and further enables +** configuration definitions for the selected type of external time data. +** The third configuration parameter required for this routine is +** #CFE_TIME_CFG_SRC_GPS, which indicates that the external time data consists +** of a time value relative to a known epoch, plus a leap seconds value. +** +** \param[in] NewTime The MET value at the next (or previous) 1 Hz tone signal. +** +** \param[in] NewLeaps The Leap Seconds value used to calculate time as UTC. +** +** \sa #CFE_TIME_ExternalTone, #CFE_TIME_ExternalMET, #CFE_TIME_ExternalTime +** +******************************************************************************/ +void CFE_TIME_ExternalGPS(CFE_TIME_SysTime_t NewTime, int16 NewLeaps); + + + +/*****************************************************************************/ +/** +** \brief Provide the time from an external source that measures time relative to a known epoch. +** +** \par Description +** This routine provides a method to provide cFE TIME with current time +** data acquired from an external source. There is a presumption that +** this function will be called at the appropriate time (relative to the +** tone) such that this call may be used by cFE TIME as the signal to +** generate the "time at the tone" data command. The "time at the tone" +** data command must arrive within the configuration specified window for +** tone signal and data packet verification.

+** Internally, cFE TIME will calculate a new STCF as the difference between +** this new time value and the spacecraft MET value at the tone. This allows +** cFE TIME to always calculate time as the sum of MET and STCF. The value +** of STCF will change only as much as the drift factor between spacecraft +** MET and the external time source. +** +** \par Assumptions, External Events, and Notes: +** - This routine is included in the API only when 3 specific configuration +** parameters are set to TRUE. The first is #CFE_TIME_CFG_SERVER which defines this +** instanciation of cFE TIME as a time server (not a client). The second +** required configuration parameter is #CFE_TIME_CFG_SOURCE which enables +** time source selection commands to the cFE TIME task, and further enables +** configuration definitions for the selected type of external time data. +** The third configuration parameter required for this routine is +** #CFE_TIME_CFG_SRC_TIME, which indicates that the external time data consists +** of a time value relative to a known epoch. +** +** \param[in] NewTime The MET value at the next (or previous) 1 Hz tone signal. +** +** \sa #CFE_TIME_ExternalTone, #CFE_TIME_ExternalMET, #CFE_TIME_ExternalGPS +** +******************************************************************************/ +void CFE_TIME_ExternalTime(CFE_TIME_SysTime_t NewTime); + +/*****************************************************************************/ +/** +** \brief Registers a callback function that is called whenever time synchronization occurs +** +** \par Description +** This routine passes a callback function pointer for an Application that wishes to +** be notified whenever a legitimate time synchronization signal (typically a 1 Hz) +** is received. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_TIME_TOO_MANY_SYNCH_CALLBACKS \retdesc \copydoc CFE_TIME_TOO_MANY_SYNCH_CALLBACKS \endcode +** \retcode #CFE_ES_ERR_APPID \retdesc \copydoc CFE_ES_ERR_APPID \endcode +** \endreturns +** +** \sa #CFE_TIME_UnregisterSynchCallback +** +******************************************************************************/ +int32 CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr); + + +/*****************************************************************************/ +/** +** \brief Unregisters a callback function that is called whenever time synchronization occurs +** +** \par Description +** This routine removes the specified callback function pointer from the list +** of Callback functions that are called whenever a time synchronization (typically +** the 1Hz signal) is received. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode +** \retcode #CFE_TIME_CALLBACK_NOT_REGISTERED \retdesc \copydoc CFE_TIME_CALLBACK_NOT_REGISTERED \endcode +** \retcode #CFE_ES_ERR_APPID \retdesc \copydoc CFE_ES_ERR_APPID \endcode +** \endreturns +** +** \sa #CFE_TIME_RegisterSynchCallback +** +******************************************************************************/ +int32 CFE_TIME_UnregisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr); + + +/*****************************************************************************/ +/** +** \brief This function should be called from the system PSP layer once per second +** +** \par Description +** Drives the time processing logic from the system PSP layer. This must be called +** once per second based on a hardware interrupt or OS kernel signal. +** +** \par Assumptions, External Events, and Notes: +** This will update the global data structures accordingly, incrementing each +** by the 1Hz amount. +** +** +******************************************************************************/ +void CFE_TIME_Local1HzISR(void); + + +#endif /* _cfe_time_ */ + +/************************/ +/* End of File Comment */ +/************************/ diff --git a/src/components/interface/cFE/cfe_time_events.h b/src/components/interface/cFE/cfe_time_events.h new file mode 100644 index 0000000000..209d3df283 --- /dev/null +++ b/src/components/interface/cFE/cfe_time_events.h @@ -0,0 +1,592 @@ +/* +** +** Filename: cfe_time_events.h +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +* +** $Id: cfe_time_events.h 1.5 2011/11/30 15:10:44GMT-05:00 jmdagost Exp $ +** +** Purpose: +** cFE Time Services (Time) Event IDs +** +** Design Notes: +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** +** +** $Date: 2011/11/30 15:10:44GMT-05:00 $ +** $Revision: 1.5 $ +** $Log $ +*/ + +#ifndef _cfe_time_events_ +#define _cfe_time_events_ + +/* +** Event message ID's... +*/ +/** \brief 'cFE TIME Initialized' +** \event 'cFE TIME Initialized' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always automatically issued when the Time Services +** Task completes its Initialization. +**/ +#define CFE_TIME_INIT_EID 1 /* start up message "informational" */ + +/** \brief 'No-op command' +** \event 'No-op command' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is always automatically issued in response +** to a cFE Time Services \link #CFE_TIME_NOOP_CC NO-OP command \endlink +**/ +#define CFE_TIME_NOOP_EID 4 /* processed command "informational" */ + +/** \brief 'Reset Counters command' +** \event 'Reset Counters command' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is always automatically issued in response +** to a cFE Time Services \link #CFE_TIME_RESET_CC Reset Counters command \endlink +**/ +#define CFE_TIME_RESET_EID 5 + +/** \brief 'Request diagnostics command' +** \event 'Request diagnostics command' +** +** \par Type: DEBUG +** +** \par Cause: +** +** This event message is always automatically issued in response +** to a cFE Time Services \link #CFE_TIME_DIAG_TLM_CC Request Diagnostics command \endlink +**/ +#define CFE_TIME_DIAG_EID 6 + +/** \brief 'Set Clock State = \%s' +** \event 'Set Clock State = \%s' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated upon successful completion +** of a cFE Time Services \link #CFE_TIME_SET_STATE_CC Set Time State command \endlink +** +** The \c '\%s' field will identify whether the command specified +** \c VALID, \c INVALID, or \c FLYWHEEL. +**/ +#define CFE_TIME_STATE_EID 7 + +/** \brief 'Set Time Source = \%s' +** \event 'Set Time Source = \%s' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated upon successful completion +** of a cFE Time Services \link #CFE_TIME_SET_SOURCE_CC Set Time Source command \endlink +** +** The \c '\%s' field will identify whether the command specified +** \c INTERNAL, or \c EXTERNAL. +**/ +#define CFE_TIME_SOURCE_EID 8 + +/** \brief 'Set Tone Source = \%s' +** \event 'Set Tone Source = \%s' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated upon successful completion +** of a cFE Time Services \link #CFE_TIME_SET_SIGNAL_CC Set Clock Signal command \endlink +** +** The \c '\%s' field will identify whether the command specified +** \c PRIMARY, or \c REDUNDANT. +**/ +#define CFE_TIME_SIGNAL_EID 9 + + +/** \brief 'Set Tone Delay -- secs = \%d, usecs = \%d, ssecs = 0x\%X, dir = \%d' +** \event 'Set Tone Delay -- secs = \%d, usecs = \%d, ssecs = 0x\%X, dir = \%d' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated upon successful completion +** of either a cFE Time Services +** \link #CFE_TIME_ADD_DELAY_CC Add Time Delay \endlink OR a +** \link #CFE_TIME_SUB_DELAY_CC Subtract Time Delay command \endlink +** +** The \c secs field specifies the new delay (in seconds), the \c usecs +** field specifies the delay in micro-seconds, the \c ssecs field is +** the micro-seconds field converted to Spacecraft Time sub-seconds and +** the \c dir field identifies the direction of the delay. The direction +** can be either #CFE_TIME_ADD_ADJUST or #CFE_TIME_SUB_ADJUST. +**/ +#define CFE_TIME_DELAY_EID 11 + +/** \brief 'Set Time -- secs = \%d, usecs = \%d, ssecs = 0x\%X' +** \event 'Set Time -- secs = \%d, usecs = \%d, ssecs = 0x\%X' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated upon successful completion +** of a cFE Time Services \link #CFE_TIME_SET_TIME_CC Set Time command \endlink +** +** The \c secs field specifies the new spacecraft time (in seconds), the \c usecs +** field specifies the spacecraft time micro-seconds, the \c ssecs field is +** the micro-seconds field converted to Spacecraft Time sub-seconds +**/ +#define CFE_TIME_TIME_EID 12 + +/** \brief 'Set MET -- secs = \%d, usecs = \%d, ssecs = 0x\%X' +** \event 'Set MET -- secs = \%d, usecs = \%d, ssecs = 0x\%X' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated upon successful completion +** of a cFE Time Services \link #CFE_TIME_SET_MET_CC Set Mission Elapsed Time command \endlink +** +** The \c secs field specifies the new MET (in seconds), the \c usecs +** field specifies the MET micro-seconds, the \c ssecs field is +** the micro-seconds field converted to Spacecraft Time sub-seconds +**/ +#define CFE_TIME_MET_EID 13 + +/** \brief 'Set STCF -- secs = \%d, usecs = \%d, ssecs = 0x\%X' +** \event 'Set STCF -- secs = \%d, usecs = \%d, ssecs = 0x\%X' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated upon successful completion +** of a cFE Time Services \link #CFE_TIME_SET_STCF_CC Set Spacecraft Time +** Correlation Factor command \endlink +** +** The \c secs field specifies the new STCF (in seconds), the \c usecs +** field specifies the STCF micro-seconds, the \c ssecs field is +** the micro-seconds field converted to Spacecraft Time sub-seconds. +**/ +#define CFE_TIME_STCF_EID 14 + +/** \brief 'STCF Adjust -- secs = \%d, usecs = \%d, ssecs = 0x\%X, dir[1=Positive, 2=Negative] = \%d' +** \event 'STCF Adjust -- secs = \%d, usecs = \%d, ssecs = 0x\%X, dir[1=Positive, 2=Negative] = \%d' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated upon successful completion +** of any of the following cFE Time Services STCF Adjustment Commands: +** - \link #CFE_TIME_ADD_ADJUST_CC Add Single STCF Adjustment command \endlink +** - \link #CFE_TIME_SUB_ADJUST_CC Subtract Single STCF Adjustment command \endlink +** +** The \c secs field specifies the number of seconds the STCF is to be adjusted by, +** the \c usecs field specifies the number of micro-seconds, the \c ssecs field is +** the micro-seconds field converted to Spacecraft Time sub-seconds and the \c dir +** field identifies whether the adjustment was added or subtracted. The direction +** can be either #CFE_TIME_ADD_ADJUST or #CFE_TIME_SUB_ADJUST. +**/ +#define CFE_TIME_DELTA_EID 15 + +/** \brief 'STCF 1Hz Adjust -- secs = \%d, ssecs = 0x\%X, dir = \%d' +** \event 'STCF 1Hz Adjust -- secs = \%d, ssecs = 0x\%X, dir = \%d' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated upon successful completion +** of any of the following cFE Time Services STCF Adjustment Commands: +** - \link #CFE_TIME_ADD_1HZADJ_CC Add STCF Adjustment each second command \endlink +** - \link #CFE_TIME_SUB_1HZADJ_CC Subtract STCF Adjustment each second command \endlink +** +** The \c secs field specifies the number of seconds the STCF is to be adjusted by, +** the \c ssecs field specifies the number of sub-seconds (1/2^32 seconds) the STCF +** is to be adjusted by and the \c dir field identifies whether the adjustment was +** added or subtracted. The direction value can be either #CFE_TIME_ADD_ADJUST or +** #CFE_TIME_SUB_ADJUST. +**/ +#define CFE_TIME_1HZ_EID 16 + +/** \brief 'Set Leap Seconds = \%d' +** \event 'Set Leap Seconds = \%d' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated upon successful completion +** of the \link #CFE_TIME_SET_LEAPS_CC Set Leap Seconds command \endlink +** +** The \c \%d field contains the number of seconds the Spacecraft's Leap Seconds +** has been set to. +**/ +#define CFE_TIME_LEAPS_EID 17 + +/** \brief 'Start FLYWHEEL' +** \event 'Start FLYWHEEL' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated whenever the Time Services enters FLYWHEEL mode. +**/ +#define CFE_TIME_FLY_ON_EID 20 /* flywheel state "informational" */ + +/** \brief 'Stop FLYWHEEL' +** \event 'Stop FLYWHEEL' +** +** \par Type: INFORMATION +** +** \par Cause: +** +** This event message is generated whenever the Time Services exits FLYWHEEL mode. +**/ +#define CFE_TIME_FLY_OFF_EID 21 + +#define CFE_TIME_EXIT_ERR_EID 25 /* task termination "error" */ + +/** \brief 'Invalid message ID -- ID = 0x\%X' +** \event 'Invalid message ID -- ID = 0x\%X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** a message from the software bus that is not one of Time Services +** recognized messages. +** +** The \c ID field specifies, in hex, the message ID of the inappropriately +** received message. +**/ +#define CFE_TIME_ID_ERR_EID 26 /* invalid command packet "error" */ + +/** \brief 'Invalid command code -- ID = 0x\%X, CC = \%d' +** \event 'Invalid command code -- ID = 0x\%X, CC = \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** a message from the software bus that contains a unrecognized command +** code in its header.. +** +** The \c ID field specifies, in hex, the message ID of the message containing +** the unrecognized command code, identified, in decimal, by the \c CC field. +**/ +#define CFE_TIME_CC_ERR_EID 27 + +/** \brief 'Invalid Clock State = 0x\%X' +** \event 'Invalid Clock State = 0x\%X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** a \link #CFE_TIME_SET_STATE_CC Set Clock State Command \endlink +** that contains a desired clock state that is none of the following: +** - #CFE_TIME_INVALID +** - #CFE_TIME_VALID +** - #CFE_TIME_FLYWHEEL +** +** The \c State field specifies, in hex, the state value received +** in the command message. +**/ +#define CFE_TIME_STATE_ERR_EID 30 /* processed command "error" */ + +/** \brief 'Invalid Time Source = 0x\%X' +** \event 'Invalid Time Source = 0x\%X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** a \link #CFE_TIME_SET_SOURCE_CC Set Clock Source Command \endlink +** that contains a desired clock source that is none of the following: +** - #CFE_TIME_USE_INTERN +** - #CFE_TIME_USE_EXTERN +** +** The \c Source field specifies, in hex, the source value received +** in the command message. +**/ +#define CFE_TIME_SOURCE_ERR_EID 31 + +/** \brief 'Invalid Tone Source = 0x\%X' +** \event 'Invalid Tone Source = 0x\%X' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** a \link #CFE_TIME_SET_SIGNAL_CC Set Clock Signal Command \endlink +** that contains a desired clock source that is none of the following: +** - #CFE_TIME_TONE_PRI +** - #CFE_TIME_TONE_RED +** +** The \c Source field specifies, in hex, the signal source value received +** in the command message. +**/ +#define CFE_TIME_SIGNAL_ERR_EID 32 + +/** \brief 'Invalid Tone Delay -- secs = \%d, usecs = \%d' +** \event 'Invalid Tone Delay -- secs = \%d, usecs = \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** either a \link #CFE_TIME_ADD_DELAY_CC Add Tone Delay Command \endlink +** OR a \link #CFE_TIME_SUB_DELAY_CC Subtract Tone Delay Command \endlink +** that contains a microsecond field that is greater than or equal to +** 1000000. +** +** The \c secs field specifies, in decimal, the tone signal delay in seconds +** and the \c usecs field specifies, in decimal, the micro-second delay that +** was in error. +**/ +#define CFE_TIME_DELAY_ERR_EID 33 + +/** \brief 'Invalid Time -- secs = \%d, usecs = \%d' +** \event 'Invalid Time -- secs = \%d, usecs = \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** a \link #CFE_TIME_SET_TIME_CC Set Spacecraft Time Command \endlink +** that contains a microsecond field that is greater than or equal to +** 1,000,000. +** +** The \c secs field specifies, in decimal, the spacecraft time in seconds +** and the \c usecs field specifies, in decimal, the micro-second field of +** the spacecraft time that was in error. +**/ +#define CFE_TIME_TIME_ERR_EID 34 + +/** \brief 'Invalid MET -- secs = \%d, usecs = \%d' +** \event 'Invalid MET -- secs = \%d, usecs = \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** a \link #CFE_TIME_SET_MET_CC Set Mission Elapsed Time Command \endlink +** that contains a microsecond field that is greater than or equal to +** 1,000,000. +** +** The \c secs field specifies, in decimal, the MET in seconds +** and the \c usecs field specifies, in decimal, the micro-second field of +** the MET that was in error. +**/ +#define CFE_TIME_MET_ERR_EID 35 + +/** \brief 'Invalid STCF -- secs = \%d, usecs = \%d' +** \event 'Invalid STCF -- secs = \%d, usecs = \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** a \link #CFE_TIME_SET_STCF_CC Set Spacecraft Time Correlation Factor Command \endlink +** that contains a microsecond field that is greater than or equal to +** 1,000,000. +** +** The \c secs field specifies, in decimal, the STCF in seconds +** and the \c usecs field specifies, in decimal, the micro-second field of +** the STCF that was in error. +**/ +#define CFE_TIME_STCF_ERR_EID 36 + +/** \brief 'Invalid STCF Adjust -- secs = \%d, usecs = \%d, dir[1=Positive, 2=Negative] = \%d' +** \event 'Invalid STCF Adjust -- secs = \%d, usecs = \%d, dir[1=Positive, 2=Negative] = \%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** either a \link #CFE_TIME_ADD_ADJUST_CC Add Single STCF Adjustment Command \endlink +** OR a \link #CFE_TIME_SUB_ADJUST_CC Subtract Single STCF Adjustment command \endlink +** that contains a microsecond field that is greater than or equal to +** 1,000,000. +** +** The \c secs field specifies the number of seconds the STCF is to be adjusted by, +** the \c usecs field specifies the number of micro-seconds that was in error, the \c dir +** field identifies whether the adjustment was to be added or subtracted. The direction +** can be either #CFE_TIME_ADD_ADJUST or #CFE_TIME_SUB_ADJUST. +**/ +#define CFE_TIME_DELTA_ERR_EID 37 + +/** (obsolete - unused) +**/ +#define CFE_TIME_1HZ_ERR_EID 38 + +/** \brief 'Set Source commands invalid without CFE_TIME_CFG_SOURCE set to TRUE' +** \event 'Set Source commands invalid without CFE_TIME_CFG_SOURCE set to TRUE' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** a \link #CFE_TIME_SET_SOURCE_CC Set Clock Source Command \endlink +** and the Time Services configuration parameter #CFE_TIME_CFG_SOURCE has +** not been set to TRUE in the cfe_platform_cfg.h file. +**/ +#define CFE_TIME_SOURCE_CFG_EID 40 /* cmd disabled per cfg "error" */ + +/** \brief 'Set Signal commands invalid without CFE_TIME_CFG_SIGNAL set to TRUE' +** \event 'Set Signal commands invalid without CFE_TIME_CFG_SIGNAL set to TRUE' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** a \link #CFE_TIME_SET_SIGNAL_CC Set Clock Signal Command \endlink +** and the Time Services configuration parameter #CFE_TIME_CFG_SIGNAL has +** not been set to TRUE in the cfe_platform_cfg.h file. +**/ +#define CFE_TIME_SIGNAL_CFG_EID 41 + +/** \brief 'Set Delay commands invalid without CFE_TIME_CFG_CLIENT set to TRUE' +** \event 'Set Delay commands invalid without CFE_TIME_CFG_CLIENT set to TRUE' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** either a \link #CFE_TIME_ADD_DELAY_CC Add Tone Delay Command \endlink +** OR a \link #CFE_TIME_SUB_DELAY_CC Subtract Tone Delay Command \endlink +** and the Time Services configuration parameter #CFE_TIME_CFG_CLIENT has +** not been set to TRUE in the cfe_platform_cfg.h file. +**/ +#define CFE_TIME_DELAY_CFG_EID 42 + +/** \brief 'Set Time commands invalid without CFE_TIME_CFG_SERVER set to TRUE' +** \event 'Set Time commands invalid without CFE_TIME_CFG_SERVER set to TRUE' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** a \link #CFE_TIME_SET_TIME_CC Set Spacecraft Time Command \endlink +** and the Time Services configuration parameter #CFE_TIME_CFG_SERVER has +** not been set to TRUE in the cfe_platform_cfg.h file. +**/ +#define CFE_TIME_TIME_CFG_EID 43 + +/** \brief 'Set MET commands invalid without CFE_TIME_CFG_SERVER set to TRUE' +** \event 'Set MET commands invalid without CFE_TIME_CFG_SERVER set to TRUE' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** a \link #CFE_TIME_SET_MET_CC Set Mission Elapsed Time Command \endlink +** and the Time Services configuration parameter #CFE_TIME_CFG_SERVER has +** not been set to TRUE in the cfe_platform_cfg.h file. +**/ +#define CFE_TIME_MET_CFG_EID 44 + +/** \brief 'Set STCF commands invalid without CFE_TIME_CFG_SERVER set to TRUE' +** \event 'Set STCF commands invalid without CFE_TIME_CFG_SERVER set to TRUE' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** a \link #CFE_TIME_SET_STCF_CC Set Spacecraft Time Correlation Factor Command \endlink +** and the Time Services configuration parameter #CFE_TIME_CFG_SERVER has +** not been set to TRUE in the cfe_platform_cfg.h file. +**/ +#define CFE_TIME_STCF_CFG_EID 45 + +/** \brief 'Set Leaps commands invalid without CFE_TIME_CFG_SERVER set to TRUE' +** \event 'Set Leaps commands invalid without CFE_TIME_CFG_SERVER set to TRUE' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** a \link #CFE_TIME_SET_LEAPS_CC Set Leap Seconds Command \endlink +** and the Time Services configuration parameter #CFE_TIME_CFG_SERVER has +** not been set to TRUE in the cfe_platform_cfg.h file. +**/ +#define CFE_TIME_LEAPS_CFG_EID 46 + +/** \brief 'STCF Adjust commands invalid without CFE_TIME_CFG_SERVER set to TRUE' +** \event 'STCF Adjust commands invalid without CFE_TIME_CFG_SERVER set to TRUE' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** either a \link #CFE_TIME_ADD_ADJUST_CC Add Single STCF Adjustment Command \endlink +** OR a \link #CFE_TIME_SUB_ADJUST_CC Subtract Single STCF Adjustment command \endlink +** and the Time Services configuration parameter #CFE_TIME_CFG_SERVER has +** not been set to TRUE in the cfe_platform_cfg.h file. +**/ +#define CFE_TIME_DELTA_CFG_EID 47 + +/** \brief '1Hz Adjust commands invalid without CFE_TIME_CFG_SERVER set to TRUE' +** \event '1Hz Adjust commands invalid without CFE_TIME_CFG_SERVER set to TRUE' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated whenever Time Services receives +** either a \link #CFE_TIME_ADD_1HZADJ_CC Add STCF Adjustment each second Command \endlink +** OR a \link #CFE_TIME_SUB_1HZADJ_CC Subtract STCF Adjustment each second command \endlink +** and the Time Services configuration parameter #CFE_TIME_CFG_SERVER has +** not been set to TRUE in the cfe_platform_cfg.h file. +**/ +#define CFE_TIME_1HZ_CFG_EID 48 + + +#endif /* _cfe_time_events_ */ diff --git a/src/components/interface/cFE/cfe_time_msg.h b/src/components/interface/cFE/cfe_time_msg.h new file mode 100644 index 0000000000..87ac20b2f5 --- /dev/null +++ b/src/components/interface/cFE/cfe_time_msg.h @@ -0,0 +1,1187 @@ +/* +** $Id: cfe_time_msg.h 1.6 2011/11/30 15:10:45GMT-05:00 jmdagost Exp $ +** +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +* +** Purpose: cFE Time Services (TIME) SB message definitions header file +** +** Author: S.Walling/Microtel +** +** Notes: +** +** $Log: cfe_time_msg.h $ +** Revision 1.6 2011/11/30 15:10:45GMT-05:00 jmdagost +** Replaced ifdef/ifndef preprocessor tests with if...==TRUE/if...!=TRUE tests +** Revision 1.5 2010/10/25 15:01:13EDT jmdagost +** Corrected bad apostrophe in prologue. +** Revision 1.4 2010/10/04 15:25:01EDT jmdagost +** Cleaned up copyright symbol. +** Revision 1.3 2009/06/08 16:13:08EDT lwalling +** Change 1Hz adjust cmd arg from micro-seconds to sub-seconds +** Revision 1.2 2008/12/08 12:07:17EST dkobe +** Updates to correct doxygen errors +** Revision 1.1 2008/04/17 08:05:26EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.12 2007/09/12 09:46:04EDT David Kobe (dlkobe) +** Added doxygen comments to commands and some configuration parameters +** Revision 1.11 2007/06/07 13:07:49EDT dlkobe +** Added Command and Telemetry doxygen comments to TIME, EVS and SB +** Revision 1.10 2007/05/23 11:22:01EDT dlkobe +** Added doxygen formatting +** Revision 1.9 2007/04/27 12:31:07EDT njyanchik +** I changed EVS and TIME to not have a telemetry counter for SB pipe reads in the main loop. +** Instead, I have added a syslog message to state the problem +** Revision 1.8 2007/04/11 11:02:10EDT njyanchik +** Remove the TaskDelay in the main loop for TIME. I also addeda counterin telemtry that will +** notify the ground of an error in reading the command pipe. +** Revision 1.7 2007/03/07 12:03:37EST njyanchik +** There were errors in the previous change package, so I fixed them +** +*/ + +/* +** Ensure that header is included only once... +*/ +#ifndef _cfe_time_msg_ +#define _cfe_time_msg_ + +/* +** Required header files... +*/ +#include "cfe.h" + +/*************************************************************************/ + +/* +** Time task command packet command codes... +*/ +/** \name Time Services Command Codes */ +/** \{ */ + +/** \cfetimecmd Time No-Op +** +** \par Description +** This command performs no other function than to increment the +** command execution counter. The command may be used to verify +** general aliveness of the Time Services task. +** +** \cfecmdmnemonic \TIME_NOOP +** +** \par Command Structure +** #CFE_TIME_NoArgsCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TIME_CMDPC - command execution counter will increment +** - The #CFE_TIME_NOOP_EID informational event message will be generated +** +** \par Error Conditions +** There are no error conditions for this command. If the Time +** Services receives the command, the event is sent (although it +** may be filtered by EVS) and the counter is incremented +** unconditionally. +** +** \par Criticality +** None +** +** \sa +*/ +#define CFE_TIME_NOOP_CC 0 /* no-op command */ + +/** \cfetimecmd Time Reset Counters +** +** \par Description +** This command resets the following counters within the Time +** Services \link CFE_TIME_HkPacket_t Housekeeping Telemetry \endlink: +** - Command Execution Counter (\TIME_CMDPC) +** - Command Error Counter (\TIME_CMDEC) +** This command also resets the following counters within the +** Time Services \link CFE_TIME_DiagPacket_t Diagnostic Telemetry \endlink: +** - Tone Signal Detected Software Bus Message Counter (\TIME_TSDETCNT) +** - Time at the Tone Data Software Bus Message Counter (\TIME_TATTCNT) +** - Tone Signal/Data Verify Counter (\TIME_VERIFYCNT) +** - Tone Signal/Data Error Counter (\TIME_VERIFYER) +** - Tone Signal Interrupt Counter (\TIME_TSISRCNT) +** - Tone Signal Interrupt Error Counter (\TIME_TSISRERR) +** - Tone Signal Task Counter (\TIME_TSTASKCNT) +** - Local 1 Hz Interrupt Counter (\TIME_1HZISRCNT) +** - Local 1 Hz Task Counter (\TIME_1HZTASKCNT) +** - Reference Time Version Counter (\TIME_VERSIONCNT) +** +** \cfecmdmnemonic \TIME_RESETCTRS +** +** \par Command Structure +** #CFE_TIME_NoArgsCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TIME_CMDPC - command execution counter will increment +** - The #CFE_TIME_RESET_EID informational event message will be generated +** +** \par Error Conditions +** There are no error conditions for this command. If the Time +** Services receives the command, the event is sent (although it +** may be filtered by EVS) and the counter is incremented +** unconditionally. +** +** \par Criticality +** None +** +** \sa +*/ +#define CFE_TIME_RESET_CC 1 /* reset counters */ + +/** \cfetimecmd Request TIME Diagnostic Telemetry +** +** \par Description +** This command requests that the Time Service generate a message +** containing various data values not included in the normal Time +** Service housekeeping message. The command requests only a single +** copy of the diagnostic message. Refer to #CFE_TIME_DiagPacket_t for +** a description of the Time Service diagnostic message contents. +** +** \cfecmdmnemonic \TIME_REQUESTDIAG +** +** \par Command Structure +** #CFE_TIME_NoArgsCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TIME_CMDPC - command execution counter will increment +** - Sequence Counter for #CFE_TIME_DiagPacket_t will increment +** - The #CFE_TIME_DIAG_EID debug event message will be generated +** +** \par Error Conditions +** There are no error conditions for this command. If the Time +** Services receives the command, the event and telemetry is sent +** (although one or both may be filtered by EVS and TO) and the +** counter is incremented unconditionally. +** +** \par Criticality +** None +** +** \sa +*/ +#define CFE_TIME_DIAG_TLM_CC 2 /* request diagnostic hk telemetry */ + +/** \cfetimecmd Set Time Source +** +** \par Description +** This command selects the Time Service clock source. Although the +** list of potential clock sources is mission specific and defined +** via configuration parameters, this command provides a common method +** for switching between the local processor clock and an external +** source for time data.

+** When commanded to accept external time data (GPS, MET, spacecraft +** time, etc.), the Time Server will enable input via an API function +** specific to the configuration definitions for the particular source. +** When commanded to use internal time data, the Time Server will ignore +** the external data. However, the Time Server will continue to use the +** API function as the trigger to generate a "time at the tone" command +** packet regardless of the internal/external command selection.

+** Notes: +** - Operating in FLYWHEEL mode is not considered a choice related +** to clock source, but rather an element of the clock state. See below +** for a description of the #CFE_TIME_SET_STATE_CC command. +** - This command is only valid when the #CFE_TIME_CFG_SOURCE configuration +** parameter in the cfe_platform_cfg.h file has been set to TRUE. +** +** \cfecmdmnemonic \TIME_SETSOURCE +** +** \par Command Structure +** #CFE_TIME_SourceCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TIME_CMDPC - command execution counter will increment +** - \b \c \TIME_SOURCE - Diagnostic Telemetry point will indicate the +** command specified value +** - The #CFE_TIME_SOURCE_EID informational event message will be generated +** +** \par Error Conditions +** - Invalid Source selection +** (a value other than #CFE_TIME_USE_INTERN or #CFE_TIME_USE_EXTERN was specified) +** - Time source selection not allowed on this platform +**

Evidence of failure may be found in the following telemetry: +** - \b \c \TIME_CMDEC - Command Error counter will increment +** - Error specific event message (either #CFE_TIME_SOURCE_CFG_EID or #CFE_TIME_SOURCE_ERR_EID) +** +** \par Criticality +** Although clock source selection is important, this command is not critical. +** +** \sa #CFE_TIME_SET_STATE_CC, #CFE_TIME_SET_SIGNAL_CC +*/ +#define CFE_TIME_SET_SOURCE_CC 3 /* set clock source (int vs ext) */ + +/** \cfetimecmd Set Time State +** +** \par Description +** This command indirectly affects the Time Service on-board determination +** of clock state. Clock state is a combination of factors, most significantly +** whether the spacecraft time has been accurately set, and whether Time Service +** is operating in FLYWHEEL mode.

+** This command may be used to notify the Time Server that spacecraft time is +** now correct, or that time is no longer correct. This information will be +** distributed to Time Clients, and in turn, to any interested sub-systems.

+** Also, this command may be used to force a Time Server or Time Client into +** FLYWHEEL mode. Use of FLYWHEEL mode is mainly for debug purposes although +** in extreme circumstances, it may be of value to force Time Service not to rely +** on normal time updates. Note that when commanded into FLYWHEEL mode, the Time +** Service will remain so until receipt of another "set state" command setting the +** state into a mode other than FLYWHEEL.

+** Note also that setting the clock state to VALID or INVALID on a Time Client that +** is currently getting time updates from the Time Server will have very limited +** effect. As soon as the Time Client receives the next time update, the VALID/INVALID +** selection will be set to that of the Time Server. However, setting a Time Client +** to FLYWHEEL cannot be overridden by the Time Server since the Time Client will +** ignore time updates from the Time Server while in FLYWHEEL mode. +** +** \cfecmdmnemonic \TIME_SETSTATE +** +** \par Command Structure +** #CFE_TIME_StateCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TIME_CMDPC - command execution counter will increment +** - \b \c \TIME_STATEFLG - Housekeeping Telemetry point "may"l indicate the +** command specified value (see above) +** - The #CFE_TIME_STATE_EID informational event message will be generated +** +** \par Error Conditions +** - Invalid State selection +** (a value other than #CFE_TIME_INVALID, #CFE_TIME_VALID or #CFE_TIME_FLYWHEEL was specified) +** - Time source selection not allowed on this platform +**

Evidence of failure may be found in the following telemetry: +** - \b \c \TIME_CMDEC - Command Error counter will increment +** - Error specific event message (#CFE_TIME_STATE_ERR_EID) +** +** \par Criticality +** Setting Time Service into FLYWHEEL mode is not particularly hazardous, as +** the result may be that the calculation of spacecraft time is done using a +** less than optimal timer. However, inappropriately setting the clock state +** to VALID (indicating that spacecraft time is accurate) may result in other +** sub-systems performing incorrect time based calculations. The specific risk +** is dependent upon the behavior of those sub-systems. +** +** \sa #CFE_TIME_SET_SOURCE_CC, #CFE_TIME_SET_SIGNAL_CC +*/ +#define CFE_TIME_SET_STATE_CC 4 /* set clock state */ + +/** \cfetimecmd Add Time to Tone Time Delay +** +** \par Description +** This command is used to factor out a known, predictable latency between the +** Time Server and a particular Time Client. The correction is applied (added) +** to the current time calculation for Time Clients, so this command has no +** meaning for Time Servers. Each Time Client can have a unique latency setting. +** The latency value is a positive number of seconds and microseconds that represent +** the deviation from the time maintained by the Time Server. +** +** \cfecmdmnemonic \TIME_ADDCLOCKLAT +** +** \par Command Structure +** #CFE_TIME_TimeCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TIME_CMDPC - command execution counter will increment +** - \b \c \TIME_LATENTS - Housekeeping Telemetry point indicating command specified values +** - \b \c \TIME_LATENTDIR - Diagnostic Telemetry point indicating commanded latency direction +** - The #CFE_TIME_DELAY_EID informational event message will be generated +** +** \par Error Conditions +** - An invalid number of microseconds was specified (must be less than 1 million) +** - Platorm receiving the command is not a Time Client +**

Evidence of Failure may be found in the following telemetry: +** - \b \c \TIME_CMDEC - command error counter will increment +** - Error specific event messages will be issued (#CFE_TIME_DELAY_CFG_EID or #CFE_TIME_DELAY_ERR_EID) +** +** \par Criticality +** Inappropriately setting the clock may result in other sub-systems performing incorrect +** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. +** +** \sa #CFE_TIME_SUB_DELAY_CC +*/ +#define CFE_TIME_ADD_DELAY_CC 5 /* add tone delay value */ + +/** \cfetimecmd Subtract Time from Tone Time Delay +** +** \par Description +** This command is used to factor out a known, predictable latency between the Time Server +** and a particular Time Client. The correction is applied (subtracted) to the current time +** calculation for Time Clients, so this command has no meaning for Time Servers. Each Time +** Client can have a unique latency setting. The latency value is a positive number of seconds +** and microseconds that represent the deviation from the time maintained by the Time Server.

+** Note that it is unimaginable that the seconds value will ever be anything but zero. +** +** \cfecmdmnemonic \TIME_SUBCLOCKLAT +** +** \par Command Structure +** #CFE_TIME_TimeCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TIME_CMDPC - command execution counter will increment +** - \b \c \TIME_LATENTS - Housekeeping Telemetry point indicating command specified values +** - \b \c \TIME_LATENTDIR - Diagnostic Telemetry point indicating commanded latency direction +** - The #CFE_TIME_DELAY_EID informational event message will be generated +** +** \par Error Conditions +** - An invalid number of microseconds was specified (must be less than 1 million) +** - Platorm receiving the command is not a Time Client +**

Evidence of Failure may be found in the following telemetry: +** - \b \c \TIME_CMDEC - command error counter will increment +** - Error specific event messages will be issued (#CFE_TIME_DELAY_CFG_EID or #CFE_TIME_DELAY_ERR_EID) +** +** \par Criticality +** Inappropriately setting the clock may result in other sub-systems performing incorrect +** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. +** +** \sa #CFE_TIME_ADD_DELAY_CC +*/ +#define CFE_TIME_SUB_DELAY_CC 6 /* sub tone delay value */ + +/** \cfetimecmd Set Spacecraft Time +** +** \par Description +** This command sets the spacecraft clock to a new value, +** regardless of the current setting (time jam). The new time +** value represents the desired offset from the mission-defined +** time epoch and takes effect immediately upon execution of +** this command. Time Service will calculate a new STCF value +** based on the current MET and the desired new time using one +** of the following:

+** If Time Service is configured to compute current time as TAI
+** - STCF = (new time) - (current MET) +** - (current time) = (current MET) + STCF +**

If Time Service is configured to compute current time as UTC +** - STCF = ((new time) - (current MET)) + (Leap Seconds) +** - (current time) = ((curent MET) + STCF) - (Leap Seconds) +** +** \cfecmdmnemonic \TIME_SETCLOCK +** +** \par Command Structure +** #CFE_TIME_TimeCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TIME_CMDPC - command execution counter will increment +** - \b \c \TIME_STCFSECS - Housekeeping Telemetry point indicating newly calculated STCF seconds value +** - \b \c \TIME_STCFSUBSECS - Housekeeping Telemetry point indicating newly calculated STCF subseconds value +** - The #CFE_TIME_TIME_EID informational event message will be generated +** +** \par Error Conditions +** - An invalid number of microseconds was specified (must be less than 1 million) +** - Platorm receiving the command is not a Time Server +**

Evidence of Failure may be found in the following telemetry: +** - \b \c \TIME_CMDEC - command error counter will increment +** - Error specific event messages will be issued (#CFE_TIME_TIME_CFG_EID or #CFE_TIME_TIME_ERR_EID) +** +** \par Criticality +** Inappropriately setting the clock may result in other sub-systems performing incorrect +** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. +** +** \sa #CFE_TIME_SET_MET_CC, #CFE_TIME_SET_STCF_CC, #CFE_TIME_SET_LEAPS_CC +*/ +#define CFE_TIME_SET_TIME_CC 7 /* set time */ + +/** \cfetimecmd Set Mission Elapsed Time +** +** \par Description +** This command sets the Mission Elapsed Timer (MET) to the specified value.

+** Note that the MET (as implemented for cFE Time Service) is a logical representation +** and not a physical timer. Thus, setting the MET is not dependent on whether the +** hardware supports a MET register that can be written to.

+** Note also that Time Service "assumes" that during normal operation, the MET is +** synchronized to the tone signal. Therefore, unless operating in FLYWHEEL mode, +** the sub-seconds portion of the MET will be set to zero at the next tone signal interrupt.

+** The new MET takes effect immediately upon execution of this command. +** +** \cfecmdmnemonic \TIME_SETCLOCKMET +** +** \par Command Structure +** #CFE_TIME_TimeCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TIME_CMDPC - command execution counter will increment +** - \b \c \TIME_METSECS - Housekeeping Telemetry point indicating new MET seconds value +** - \b \c \TIME_METSUBSECS - Housekeeping Telemetry point indicating new MET subseconds value +** - The #CFE_TIME_MET_EID informational event message will be generated +** +** \par Error Conditions +** - An invalid number of microseconds was specified (must be less than 1 million) +** - Platorm receiving the command is not a Time Server +**

Evidence of Failure may be found in the following telemetry: +** - \b \c \TIME_CMDEC - command error counter will increment +** - Error specific event messages will be issued (#CFE_TIME_MET_CFG_EID or #CFE_TIME_MET_ERR_EID) +** +** \par Criticality +** Inappropriately setting the clock may result in other sub-systems performing incorrect +** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. +** +** \sa #CFE_TIME_SET_TIME_CC, #CFE_TIME_SET_STCF_CC, #CFE_TIME_SET_LEAPS_CC +*/ +#define CFE_TIME_SET_MET_CC 8 /* set MET */ + +/** \cfetimecmd Set Spacecraft Time Correlation Factor +** +** \par Description +** This command sets the Spacecraft Time Correlation Factor (STCF) to the specified value. +** This command differs from the previously described SET CLOCK in the nature of the command +** argument. This command sets the STCF value directly, rather than extracting the STCF +** from a value representing the total of MET, STCF and optionally, Leap Seconds. The new +** STCF takes effect immediately upon execution of this command. +** +** \cfecmdmnemonic \TIME_SETCLOCKSTCF +** +** \par Command Structure +** #CFE_TIME_TimeCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TIME_CMDPC - command execution counter will increment +** - \b \c \TIME_STCFSECS - Housekeeping Telemetry point indicating new STCF seconds value +** - \b \c \TIME_STCFSUBSECS - Housekeeping Telemetry point indicating new STCF subseconds value +** - The #CFE_TIME_STCF_EID informational event message will be generated +** +** \par Error Conditions +** - An invalid number of microseconds was specified (must be less than 1 million) +** - Platorm receiving the command is not a Time Server +**

Evidence of Failure may be found in the following telemetry: +** - \b \c \TIME_CMDEC - command error counter will increment +** - Error specific event messages will be issued (#CFE_TIME_STCF_CFG_EID or #CFE_TIME_STCF_ERR_EID) +** +** \par Criticality +** Inappropriately setting the clock may result in other sub-systems performing incorrect +** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. +** +** \sa #CFE_TIME_SET_TIME_CC, #CFE_TIME_SET_MET_CC, #CFE_TIME_SET_LEAPS_CC +*/ +#define CFE_TIME_SET_STCF_CC 9 /* set STCF */ + +/** \cfetimecmd Set Leap Seconds +** +** \par Description +** This command sets the spacecraft Leap Seconds to the specified value. +** Leap Seconds may be positive or negative, and there is no limit to the +** value except, of course, the limit imposed by the 16 bit signed integer +** data type. The new Leap Seconds value takes effect immediately upon +** execution of this command. +** +** \cfecmdmnemonic \TIME_SETCLOCKLEAP +** +** \par Command Structure +** #CFE_TIME_TimeCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TIME_CMDPC - command execution counter will increment +** - \b \c \TIME_LEAPSECS - Housekeeping Telemetry point indicating new Leap seconds value +** - The #CFE_TIME_LEAPS_EID informational event message will be generated +** +** \par Error Conditions +** - Platorm receiving the command is not a Time Server +**

Evidence of Failure may be found in the following telemetry: +** - \b \c \TIME_CMDEC - command error counter will increment +** - Error specific event messages will be issued (#CFE_TIME_LEAPS_CFG_EID) +** +** \par Criticality +** Inappropriately setting the clock may result in other sub-systems performing incorrect +** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. +** +** \sa #CFE_TIME_SET_TIME_CC, #CFE_TIME_SET_MET_CC, #CFE_TIME_SET_STCF_CC +*/ +#define CFE_TIME_SET_LEAPS_CC 10 /* set Leap Seconds */ + +/** \cfetimecmd Add Delta to Spacecraft Time Correlation Factor +** +** \par Description +** This command adjusts the Spacecraft Time Correlation Factor (STCF) by +** adding the specified value. The new STCF takes effect immediately upon +** execution of this command. +** +** \cfecmdmnemonic \TIME_ADDSTCFADJ +** +** \par Command Structure +** #CFE_TIME_TimeCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TIME_CMDPC - command execution counter will increment +** - \b \c \TIME_STCFSECS - Housekeeping Telemetry point indicating new STCF seconds value +** - \b \c \TIME_STCFSUBSECS - Housekeeping Telemetry point indicating new STCF subseconds value +** - The #CFE_TIME_DELTA_EID informational event message will be generated +** +** \par Error Conditions +** - An invalid number of microseconds was specified (must be less than 1 million) +** - Platorm receiving the command is not a Time Server +**

Evidence of Failure may be found in the following telemetry: +** - \b \c \TIME_CMDEC - command error counter will increment +** - Error specific event messages will be issued (#CFE_TIME_DELTA_ERR_EID or #CFE_TIME_DELTA_CFG_EID) +** +** \par Criticality +** Inappropriately setting the clock may result in other sub-systems performing incorrect +** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. +** +** \sa #CFE_TIME_ADD_ADJUST_CC, #CFE_TIME_SUB_ADJUST_CC, #CFE_TIME_ADD_1HZADJ_CC, #CFE_TIME_SUB_1HZADJ_CC +*/ +#define CFE_TIME_ADD_ADJUST_CC 11 /* add one time STCF adjustment */ + +/** \cfetimecmd Subtract Delta from Spacecraft Time Correlation Factor +** +** \par Description +** This command adjusts the Spacecraft Time Correlation Factor (STCF) by subtracting the specified +** value. The new STCF takes effect immediately upon execution of this command. +** +** \cfecmdmnemonic \TIME_SUBSTCFADJ +** +** \par Command Structure +** #CFE_TIME_TimeCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TIME_CMDPC - command execution counter will increment +** - \b \c \TIME_STCFSECS - Housekeeping Telemetry point indicating new STCF seconds value +** - \b \c \TIME_STCFSUBSECS - Housekeeping Telemetry point indicating new STCF subseconds value +** - The #CFE_TIME_DELTA_EID informational event message will be generated +** +** \par Error Conditions +** - An invalid number of microseconds was specified (must be less than 1 million) +** - Platorm receiving the command is not a Time Server +**

Evidence of Failure may be found in the following telemetry: +** - \b \c \TIME_CMDEC - command error counter will increment +** - Error specific event messages will be issued (#CFE_TIME_DELTA_ERR_EID or #CFE_TIME_DELTA_CFG_EID) +** +** \par Criticality +** Inappropriately setting the clock may result in other sub-systems performing incorrect +** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. +** +** \sa #CFE_TIME_ADD_ADJUST_CC, #CFE_TIME_ADD_1HZADJ_CC, #CFE_TIME_SUB_1HZADJ_CC +*/ +#define CFE_TIME_SUB_ADJUST_CC 12 /* subtract one time STCF adjustment */ + +/** \cfetimecmd Add Delta to Spacecraft Time Correlation Factor each 1Hz +** +** \par Description +** This command has been updated to take actual sub-seconds (1/2^32 seconds) +** rather than micro-seconds as an input argument. This change occurred +** after the determination was made that one micro-second is too large an +** increment for a constant 1Hz adjustment.

+** This command continuously adjusts the Spacecraft Time Correlation Factor (STCF) +** every second, by adding the specified value. The adjustment to the STCF is +** applied in the Time Service local 1Hz interrupt handler. As the local 1Hz +** interrupt is not synchronized to the tone signal, one cannot say when the +** adjustment will occur, other than once a second, at about the same time +** relative to the tone.

+** There was some debate about whether the maximum 1Hz clock drift correction +** factor would ever need to exceed some small fraction of a second. But, the +** decision was made to provide the capability to make 1Hz adjustments greater +** than one second and leave it to the ground system to provide mission specific +** limits. +** +** \cfecmdmnemonic \TIME_ADD1HZSTCF +** +** \par Command Structure +** #CFE_TIME_1HzAdjCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TIME_CMDPC - command execution counter will increment +** - \b \c \TIME_STCFSECS - Housekeeping Telemetry point indicating new STCF seconds value +** - \b \c \TIME_STCFSUBSECS - Housekeeping Telemetry point indicating new STCF subseconds value +** - The #CFE_TIME_1HZ_EID informational event message will be generated +** +** \par Error Conditions +** - Platorm receiving the command is not a Time Server +**

Evidence of Failure may be found in the following telemetry: +** - \b \c \TIME_CMDEC - command error counter will increment +** - Error specific event message will be issued (#CFE_TIME_1HZ_CFG_EID) +** +** \par Criticality +** Inappropriately setting the clock may result in other sub-systems performing incorrect +** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. +** +** \sa #CFE_TIME_ADD_ADJUST_CC, #CFE_TIME_SUB_ADJUST_CC, #CFE_TIME_SUB_1HZADJ_CC +*/ +#define CFE_TIME_ADD_1HZADJ_CC 13 /* add 1Hz STCF adjustment */ + +/** \cfetimecmd Subtract Delta from Spacecraft Time Correlation Factor each 1Hz +** +** \par Description +** This command has been updated to take actual sub-seconds (1/2^32 seconds) +** rather than micro-seconds as an input argument. This change occurred +** after the determination was made that one micro-second is too large an +** increment for a constant 1Hz adjustment.

+** This command continuously adjusts the Spacecraft Time Correlation Factor (STCF) +** every second, by subtracting the specified value. The adjustment to the STCF +** is applied in the Time Service local 1Hz interrupt handler. As the local 1Hz +** interrupt is not synchronized to the tone signal, one cannot say when the +** adjustment will occur, other than once a second, at about the same time +** relative to the tone.

+** There was some debate about whether the maximum 1Hz clock drift correction +** factor would ever need to exceed some small fraction of a second. But, the +** decision was made to provide the capability to make 1Hz adjustments greater +** than one second and leave it to the ground system to provide mission specific +** limits. +** +** \cfecmdmnemonic \TIME_SUB1HZSTCF +** +** \par Command Structure +** #CFE_TIME_1HzAdjCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TIME_CMDPC - command execution counter will increment +** - \b \c \TIME_STCFSECS - Housekeeping Telemetry point indicating new STCF seconds value +** - \b \c \TIME_STCFSUBSECS - Housekeeping Telemetry point indicating new STCF subseconds value +** - The #CFE_TIME_1HZ_EID informational event message will be generated +** +** \par Error Conditions +** - Platorm receiving the command is not a Time Server +**

Evidence of Failure may be found in the following telemetry: +** - \b \c \TIME_CMDEC - command error counter will increment +** - Error specific event message will be issued (#CFE_TIME_1HZ_CFG_EID) +** +** \par Criticality +** Inappropriately setting the clock may result in other sub-systems performing incorrect +** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. +** +** \sa #CFE_TIME_ADD_ADJUST_CC, #CFE_TIME_SUB_ADJUST_CC, #CFE_TIME_ADD_1HZADJ_CC +*/ +#define CFE_TIME_SUB_1HZADJ_CC 14 /* subtract 1Hz STCF adjustment */ + + +/** \cfetimecmd Set Tone Signal Source +** +** \par Description +** This command selects the Time Service tone signal source. Although the +** list of potential tone signal sources is mission specific, a common +** choice is the selection of primary or redundant tone signal. The selection +** may be available to both the Time Server and Time Clients, depending on +** hardware configuration.

+** Notes: +** - This command is only valid when the #CFE_TIME_CFG_SIGNAL configuration +** parameter in the cfe_platform_cfg.h file has been set to TRUE. +** +** \cfecmdmnemonic \TIME_SETSIGNAL +** +** \par Command Structure +** #CFE_TIME_SignalCmd_t +** +** \par Command Verification +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \TIME_CMDPC - command execution counter will +** increment +** - \b \c \TIME_SIGNAL - Diagnostic Telemetry point will indicate the +** command specified value +** - The #CFE_TIME_SIGNAL_EID informational event message will +** be generated +** +** \par Error Conditions +** - Invalid Signal selection +** (a value other than #CFE_TIME_TONE_PRI or #CFE_TIME_TONE_RED was specified) +** - Multiple Tone Signal Sources not available on this platform +**

Evidence of failure may be found in the following telemetry: +** - \b \c \TIME_CMDEC - Command Error counter will increment +** - Error specific event message (either #CFE_TIME_SIGNAL_CFG_EID or #CFE_TIME_SIGNAL_ERR_EID) +** +** \par Criticality +** Although tone signal source selection is important, this command is not critical +** +** \sa #CFE_TIME_SET_STATE_CC, #CFE_TIME_SET_SOURCE_CC +*/ +#define CFE_TIME_SET_SIGNAL_CC 15 /* set clock signal (pri vs red) */ +/** \} */ + +/* +** Clock source command arguments... +*/ +/** \name Clock Source Selection Parameters */ +/** \{ */ +#define CFE_TIME_USE_INTERN 1 +#define CFE_TIME_USE_EXTERN 2 +/** \} */ + +/* +** Clock signal command arguments... +*/ +/** \name Clock Signal Selection Parameters */ +/** \{ */ +#define CFE_TIME_TONE_PRI 1 +#define CFE_TIME_TONE_RED 2 +/** \} */ + +/* +** STCF adjustment direction (for both "one time" and "1Hz" adjustments)... +*/ +/** \name Spacecraft Time Correlation Factor Adjustment Parameters */ +/** \{ */ +#define CFE_TIME_ADD_ADJUST 1 /* add STCF adjustment value */ +#define CFE_TIME_SUB_ADJUST 2 /* subtract STCF adjustment value */ +/** \} */ + +/* +** Fly-wheel status values (are we currently fly-wheeling)... +*/ +/** \name Fly-wheel status values */ +/** \{ */ +#define CFE_TIME_NO_FLY 0 +#define CFE_TIME_IS_FLY 1 +/** \} */ + +/* +** Clock "set" status values (has the clock been set to correct time)... +*/ +/** \name Clock "set" status values */ +/** \{ */ +#define CFE_TIME_NOT_SET 0 +#define CFE_TIME_WAS_SET 1 +/** \} */ + +/* +** Clock "state flag" definitions (state data converted to flags)... +*/ +/** \name Clock "state flag" values */ +/** \{ */ +#define CFE_TIME_FLAG_CLKSET 0x8000 /**< \brief The spacecraft time has been set */ +#define CFE_TIME_FLAG_FLYING 0x4000 /**< \brief This instance of Time Services is flywheeling */ +#define CFE_TIME_FLAG_SRCINT 0x2000 /**< \brief The clock source is set to "internal" */ +#define CFE_TIME_FLAG_SIGPRI 0x1000 /**< \brief The clock signal is set to "primary" */ +#define CFE_TIME_FLAG_SRVFLY 0x0800 /**< \brief The Time Server is in flywheel mode */ +#define CFE_TIME_FLAG_CMDFLY 0x0400 /**< \brief This instance of Time Services was commanded into flywheel mode */ +#define CFE_TIME_FLAG_ADDADJ 0x0200 /**< \brief One time STCF Adjustment is to be done in positive direction */ +#define CFE_TIME_FLAG_ADD1HZ 0x0100 /**< \brief 1 Hz STCF Adjustment is to be done in a positive direction */ +#define CFE_TIME_FLAG_ADDTCL 0x0080 /**< \brief Time Client Latency is applied in a positive direction */ +#define CFE_TIME_FLAG_SERVER 0x0040 /**< \brief This instance of Time Services is a Time Server */ +#define CFE_TIME_FLAG_GDTONE 0x0020 /**< \brief The tone received is good compared to the last tone received */ +#define CFE_TIME_FLAG_UNUSED 0x001F /**< \brief Reserved flags - should be zero */ +/** \} */ + + +/*************************************************************************/ + +/* +** Type definition (generic "no arguments" command)... +*/ +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + +} CFE_TIME_NoArgsCmd_t; + + +/* +** Type definition (leap seconds command)... +*/ +typedef struct +{ + int16 LeapSeconds; +} CFE_TIME_LeapsCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + CFE_TIME_LeapsCmd_Payload_t Payload; +} CFE_TIME_LeapsCmd_t; + + +/* +** Type definition (clock state command)... +*/ +typedef struct +{ + int16 ClockState; /**< \brief #CFE_TIME_INVALID=Spacecraft time has not been accurately set, + #CFE_TIME_VALID=Spacecraft clock has been accurately set, + #CFE_TIME_FLYWHEEL=Force into FLYWHEEL mode */ + /**< Selects the current clock state */ +} CFE_TIME_StateCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + CFE_TIME_StateCmd_Payload_t Payload; +} CFE_TIME_StateCmd_t; + + +/* +** Type definition (time data source command)... +*/ +typedef struct +{ + int16 TimeSource; /**< \brief #CFE_TIME_USE_INTERN=Internal Source, + #CFE_TIME_USE_EXTERN=External Source */ + /**< Selects either the "Internal" and "External" clock source */ +} CFE_TIME_SourceCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + CFE_TIME_SourceCmd_Payload_t Payload; +} CFE_TIME_SourceCmd_t; + + +/* +** Type definition (tone signal source command)... +*/ +typedef struct +{ + int16 ToneSource; /**< \brief #CFE_TIME_TONE_PRI=Primary Source, + #CFE_TIME_TONE_RED=Redundant Source */ + /**< Selects either the "Primary" or "Redundant" tone signal source */ +} CFE_TIME_SignalCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + CFE_TIME_SignalCmd_Payload_t Payload; + +} CFE_TIME_SignalCmd_t; + + +/* +** Type definition (generic "time argument" command)... +*/ +typedef struct +{ + uint32 Seconds; + uint32 MicroSeconds; +} CFE_TIME_TimeCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + CFE_TIME_TimeCmd_Payload_t Payload; +} CFE_TIME_TimeCmd_t; + + +/* +** Type definition (1Hz STCF adjustment "time argument" command)... +*/ +typedef struct +{ + uint32 Seconds; + uint32 Subseconds; + +} CFE_TIME_1HzAdjCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + CFE_TIME_1HzAdjCmd_Payload_t Payload; + +} CFE_TIME_1HzAdjCmd_t; + + +/* +** Type definition (local 1Hz wake-up command)... +*/ +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + +} CFE_TIME_1HzCmd_t; + + +/* +** Type definition (time at the tone signal command)... +*/ +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + +} CFE_TIME_ToneSignalCmd_t; + + +/* +** Type definition ("fake" time at the tone signal command)... +*/ +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + +} CFE_TIME_FakeToneCmd_t; + + +/* +** Type definition (time at the tone data command)... +*/ +typedef struct +{ + CFE_TIME_SysTime_t AtToneMET; /**< \brief MET at time of tone */ + CFE_TIME_SysTime_t AtToneSTCF; /**< \brief STCF at time of tone */ + int16 AtToneLeaps; /**< \brief Leap Seconds at time of tone */ + int16 AtToneState; /**< \brief Clock state at time of tone */ +} CFE_TIME_ToneDataCmd_Payload_t; + +typedef struct +{ + uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; + CFE_TIME_ToneDataCmd_Payload_t Payload; +} CFE_TIME_ToneDataCmd_t; + + +/*************************************************************************/ + +/** +** \cfetimetlm Time Services Housekeeping Packet +**/ +typedef struct +{ + /* + ** Task command interface counters... + */ + uint8 CmdCounter; /**< \cfetlmmnemonic \TIME_CMDPC + \brief Time Command Execution Counter */ + uint8 ErrCounter; /**< \cfetlmmnemonic \TIME_CMDEC + \brief Time Command Error Counter */ + + /* + ** Clock state flags and "as calculated" clock state... + */ + uint16 ClockStateFlags; /**< \cfetlmmnemonic \TIME_STATEFLG + \brief State Flags */ + int16 ClockStateAPI; /**< \cfetlmmnemonic \TIME_APISTATE + \brief API State */ + + /* + ** Leap Seconds... + */ + int16 LeapSeconds; /**< \cfetlmmnemonic \TIME_LEAPSECS + \brief Current Leaps Seconds */ + + /* + ** Current MET and STCF time values... + */ + uint32 SecondsMET; /**< \cfetlmmnemonic \TIME_METSECS + \brief Current MET (seconds) */ + uint32 SubsecsMET; /**< \cfetlmmnemonic \TIME_METSUBSECS + \brief Current MET (sub-seconds) */ + + uint32 SecondsSTCF; /**< \cfetlmmnemonic \TIME_STCFSECS + \brief Current STCF (seconds) */ + uint32 SubsecsSTCF; /**< \cfetlmmnemonic \TIME_STCFSUBSECS + \brief Current STCF (sub-seconds) */ + + /* + ** 1Hz STCF adjustment values (server only)... + */ + #if (CFE_TIME_CFG_SERVER == TRUE) + uint32 Seconds1HzAdj; /**< \cfetlmmnemonic \TIME_1HZADJSECS + \brief Current 1 Hz SCTF adjustment (seconds) */ + uint32 Subsecs1HzAdj; /**< \cfetlmmnemonic \TIME_1HZADJSSECS + \brief Current 1 Hz SCTF adjustment (sub-seconds) */ + #endif + + /* + ** Time at tone delay values (client only)... + */ + #if (CFE_TIME_CFG_CLIENT == TRUE) + uint32 SecondsDelay; /**< \cfetlmmnemonic \TIME_1HZDLYSECS + \brief Current 1 Hz SCTF Delay (seconds) */ + uint32 SubsecsDelay; /**< \cfetlmmnemonic \TIME_1HZDLYSSECS + \brief Current 1 Hz SCTF Delay (sub-seconds) */ + #endif + +} CFE_TIME_HkPacket_Payload_t; + +typedef struct +{ + uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; + CFE_TIME_HkPacket_Payload_t Payload; +} CFE_TIME_HkPacket_t; + + +/*************************************************************************/ + +/** +** \cfetimetlm Time Services Diagnostics Packet +**/ +typedef struct +{ + /* + ** Data values used to compute time (in reference to "tone")... + */ + CFE_TIME_SysTime_t AtToneMET; /**< \cfetlmmnemonic \TIME_TMETS + \brief MET at time of tone */ + CFE_TIME_SysTime_t AtToneSTCF; /**< \cfetlmmnemonic \TIME_STCFS + \brief STCF at time of tone */ + CFE_TIME_SysTime_t AtToneDelay; /**< \cfetlmmnemonic \TIME_LATENTS + \brief Adjustment for slow tone detection */ + CFE_TIME_SysTime_t AtToneLatch; /**< \cfetlmmnemonic \TIME_TVALIDS + \brief Local clock latched at time of tone */ + + int16 AtToneLeaps; /**< \cfetlmmnemonic \TIME_LEAPS + \brief Leap Seconds at time of tone */ + int16 ClockStateAPI; /**< \cfetlmmnemonic \TIME_APISTATE + \brief Clock state as per API */ + + /* + ** Data values that reflect the time (right now)... + */ + CFE_TIME_SysTime_t TimeSinceTone; /**< \cfetlmmnemonic \TIME_ELAPSEDS + \brief Time elapsed since the tone */ + CFE_TIME_SysTime_t CurrentLatch; /**< \cfetlmmnemonic \TIME_LOCALS + \brief Local clock latched just "now" */ + CFE_TIME_SysTime_t CurrentMET; /**< \cfetlmmnemonic \TIME_METS + \brief MET at this instant */ + CFE_TIME_SysTime_t CurrentTAI; /**< \cfetlmmnemonic \TIME_TAIS + \brief TAI at this instant */ + CFE_TIME_SysTime_t CurrentUTC; /**< \cfetlmmnemonic \TIME_UTCS + \brief UTC at this instant */ + + /* + ** Data values used to define the current clock state... + */ + int16 ClockSetState; /**< \cfetlmmnemonic \TIME_VALID + \brief Time has been "set" */ + int16 ClockFlyState; /**< \cfetlmmnemonic \TIME_FLYWHEEL + \brief Current fly-wheel state */ + int16 ClockSource; /**< \cfetlmmnemonic \TIME_SOURCE + \brief Internal vs external, etc. */ + int16 ClockSignal; /**< \cfetlmmnemonic \TIME_SIGNAL + \brief Primary vs redundant, etc. */ + int16 ServerFlyState; /**< \cfetlmmnemonic \TIME_SRVFLY + \brief Used by clients only */ + int16 Forced2Fly; /**< \cfetlmmnemonic \TIME_CMD2FLY + \brief Commanded into fly-wheel */ + + /* + ** Clock state flags... + */ + uint16 ClockStateFlags;/**< \cfetlmmnemonic \TIME_STATEFLAGS + \brief Clock State Flags */ + + /* + ** STCF adjustment direction values... + */ + int16 OneTimeDirection; /**< \cfetlmmnemonic \TIME_ADJUSTDIR + \brief One time STCF adjustment direction (Add = 1, Sub = 2) */ + int16 OneHzDirection; /**< \cfetlmmnemonic \TIME_1HZADJDIR + \brief 1Hz STCF adjustment direction */ + int16 DelayDirection; /**< \cfetlmmnemonic \TIME_LATENTDIR + \brief Client latency adjustment direction */ + + /* + ** STCF adjustment values... + */ + CFE_TIME_SysTime_t OneTimeAdjust; /**< \cfetlmmnemonic \TIME_ADJUSTS + \brief Previous one-time STCF adjustment */ + CFE_TIME_SysTime_t OneHzAdjust; /**< \cfetlmmnemonic \TIME_1HZADJS + \brief Current 1Hz STCF adjustment */ + + /* + ** Most recent local clock latch values... + */ + CFE_TIME_SysTime_t ToneSignalLatch; /**< \cfetlmmnemonic \TIME_TTS + \brief Local Clock latched at most recent tone signal */ + CFE_TIME_SysTime_t ToneDataLatch; /**< \cfetlmmnemonic \TIME_TDS + \brief Local Clock latched at arrival of tone data */ + + /* + ** Miscellaneous counters (subject to reset command)... + */ + uint32 ToneMatchCount; /**< \cfetlmmnemonic \TIME_VERIFYCNT + \brief Tone signal / data verification count */ + uint32 ToneMatchErrors; /**< \cfetlmmnemonic \TIME_VERIFYER + \brief Tone signal / data verification error count */ + uint32 ToneSignalCount; /**< \cfetlmmnemonic \TIME_TSDETCNT + \brief Tone signal detected SB message count */ + uint32 ToneDataCount; /**< \cfetlmmnemonic \TIME_TATTCNT + \brief Time at the tone data SB message count */ + uint32 ToneIntCount; /**< \cfetlmmnemonic \TIME_TSISRCNT + \brief Tone signal ISR execution count */ + uint32 ToneIntErrors; /**< \cfetlmmnemonic \TIME_TSISRERR + \brief Tone signal ISR error count */ + uint32 ToneTaskCount; /**< \cfetlmmnemonic \TIME_TSTASKCNT + \brief Tone task execution count */ + uint32 VersionCount; /**< \cfetlmmnemonic \TIME_VERSIONCNT + \brief Count of mods to time at tone reference data (version) */ + uint32 LocalIntCount; /**< \cfetlmmnemonic \TIME_1HZISRCNT + \brief Local 1Hz ISR execution count */ + uint32 LocalTaskCount; /**< \cfetlmmnemonic \TIME_1HZTASKCNT + \brief Local 1Hz task execution count */ + + /* + ** Miscellaneous counters (not subject to reset command)... + */ + uint32 VirtualMET; /**< \cfetlmmnemonic \TIME_LOGICALMET + \brief Software MET */ + + /* + ** Time window verification values (converted from micro-secs)... + ** + ** Regardless of whether the tone follows the time packet, or vice + ** versa, these values define the acceptable window of time for + ** the second event to follow the first. The minimum value may + ** be as little as zero, and the maximum must be something less + ** than a second. + */ + uint32 MinElapsed; /**< \cfetlmmnemonic \TIME_MINWINDOW + \brief Min tone signal / data pkt arrival window (Sub-seconds) */ + uint32 MaxElapsed; /**< \cfetlmmnemonic \TIME_MAXWINDOW + \brief Max tone signal / data pkt arrival window (Sub-seconds) */ + + /* + ** Maximum local clock value (before roll-over)... + */ + CFE_TIME_SysTime_t MaxLocalClock; /**< \cfetlmmnemonic \TIME_WRAPS + \brief Max local clock value before rollover */ + + /* + ** Tone signal tolerance limits... + */ + uint32 ToneOverLimit; /**< \cfetlmmnemonic \TIME_MAXSS + \brief Max between tone signal interrupts */ + uint32 ToneUnderLimit; /**< \cfetlmmnemonic \TIME_MINSS + \brief Min between tone signal interrupts */ + + /* + ** Reset Area... + */ + uint32 DataStoreStatus; /**< \cfetlmmnemonic \TIME_ATASTSTAT + \brief Data Store status (preserved across processor reset) */ +} CFE_TIME_DiagPacket_Payload_t; + +typedef struct +{ + uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; + CFE_TIME_DiagPacket_Payload_t Payload; +} CFE_TIME_DiagPacket_t; + + +/*************************************************************************/ + +#endif /* _cfe_time_msg_ */ + +/************************/ +/* End of File Comment */ +/************************/ diff --git a/src/components/interface/cFE/cfe_version.h b/src/components/interface/cFE/cfe_version.h new file mode 100644 index 0000000000..7b5be26d5c --- /dev/null +++ b/src/components/interface/cFE/cfe_version.h @@ -0,0 +1,83 @@ +/* +** File: +** cfe_es_version.h +** $Id: cfe_version.h 1.8.2.5 2014/12/02 19:26:21GMT-05:00 sstrege Exp $ +** +** +** Copyright (c) 2004-2012, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software(cFE) was created at NASA's Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Purpose: +** Provide version identifiers for the cFE core. +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** cFE Flight Software Application Developers Guide +** +** Notes: +** +** +** Modification History: +** $Log: cfe_version.h $ +** Revision 1.8.2.5 2014/12/02 19:26:21GMT-05:00 sstrege +** Changing version number for the branch to 6.4.1 +** Revision 1.8.2.4 2014/09/30 17:39:28EDT sstrege +** Changing the version number for the branch tip to 9.9.9 +** Revision 1.8.2.3 2014/09/30 15:56:42EDT sstrege +** Changing version number for 6.4.0 release +** Revision 1.8.2.2 2014/09/10 22:36:45EDT sstrege +** Changing the version number for the branch tip to 9.9.9 +** Revision 1.8.2.1 2014/09/10 22:27:48EDT sstrege +** Changing the version number for the branch to 6.4.0 +** Revision 1.8 2012/01/13 11:50:06EST acudmore +** Member renamed from cfe_es_version.h to cfe_version.h in project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj. +** Revision 1.7 2012/01/13 11:50:06ACT acudmore +** Member moved from cfe_es_version.h in project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/es/project.pj to cfe_es_version.h in project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj. +** Revision 1.6 2012/01/13 11:50:06ACT acudmore +** Changed license text to reflect open source +** Revision 1.5 2010/11/23 15:27:32EST jmdagost +** Changed SubMinor Version definition to Revision to match other cFE/CFS components. +** Revision 1.4 2010/10/25 15:02:13EDT jmdagost +** Corrected bad apostrophe in prologue. +** Revision 1.3 2010/10/04 15:37:32EDT jmdagost +** Cleaned up copyright symbol. +** Revision 1.2 2008/07/21 16:00:07EDT rjmcgraw +** DCR4195:1 Changed version number from 9.9.9 to 0.0.0 +** Revision 1.1 2008/04/17 08:05:10EDT ruperera +** Initial revision +** Member added to cFE project +*/ + +#ifndef _cfe_es_version_ +#define _cfe_es_version_ + +/* + * The "enhanced build" (cmake-driven) instantiates a configuration + * object that contains extended version information within it. + * + * This information is generated automatically by the build using + * git to determine the most recent tag and commitid. + * + * This is only available when compiling with the cmake scripts which + * is why it is conditionally included. + */ +#ifdef _ENHANCED_BUILD_ +#include +#endif + + +/* +** Macro Definitions +*/ +#define CFE_MAJOR_VERSION 6 +#define CFE_MINOR_VERSION 5 +#define CFE_REVISION 0 + + +#endif /* _cfe_es_version_ */ + diff --git a/src/components/interface/cFE/common_types.h b/src/components/interface/cFE/common_types.h new file mode 100644 index 0000000000..e915f00e99 --- /dev/null +++ b/src/components/interface/cFE/common_types.h @@ -0,0 +1,374 @@ +/*--------------------------------------------------------------------------- +** +** Filename: +** $Id: common_types.h 1.9 2014/01/14 16:28:32GMT-05:00 acudmore Exp $ +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software was created at NASAs Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Purpose: +** Unit specification for common types. +** +** Design Notes: +** Assumes make file has defined processor family +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** +** +** Notes: +** +** +** $Date: 2014/01/14 16:28:32GMT-05:00 $ +** $Revision: 1.9 $ +** $Log: common_types.h $ +** Revision 1.9 2014/01/14 16:28:32GMT-05:00 acudmore +** Fixed typo in macro for x86-64 +** Revision 1.8 2013/08/09 13:58:04GMT-05:00 acudmore +** Added int64 type, added support for ARM arch, added 64 bit x86 arch, added arch check for GCC arch macros, added check for proper data type sizes +** Revision 1.7 2013/07/25 10:01:29GMT-05:00 acudmore +** Added C++ support +** Revision 1.6 2012/04/11 09:19:03GMT-05:00 acudmore +** added OS_USED attribute +** Revision 1.5 2010/02/18 16:43:29EST acudmore +** Added SPARC processor section +** Removed special characters from comments that cause problems with some tools. +** Revision 1.4 2010/02/18 16:41:39EST acudmore +** Added a block of defines for GCC specific pragmas and extensions. +** Removed RTEMS boolean related ifdefs +** moved OS_PACK into the GCC specific block +** Revision 1.3 2010/02/01 12:31:17EST acudmore +** Added uint64 type +** Revision 1.2 2009/07/07 16:30:05EDT acudmore +** Removed conditinal comp. around boolean for m68k. +** This will need to be done for all RTEMS targets +** Revision 1.1 2009/06/02 10:04:58EDT acudmore +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/os/inc/project.pj +** Revision 1.1 2008/04/20 22:35:58EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/inc/project.pj +** Revision 1.1 2007/10/16 16:14:49EDT apcudmore +** Initial revision +** Member added to project d:/mksdata/MKS-OSAL-REPOSITORY/src/inc/project.pj +** Revision 1.2 2006/06/08 14:28:32EDT David Kobe (dlkobe) +** Added NASA Open Source Legal Statement +** Revision 1.1 2005/06/09 09:57:51GMT-05:00 rperera +** Initial revision +** Member added to project d:/mksdata/MKS-CFE-REPOSITORY/cfe-core/inc/project.pj +** Revision 1.6 2005/03/24 19:20:52 rmcgraw +** Wrapped the boolean defintion for all three processors with #ifndef _USING_RTEMS_INCLUDES_ +** +** Revision 1.5 2005/03/10 16:59:08 acudmore +** removed boolean prefix to TRUE and FALSE defintion to avoid vxWorks conflict. +** +** Revision 1.4 2005/03/07 20:23:34 acudmore +** removed duplicate boolean definition +** +** Revision 1.3 2005/03/07 20:05:17 acudmore +** updated with __PPC__ macro that gnu compiler uses +** +** Revision 1.2 2005/03/04 16:02:44 acudmore +** added coldfire architecture +** +** Revision 1.1 2005/03/04 15:58:45 acudmore +** Added common_types.h +** +** +** +**-------------------------------------------------------------------------*/ + +#ifndef _common_types_ +#define _common_types_ + +#ifdef __cplusplus + extern "C" { +#endif + +/* +** Includes +*/ + +/* +** Macro Definitions +*/ + +/* +** Condition = TRUE is ok, Condition = FALSE is error +*/ +#define CompileTimeAssert(Condition, Message) typedef char Message[(Condition) ? 1 : -1] + + +/* +** Define compiler specific macros +** The __extension__ compiler pragma is required +** for the uint64 type using GCC with the ANSI C90 standard. +** Other macros can go in here as needed, for example alignment +** pragmas. +** +** NOTE: The white-box (coverage) unit testing may need to disable +** these extra attributes. These test builds define the OSAPI_NO_SPECIAL_ATTRIBS +** macro to disable this. +*/ +#if defined (__GNUC__) && !defined(OSAPI_NO_SPECIAL_ATTRIBS) + #define _EXTENSION_ __extension__ + #define OS_PACK __attribute__ ((packed)) + #define OS_ALIGN(n) __attribute__((aligned(n))) + #define OS_USED __attribute__((used)) + #define OS_PRINTF(n,m) __attribute__ ((format (printf, n, m))) +#else + #define _EXTENSION_ + #define OS_PACK + #define OS_ALIGN(n) + #define OS_USED + #define OS_PRINTF(n,m) +#endif + +/* + * If the host system has a ISO C99 standard stdint header file, prefer it. + * This ensures that fixed-width types are correct including on 64-bit systems. + */ +#if defined(_HAVE_STDINT_) + +#include +#include +/* + * NOTE - NOT DEFINING STRUCT_LOW_BIT_FIRST or STRUCT_HIGH_BIT_FIRST + * We should not make assumptions about the bit order here + */ + + typedef uint8_t osalbool; + typedef int8_t int8; + typedef int16_t int16; + typedef int32_t int32; + typedef int64_t int64; + typedef uint8_t uint8; + typedef uint16_t uint16; + typedef uint32_t uint32; + typedef uint64_t uint64; + typedef intptr_t intptr; + typedef uintptr_t cpuaddr; + typedef size_t cpusize; + typedef ptrdiff_t cpudiff; + +/* + * Fall back to default integer type maps - + * These definitions assume a 32-bit processor + */ +#elif defined(_ix86_) || defined (__i386__) +/* ----------------------- Intel x86 processor family -------------------------*/ + /* Little endian */ + #undef _STRUCT_HIGH_BIT_FIRST_ + #define _STRUCT_LOW_BIT_FIRST_ + + typedef unsigned char osalbool; + typedef signed char int8; + typedef short int int16; + typedef long int int32; + _EXTENSION_ typedef long long int int64; + typedef unsigned char uint8; + typedef unsigned short int uint16; + typedef unsigned long int uint32; + _EXTENSION_ typedef unsigned long long int uint64; + + typedef unsigned long int cpuaddr; + typedef unsigned long int cpusize; + typedef long int cpudiff; + +#elif defined (_ix64_) || defined (__x86_64__) +/* ----------------------- Intel/AMD x64 processor family -------------------------*/ + /* Little endian */ + #undef _STRUCT_HIGH_BIT_FIRST_ + #define _STRUCT_LOW_BIT_FIRST_ + + typedef unsigned char osalbool; + typedef signed char int8; + typedef short int int16; + typedef int int32; + typedef long int int64; + typedef unsigned char uint8; + typedef unsigned short int uint16; + typedef unsigned int uint32; + typedef unsigned long int uint64; + + typedef unsigned long int cpuaddr; + typedef unsigned long int cpusize; + typedef long int cpudiff; + +#elif defined(__PPC__) || defined (__ppc__) + /* ----------------------- Motorola Power PC family ---------------------------*/ + /* The PPC can be programmed to be big or little endian, we assume native */ + /* Big endian */ + #define _STRUCT_HIGH_BIT_FIRST_ + #undef _STRUCT_LOW_BIT_FIRST_ + + typedef unsigned char osalbool; + typedef signed char int8; + typedef short int int16; + typedef long int int32; + _EXTENSION_ typedef long long int int64; + typedef unsigned char uint8; + typedef unsigned short int uint16; + typedef unsigned long int uint32; + _EXTENSION_ typedef unsigned long long int uint64; + + typedef unsigned long int cpuaddr; + typedef unsigned long int cpusize; + typedef long int cpudiff; + +#elif defined(_m68k_) || defined(__m68k__) + /* ----------------------- Motorola m68k/Coldfire family ---------------------------*/ + /* Big endian */ + #define _STRUCT_HIGH_BIT_FIRST_ + #undef _STRUCT_LOW_BIT_FIRST_ + + typedef unsigned char osalbool; + typedef signed char int8; + typedef short int int16; + typedef long int int32; + _EXTENSION_ typedef long long int int64; + typedef unsigned char uint8; + typedef unsigned short int uint16; + typedef unsigned long int uint32; + _EXTENSION_ typedef unsigned long long int uint64; + + typedef unsigned long int cpuaddr; + typedef unsigned long int cpusize; + typedef long int cpudiff; + +#elif defined (__ARM__) || defined(__arm__) +/* ----------------------- ARM processor family -------------------------*/ + /* Little endian */ + #undef _STRUCT_HIGH_BIT_FIRST_ + #define _STRUCT_LOW_BIT_FIRST_ + + typedef unsigned char osalbool; + typedef signed char int8; + typedef short int int16; + typedef long int int32; + _EXTENSION_ typedef long long int int64; + typedef unsigned char uint8; + typedef unsigned short int uint16; + typedef unsigned long int uint32; + _EXTENSION_ typedef unsigned long long int uint64; + + typedef unsigned long int cpuaddr; + typedef unsigned long int cpusize; + typedef long int cpudiff; + +#elif defined(__SPARC__) || defined (_sparc_) + /* ----------------------- SPARC/LEON family ---------------------------*/ + /* SPARC Big endian */ + #define _STRUCT_HIGH_BIT_FIRST_ + #undef _STRUCT_LOW_BIT_FIRST_ + + typedef unsigned char osalbool; + typedef signed char int8; + typedef short int int16; + typedef long int int32; + _EXTENSION_ typedef long long int int64; + typedef unsigned char uint8; + typedef unsigned short int uint16; + typedef unsigned long int uint32; + _EXTENSION_ typedef unsigned long long int uint64; + + typedef unsigned long int cpuaddr; + typedef unsigned long int cpusize; + typedef long int cpudiff; + +#else /* not any of the above */ + #error undefined processor +#endif /* processor types */ + +/* + * Boolean type for compatibility -- + * + * Note it is a bad idea to typedef "bool" or "boolean" -- MANY other projects + * and libraries also define a boolean type due to the lack of a standard bool in C89. + * But calling it simply "bool" or "boolean" almost guarantees a namespace conflict + * if trying to use OSAL with one of those other existing projects. + * + * RTEMS 4.11 no longer defines boolean type by default (deprecated) probably also + * due to the high likelihood of name conflicts. + * + * In order to preserve compatibility for apps written against prior versions of + * OSAL, the name "boolean" is typedefed as well, but this may be turned off + * in a future version whenever appropriate. + */ + +#if (!defined(_USING_RTEMS_INCLUDES_) || !defined(RTEMS_DEPRECATED_TYPES)) + typedef osalbool boolean; +#endif + + +#ifndef NULL /* pointer to nothing */ + #define NULL ((void *) 0) +#endif + +#ifndef TRUE /* Boolean true */ + #define TRUE (1) +#endif + +#ifndef FALSE /* Boolean false */ + #define FALSE (0) +#endif + +/* +** Check Sizes +*/ +CompileTimeAssert(sizeof(uint8)==1, TypeUint8WrongSize); +CompileTimeAssert(sizeof(uint16)==2, TypeUint16WrongSize); +CompileTimeAssert(sizeof(uint32)==4, TypeUint32WrongSize); +CompileTimeAssert(sizeof(uint64)==8, TypeUint64WrongSize); +CompileTimeAssert(sizeof(int8)==1, Typeint8WrongSize); +CompileTimeAssert(sizeof(int16)==2, Typeint16WrongSize); +CompileTimeAssert(sizeof(int32)==4, Typeint32WrongSize); +CompileTimeAssert(sizeof(int64)==8, Typeint64WrongSize); +CompileTimeAssert(sizeof(cpuaddr) >= sizeof(void *), TypePtrWrongSize); + +/* + * TEMPORARY COMPATIBILITY MACRO + * + * Any code that depends on this macro should be fixed so as to not need it. + * The value for this had been set by the BSP makefiles but this is not reliable, + * especially on processors that support both big- and little- endian modes e.g. + * ARM and MIPS. + * + * This is deprecated and only here to bridge the gap until code that depends + * on this can be fixed. Do not write any new code that uses this macro. + * + * If using an older makefile that defines one of the BIT_ORDER macros already, + * then this entire section is skipped and the macro is used as-is. + */ +#if !defined(SOFTWARE_BIG_BIT_ORDER) && !defined(SOFTWARE_LITTLE_BIT_ORDER) + +#if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || \ + defined(__BIG_ENDIAN__) || \ + defined(__ARMEB__) || \ + defined(__THUMBEB__) || \ + defined(__AARCH64EB__) || \ + defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__) +/* It is a big-endian target architecture */ +#define SOFTWARE_BIG_BIT_ORDER +#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || \ + defined(__LITTLE_ENDIAN__) || \ + defined(__ARMEL__) || \ + defined(__THUMBEL__) || \ + defined(__AARCH64EL__) || \ + defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) +/* It is a little-endian target architecture */ +#define SOFTWARE_LITTLE_BIT_ORDER +#endif + +#endif /* !defined(SOFTWARE_BIG_BIT_ORDER) && !defined(SOFTWARE_LITTLE_BIT_ORDER) */ + +#ifdef __cplusplus + } +#endif + +#endif /* _common_types_ */ diff --git a/src/components/interface/cFE/network_includes.h b/src/components/interface/cFE/network_includes.h new file mode 100644 index 0000000000..1b0d93356a --- /dev/null +++ b/src/components/interface/cFE/network_includes.h @@ -0,0 +1,104 @@ +/****************************************************************************** +** File: network_includes.h +** $Id: network_includes.h 1.3 2009/07/31 10:20:30GMT-05:00 acudmore Exp $ +** +** Purpose: +** This header file contains the correct set of network include +** files, which are dependant on the operating system. +** +** Author: R.McGraw/SSI +** +** Notes: +** +** $Date: 2009/07/31 10:20:30GMT-05:00 $ +** $Revision: 1.3 $ +** $Log: network_includes.h $ +** Revision 1.3 2009/07/31 10:20:30GMT-05:00 acudmore +** Updated RTEMS section to define a MSG_DONTWAIT flag that ci_lab uses. +** Revision 1.2 2009/07/17 14:18:09EDT acudmore +** Updated includes to prevent warnings from ARC suggestions. +** Revision 1.1 2008/04/17 08:05:27EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj +** Revision 1.5 2006/06/08 14:20:29EDT apcudmore +** Re-ordered include files to prevent warnings/errors for vxWorks and REMS +** Revision 1.4 2006/03/03 16:28:38GMT apcudmore +** Created conditional compilation for systems that dont have the fcntl function +** Revision 1.3 2006/03/03 15:11:03GMT apcudmore +** Fixed non-blocking socket problem with CI +** Revision 1.2 2005/07/29 18:16:40GMT apcudmore +** Updated for mac and linux builds +** Revision 1.1 2005/06/09 09:57:51CDT rperera +** Initial revision +** Member added to project d:/mksdata/MKS-CFE-REPOSITORY/cfe-core/inc/project.pj +** Revision 1.1 2005/03/23 16:04:15 rmcgraw +** Initial Release +** +** +******************************************************************************/ + +#ifndef _network_includes_ +#define _network_includes_ + +#ifdef _VXWORKS_OS_ + #include + #include + #include + #include + #include + #include + #include + +#elif _RTEMS_OS_ + #define _USING_RTEMS_INCLUDES_ + #include + #include + #include + #include + #include + #include + #include + #define _HAVE_FCNTL_ + #ifndef MSG_DONTWAIT + #define MSG_DONTWAIT 0 + #endif +#elif _MAC_OS_ + #include + #include + #include + #include + #include + #include + #include + #define _HAVE_FCNTL_ + +#elif _LINUX_OS_ + #include + #include + #include + #include + #include + #include + #include + #define _HAVE_FCNTL_ + #ifndef MSG_DONTWAIT + #define MSG_DONTWAIT 0 + #endif + +#elif _COMPOSITE_OS_ + #include + #include + #include + #include + #include + #include + #include + #define _HAVE_FCNTL_ + #ifndef MSG_DONTWAIT + #define MSG_DONTWAIT 0 + #endif +#else + #error "No OS defined!" +#endif + +#endif /* _network_includes_ */ diff --git a/src/components/interface/cFE/osapi-os-core.h b/src/components/interface/cFE/osapi-os-core.h new file mode 100644 index 0000000000..2f59a1a469 --- /dev/null +++ b/src/components/interface/cFE/osapi-os-core.h @@ -0,0 +1,330 @@ +/* +** File: osapi-os-core.h +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software was created at NASAs Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Author: Ezra Yeheksli -Code 582/Raytheon +** +** Purpose: Contains functions prototype definitions and variables declarations +** for the OS Abstraction Layer, Core OS module +** +** $Revision: 1.8 $ +** +** $Date: 2013/07/25 10:02:00GMT-05:00 $ +** +** $Log: osapi-os-core.h $ +** Revision 1.8 2013/07/25 10:02:00GMT-05:00 acudmore +** removed circular include "osapi.h" +** Revision 1.7 2012/04/11 09:30:48GMT-05:00 acudmore +** Added OS_printf_enable and OS_printf_disable +** Revision 1.6 2010/11/12 12:00:17EST acudmore +** replaced copyright character with (c) and added open source notice where needed. +** Revision 1.5 2010/11/10 15:33:14EST acudmore +** Updated IntAttachHandler prototype +** Revision 1.4 2010/03/08 12:06:28EST acudmore +** added function pointer type to get rid of warnings +** Revision 1.3 2010/02/01 12:37:15EST acudmore +** added return code to OS API init +** Revision 1.2 2009/08/04 10:49:09EDT acudmore +** +*/ + +#ifndef _osapi_core_ +#define _osapi_core_ + +#include /* for va_list */ + +/*difines constants for OS_BinSemCreate for state of semaphore */ +#define OS_SEM_FULL 1 +#define OS_SEM_EMPTY 0 + +/* #define for enabling floating point operations on a task*/ +#define OS_FP_ENABLED 1 + +/* tables for the properties of objects */ + +/*tasks */ +typedef struct +{ + char name [OS_MAX_API_NAME]; + uint32 creator; + uint32 stack_size; + uint32 priority; + uint32 OStask_id; +}OS_task_prop_t; + +/* queues */ +typedef struct +{ + char name [OS_MAX_API_NAME]; + uint32 creator; +}OS_queue_prop_t; + +/* Binary Semaphores */ +typedef struct +{ + char name [OS_MAX_API_NAME]; + uint32 creator; + int32 value; +}OS_bin_sem_prop_t; + +/* Counting Semaphores */ +typedef struct +{ + char name [OS_MAX_API_NAME]; + uint32 creator; + int32 value; +}OS_count_sem_prop_t; + +/* Mutexes */ +typedef struct +{ + char name [OS_MAX_API_NAME]; + uint32 creator; +}OS_mut_sem_prop_t; + + +/* struct for OS_GetLocalTime() */ + +typedef struct +{ + uint32 seconds; + uint32 microsecs; +}OS_time_t; + +/* heap info */ +typedef struct +{ + uint32 free_bytes; + uint32 free_blocks; + uint32 largest_free_block; +}OS_heap_prop_t; + + +/* This typedef is for the OS_GetErrorName function, to ensure + * everyone is making an array of the same length. + * + * Implementation note for developers: + * + * The sizes of strings in OSAL functions are built with this + * OS_ERROR_NAME_LENGTH limit in mind. Always check the uses of os_err_name_t + * when changing this value. + */ + +#define OS_ERROR_NAME_LENGTH 35 +typedef char os_err_name_t[OS_ERROR_NAME_LENGTH]; + +/* +** These typedefs are for the task entry point +*/ +typedef void osal_task; +typedef osal_task ((*osal_task_entry)(void)); + +/* +** Typedef for general purpose OSAL callback functions +** This may be used by multiple APIS +*/ +typedef void (*OS_ArgCallback_t)(uint32 object_id, void *arg); + + +/* +** External Declarations +*/ + +/* +** Prototype for application startup function. +** This is implemented by the user application +*/ +void OS_Application_Startup(void); + + +/* +** Exported Functions +*/ + +/* +** Initialization of API +*/ +int32 OS_API_Init (void); + +/* +** OS-specific background thread implementation - waits forever for events to occur. +** +** This should be called from the BSP main routine / initial thread after all other +** board / application initialization has taken place and all other tasks are running. +*/ +void OS_IdleLoop (void); + +/* +** OS_DeleteAllObjects() provides a means to clean up all resources allocated by this +** instance of OSAL. It would typically be used during an orderly shutdown but may also +** be helpful for testing purposes. +*/ +void OS_DeleteAllObjects (void); + +/* +** OS_ApplicationShutdown() provides a means for a user-created thread to request the orderly +** shutdown of the whole system, such as part of a user-commanded reset command. +** This is preferred over e.g. ApplicationExit() which exits immediately and does not +** provide for any means to clean up first. +*/ +void OS_ApplicationShutdown (uint8 flag); + + +/* +** Task API +*/ + +int32 OS_TaskCreate (uint32 *task_id, const char *task_name, + osal_task_entry function_pointer, + uint32 *stack_pointer, + uint32 stack_size, + uint32 priority, uint32 flags); + +int32 OS_TaskDelete (uint32 task_id); +void OS_TaskExit (void); +int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer); +int32 OS_TaskDelay (uint32 millisecond); +int32 OS_TaskSetPriority (uint32 task_id, uint32 new_priority); +int32 OS_TaskRegister (void); +uint32 OS_TaskGetId (void); +int32 OS_TaskGetIdByName (uint32 *task_id, const char *task_name); +int32 OS_TaskGetInfo (uint32 task_id, OS_task_prop_t *task_prop); + +/* +** Message Queue API +*/ + +/* +** Queue Create now has the Queue ID returned to the caller. +*/ +int32 OS_QueueCreate (uint32 *queue_id, const char *queue_name, + uint32 queue_depth, uint32 data_size, uint32 flags); +int32 OS_QueueDelete (uint32 queue_id); +int32 OS_QueueGet (uint32 queue_id, void *data, uint32 size, + uint32 *size_copied, int32 timeout); +int32 OS_QueuePut (uint32 queue_id, const void *data, uint32 size, + uint32 flags); +int32 OS_QueueGetIdByName (uint32 *queue_id, const char *queue_name); +int32 OS_QueueGetInfo (uint32 queue_id, OS_queue_prop_t *queue_prop); + +/* +** Semaphore API +*/ + +int32 OS_BinSemCreate (uint32 *sem_id, const char *sem_name, + uint32 sem_initial_value, uint32 options); +int32 OS_BinSemFlush (uint32 sem_id); +int32 OS_BinSemGive (uint32 sem_id); +int32 OS_BinSemTake (uint32 sem_id); +int32 OS_BinSemTimedWait (uint32 sem_id, uint32 msecs); +int32 OS_BinSemDelete (uint32 sem_id); +int32 OS_BinSemGetIdByName (uint32 *sem_id, const char *sem_name); +int32 OS_BinSemGetInfo (uint32 sem_id, OS_bin_sem_prop_t *bin_prop); + +int32 OS_CountSemCreate (uint32 *sem_id, const char *sem_name, + uint32 sem_initial_value, uint32 options); +int32 OS_CountSemGive (uint32 sem_id); +int32 OS_CountSemTake (uint32 sem_id); +int32 OS_CountSemTimedWait (uint32 sem_id, uint32 msecs); +int32 OS_CountSemDelete (uint32 sem_id); +int32 OS_CountSemGetIdByName (uint32 *sem_id, const char *sem_name); +int32 OS_CountSemGetInfo (uint32 sem_id, OS_count_sem_prop_t *count_prop); + +/* +** Mutex API +*/ + +int32 OS_MutSemCreate (uint32 *sem_id, const char *sem_name, uint32 options); +int32 OS_MutSemGive (uint32 sem_id); +int32 OS_MutSemTake (uint32 sem_id); +int32 OS_MutSemDelete (uint32 sem_id); +int32 OS_MutSemGetIdByName (uint32 *sem_id, const char *sem_name); +int32 OS_MutSemGetInfo (uint32 sem_id, OS_mut_sem_prop_t *mut_prop); + +/* +** OS Time/Tick related API +*/ + +int32 OS_Milli2Ticks (uint32 milli_seconds); +int32 OS_Tick2Micros (void); +int32 OS_GetLocalTime (OS_time_t *time_struct); +int32 OS_SetLocalTime (OS_time_t *time_struct); + +/* +** Exception API +*/ + +int32 OS_ExcAttachHandler (uint32 ExceptionNumber, + void (*ExceptionHandler)(uint32, const void *,uint32), + int32 parameter); +int32 OS_ExcEnable (int32 ExceptionNumber); +int32 OS_ExcDisable (int32 ExceptionNumber); + +/* +** Floating Point Unit API +*/ + +int32 OS_FPUExcAttachHandler (uint32 ExceptionNumber, void * ExceptionHandler , + int32 parameter); +int32 OS_FPUExcEnable (int32 ExceptionNumber); +int32 OS_FPUExcDisable (int32 ExceptionNumber); +int32 OS_FPUExcSetMask (uint32 mask); +int32 OS_FPUExcGetMask (uint32 *mask); + +/* +** Interrupt API +*/ +int32 OS_IntAttachHandler (uint32 InterruptNumber, osal_task_entry InterruptHandler, int32 parameter); +int32 OS_IntUnlock (int32 IntLevel); +int32 OS_IntLock (void); + +int32 OS_IntEnable (int32 Level); +int32 OS_IntDisable (int32 Level); + +int32 OS_IntSetMask (uint32 mask); +int32 OS_IntGetMask (uint32 *mask); +int32 OS_IntAck (int32 InterruptNumber); + +/* +** Shared memory API +*/ +int32 OS_ShMemInit (void); +int32 OS_ShMemCreate (uint32 *Id, uint32 NBytes, const char* SegName); +int32 OS_ShMemSemTake (uint32 Id); +int32 OS_ShMemSemGive (uint32 Id); +int32 OS_ShMemAttach (cpuaddr * Address, uint32 Id); +int32 OS_ShMemGetIdByName (uint32 *ShMemId, const char *SegName ); + +/* +** Heap API +*/ +int32 OS_HeapGetInfo (OS_heap_prop_t *heap_prop); + +/* +** API for useful debugging function +*/ +int32 OS_GetErrorName (int32 error_num, os_err_name_t* err_name); + + +/* +** Abstraction for printf statements +*/ +void OS_printf( const char *string, ...) OS_PRINTF(1,2); +void OS_printf_disable(void); +void OS_printf_enable(void); + +/* +** Call to exit the running application +** Normally embedded applications run forever, but for debugging purposes +** (unit testing for example) this is needed in order to end the test +*/ +void OS_ApplicationExit(int32 Status); + +#endif diff --git a/src/components/interface/cFE/osapi-os-filesys.h b/src/components/interface/cFE/osapi-os-filesys.h new file mode 100644 index 0000000000..b51bf77b9a --- /dev/null +++ b/src/components/interface/cFE/osapi-os-filesys.h @@ -0,0 +1,440 @@ +/* +** File: osapi-os-filesys.h +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software was created at NASAs Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Author: Alan Cudmore Code 582 +** +** Purpose: Contains functions prototype definitions and variables declarations +** for the OS Abstraction Layer, File System module +** +** $Revision: 1.11 $ +** +** $Date: 2013/12/16 12:57:41GMT-05:00 $ +** +** $Log: osapi-os-filesys.h $ +** Revision 1.11 2013/12/16 12:57:41GMT-05:00 acudmore +** Added macros for Volume name length and physical device name length +** Revision 1.10 2013/07/29 12:05:48GMT-05:00 acudmore +** Added define for device and volume name length +** Revision 1.9 2013/07/25 14:31:21GMT-05:00 acudmore +** Added prototype and datatype for OS_GetFsInfo +** Revision 1.8 2011/12/05 12:04:21GMT-05:00 acudmore +** Added OS_rewinddir API +** Revision 1.7 2011/04/05 16:01:12EDT acudmore +** Added OS_CloseFileByName and OS_CloseAllFiles +** Revision 1.6 2010/11/15 11:04:38EST acudmore +** Added OS_FileOpenCheck function. +** Revision 1.5 2010/11/12 12:00:18EST acudmore +** replaced copyright character with (c) and added open source notice where needed. +** Revision 1.4 2010/02/01 12:28:57EST acudmore +** Added OS_fsBytesFree API +** Revision 1.3 2010/01/25 14:44:26EST acudmore +** renamed "new" variable to avoid C++ reserved name conflict. +** Revision 1.2 2009/07/14 15:16:05EDT acudmore +** Added OS_TranslatePath to the API +** Revision 1.1 2008/04/20 22:36:01EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/os/inc/project.pj +** Revision 1.1 2007/10/16 16:14:52EDT apcudmore +** Initial revision +** Member added to project d:/mksdata/MKS-OSAL-REPOSITORY/src/os/inc/project.pj +** Revision 1.1 2007/08/24 13:43:24EDT apcudmore +** Initial revision +** Member added to project d:/mksdata/MKS-CFE-PROJECT/fsw/cfe-core/os/inc/project.pj +** Revision 1.17 2007/06/07 09:59:14EDT njyanchik +** I replaced the second OS_cp definition with OS_mv +** Revision 1.16 2007/06/05 16:25:33EDT apcudmore +** Increased Number of volume table entries from 10 to 14. +** Added 2 extra EEPROM disk mappings to RAD750 Volume table + 2 spares +** Added 4 spares to every other volume table. +** Revision 1.15 2007/05/25 09:17:56EDT njyanchik +** I added the rmfs call to the OSAL and updated the unit test stubs to match +** Revision 1.14 2007/03/21 10:15:29EST njyanchik +** I mistakenly put the wrong length in for the path in the OS_FDTableEntry structure, and I added +** some code that will set and out of range file descriptors .IsValid flag to false in OS_FDGetInfo +** Revision 1.13 2007/03/06 11:52:46EST njyanchik +** This change goes with the previous CP, I forgot to include it +** Revision 1.12 2007/02/28 14:57:45EST njyanchik +** The updates for supporting copying and moving files are now supported +** Revision 1.11 2007/02/27 15:22:11EST njyanchik +** This CP has the initial import of the new file descripor table mechanism +** Revision 1.10 2006/12/20 10:27:09EST njyanchik +** This change package incorporates all the changes necessary for the addition +** of a new API to get the real physical drive undernieth a mount point +** Revision 1.9 2006/11/14 14:44:28GMT-05:00 njyanchik +** Checks were added to the OS fs calls that look at the return of a function that +** changes the name of paths from abstracted to local path names. +** Revision 1.8 2006/10/30 16:12:19GMT-05:00 apcudmore +** Updated Compact flash and RAM device names for vxWorks 6.2 changes. +** Revision 1.7 2006/10/25 11:31:18EDT njyanchik +** This CP incorporates changes to every bsp_voltab.c file. I increased the number +** entries in the volume table to 10. I also changed the #define in the os_filesys.h +** file for the number of entries to match. +** +** This update also includes adding the prototype for OS_initfs in os_filesys.h +** Revision 1.6 2006/09/26 09:03:46GMT-05:00 njyanchik +** Contains the initial import of the ES Shell commands interface +** Revision 1.5 2006/07/25 15:37:52EDT njyanchik +** It turns out the both the FS app and the OSAL were incorrect where file descriptors are +** concerned. the file descriptors should be int32 across the board. +** Revision 1.4 2006/01/20 11:56:18EST njyanchik +** Fixed header file information to match api document +** Revision 1.26 2005/07/12 17:13:56 nyanchik +** Moved the Volume table to a bsp table in the arch directories. +** +** Revision 1.2 2005/07/11 16:26:57EDT apcudmore +** OSAPI 2.0 integration +** Revision 1.25 2005/07/06 16:11:17 nyanchik +** *** empty log message *** +** +** Revision 1.24 2005/07/05 18:34:55 nyanchik +** fixed issues found in code walkthrogh. Also removed the OS_Info* functions that are going in the BSP +** +** Revision 1.23 2005/06/17 19:46:34 nyanchik +** added new file system style to linux and rtems. +** +** Revision 1.22 2005/06/15 16:43:48 nyanchik +** added extra parenthesis for the .h file # defines +** +** Revision 1.21 2005/06/06 14:17:42 nyanchik +** added headers to osapi-os-core.h and osapi-os-filesys.h +** +** Revision 1.20 2005/06/02 18:04:24 nyanchik +** *** empty log message *** +** +** Revision 1.1 2005/03/15 18:26:32 nyanchik +** *** empty log message *** +** +** +** Date Written: +** +** +*/ + +#ifndef _osapi_filesys_ +#define _osapi_filesys_ +#include +#include +#include +#include + +#define OS_READ_ONLY 0 +#define OS_WRITE_ONLY 1 +#define OS_READ_WRITE 2 + +#define OS_SEEK_SET 0 +#define OS_SEEK_CUR 1 +#define OS_SEEK_END 2 + +#define OS_CHK_ONLY 0 +#define OS_REPAIR 1 + +#define FS_BASED 0 +#define RAM_DISK 1 +#define EEPROM_DISK 2 +#define ATA_DISK 3 + + +/* +** Number of entries in the internal volume table +*/ +#define NUM_TABLE_ENTRIES 14 + +/* +** Length of a Device and Volume name +*/ +#define OS_FS_DEV_NAME_LEN 32 +#define OS_FS_PHYS_NAME_LEN 64 +#define OS_FS_VOL_NAME_LEN 32 + + +/* +** Defines for File System Calls +*/ +/* + * NOTE - these values used to overlap with the + * other OSAPI error codes. They now start at -100 + * to avoid this overlap. + */ +#define OS_FS_ERR_PATH_TOO_LONG (-103) +#define OS_FS_ERR_NAME_TOO_LONG (-104) +#define OS_FS_ERR_DRIVE_NOT_CREATED (-106) +#define OS_FS_ERR_DEVICE_NOT_FREE (-107) +#define OS_FS_ERR_PATH_INVALID (-108) + + +/* + * Map some codes used by the file API back to the generic counterparts + * where there is overlap between them. Do not duplicate error codes. + */ +#define OS_FS_SUCCESS OS_SUCCESS +#define OS_FS_ERROR OS_ERROR +#define OS_FS_ERR_INVALID_POINTER OS_INVALID_POINTER +#define OS_FS_ERR_NO_FREE_FDS OS_ERR_NO_FREE_IDS +#define OS_FS_ERR_INVALID_FD OS_ERR_INVALID_ID +#define OS_FS_UNIMPLEMENTED OS_ERR_NOT_IMPLEMENTED + + +/* This typedef is for the OS_FS_GetErrorName function, to ensure + * everyone is making an array of the same length + * + * Implementation note for developers: + * + * os_fs_err_name_t is now equivalent to the OSAL "os_err_name_t" typedef, + * to preserve source code compatibility with anything using the OS_FS_GetErrorName api + * + * The sizes of strings in OSAL functions are built with os_fs_err_name_t's + * limits in mind. Always check the uses of os_fs_err_name_t when changing + * os_err_name_t. + */ +typedef os_err_name_t os_fs_err_name_t; + + +/* +** Internal structure of the OS volume table for +** mounted file systems and path translation +*/ +typedef struct +{ + char DeviceName [OS_FS_DEV_NAME_LEN]; + char PhysDevName [OS_FS_PHYS_NAME_LEN]; + uint32 VolumeType; + uint8 VolatileFlag; + uint8 FreeFlag; + uint8 IsMounted; + char VolumeName [OS_FS_VOL_NAME_LEN]; + char MountPoint [OS_MAX_PATH_LEN]; + uint32 BlockSize; + +}OS_VolumeInfo_t; + +typedef struct +{ + int32 OSfd; /* The underlying OS's file descriptor */ + char Path[OS_MAX_PATH_LEN]; /* The path of the file opened */ + uint32 User; /* The task id of the task who opened the file*/ + uint8 IsValid; /* Whether or not this entry is valid */ +}OS_FDTableEntry; + +typedef struct +{ + uint32 MaxFds; /* Total number of file descriptors */ + uint32 FreeFds; /* Total number that are free */ + uint32 MaxVolumes; /* Maximum number of volumes */ + uint32 FreeVolumes; /* Total number of volumes free */ +} os_fsinfo_t; + +/* modified to posix calls, since all of the + * applicable OSes use the posix calls */ + +typedef struct stat os_fstat_t; +typedef DIR* os_dirp_t; +typedef struct dirent os_dirent_t; +/* still don't know what this should be*/ +typedef unsigned long int os_fshealth_t; + +/* + * Exported Functions +*/ + + +/****************************************************************************** +** Standard File system API +******************************************************************************/ +/* + * Initializes the File System functions +*/ + +int32 OS_FS_Init(void); + +/* + * Creates a file specified by path +*/ +int32 OS_creat (const char *path, int32 access); + +/* + * Opend a file for reading/writing. Returns file descriptor +*/ +int32 OS_open (const char *path, int32 access, uint32 mode); + +/* + * Closes an open file. +*/ +int32 OS_close (int32 filedes); + +/* + * Reads nbytes bytes from file into buffer +*/ +int32 OS_read (int32 filedes, void *buffer, uint32 nbytes); + +/* + * Write nybytes bytes of buffer into the file +*/ +int32 OS_write (int32 filedes, void *buffer, uint32 nbytes); + +/* + * Changes the permissions of a file +*/ +int32 OS_chmod (const char *path, uint32 access); + +/* + * Returns file status information in filestats +*/ +int32 OS_stat (const char *path, os_fstat_t *filestats); + +/* + * Seeks to the specified position of an open file +*/ +int32 OS_lseek (int32 filedes, int32 offset, uint32 whence); + +/* + * Removes a file from the file system +*/ +int32 OS_remove (const char *path); + +/* + * Renames a file in the file system +*/ +int32 OS_rename (const char *old_filename, const char *new_filename); + +/* + * copies a single file from src to dest +*/ +int32 OS_cp (const char *src, const char *dest); + +/* + * moves a single file from src to dest +*/ +int32 OS_mv (const char *src, const char *dest); + +/* + * Copies the info of an open file to the structure +*/ +int32 OS_FDGetInfo (int32 filedes, OS_FDTableEntry *fd_prop); + +/* +** Check to see if a file is open +*/ +int32 OS_FileOpenCheck(char *Filename); + +/* +** Close all open files +*/ +int32 OS_CloseAllFiles(void); + +/* +** Close a file by filename +*/ +int32 OS_CloseFileByName(char *Filename); + + +/****************************************************************************** +** Directory API +******************************************************************************/ + +/* + * Makes a new directory +*/ +int32 OS_mkdir (const char *path, uint32 access); + +/* + * Opens a directory for searching +*/ +os_dirp_t OS_opendir (const char *path); + +/* + * Closes an open directory +*/ +int32 OS_closedir(os_dirp_t directory); + +/* + * Rewinds an open directory +*/ +void OS_rewinddir(os_dirp_t directory); + +/* + * Reads the next object in the directory +*/ +os_dirent_t * OS_readdir (os_dirp_t directory); + +/* + * Removes an empty directory from the file system. +*/ +int32 OS_rmdir (const char *path); + +/****************************************************************************** +** System Level API +******************************************************************************/ +/* + * Makes a file system +*/ +int32 OS_mkfs (char *address,char *devname, char *volname, + uint32 blocksize, uint32 numblocks); +/* + * Mounts a file system +*/ +int32 OS_mount (const char *devname, char *mountpoint); + +/* + * Initializes an existing file system +*/ +int32 OS_initfs (char *address,char *devname, char *volname, + uint32 blocksize, uint32 numblocks); + +/* + * removes a file system +*/ +int32 OS_rmfs (char *devname); + +/* + * Unmounts a mounted file system +*/ +int32 OS_unmount (const char *mountpoint); + +/* + * Returns the number of free blocks in a file system +*/ +int32 OS_fsBlocksFree (const char *name); + +/* +** Returns the number of free bytes in a file system +** Note the 64 bit data type to support filesystems that +** are greater than 4 Gigabytes +*/ +int32 OS_fsBytesFree (const char *name, uint64 *bytes_free); + +/* + * Checks the health of a file system and repairs it if neccesary +*/ +os_fshealth_t OS_chkfs (const char *name, boolean repair); + +/* + * Returns in the parameter the physical drive underneith the mount point +*/ +int32 OS_FS_GetPhysDriveName (char * PhysDriveName, char * MountPoint); + +/* +** Translates a OSAL Virtual file system path to a host Local path +*/ +int32 OS_TranslatePath ( const char *VirtualPath, char *LocalPath); + +/* +** Returns information about the file system in an os_fsinfo_t +*/ +int32 OS_GetFsInfo(os_fsinfo_t *filesys_info); + +/****************************************************************************** +** Shell API +******************************************************************************/ + +/* executes the shell command passed into is and writes the output of that + * command to the file specified by the given OSAPI file descriptor */ +int32 OS_ShellOutputToFile(char* Cmd, int32 OS_fd); +#endif diff --git a/src/components/interface/cFE/osapi-os-loader.h b/src/components/interface/cFE/osapi-os-loader.h new file mode 100644 index 0000000000..f14845ff65 --- /dev/null +++ b/src/components/interface/cFE/osapi-os-loader.h @@ -0,0 +1,104 @@ +/* +** File: osapi-os-loader.h +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software was created at NASAs Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Author: Alan Cudmore - Code 582 +** +** Purpose: Contains functions prototype definitions and variables declarations +** for the OS Abstraction Layer, Object file loader API +** +** $Revision: 1.5 $ +** +** $Date: 2013/07/25 10:02:08GMT-05:00 $ +** +** $Log: osapi-os-loader.h $ +** Revision 1.5 2013/07/25 10:02:08GMT-05:00 acudmore +** removed circular include "osapi.h" +** Revision 1.4 2010/11/12 12:00:18GMT-05:00 acudmore +** replaced copyright character with (c) and added open source notice where needed. +** Revision 1.3 2010/02/01 12:38:06EST acudmore +** added return code to OS_ModuleTableInit +** Revision 1.2 2008/06/20 15:13:43EDT apcudmore +** Checked in new Module loader/symbol table functionality +** Revision 1.1 2008/04/20 22:36:02EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/os/inc/project.pj +** Revision 1.1 2008/02/07 11:08:24EST apcudmore +** Initial revision +** Member added to project d:/mksdata/MKS-OSAL-REPOSITORY/src/os/inc/project.pj +** +** +*/ + +#ifndef _osapi_loader_ +#define _osapi_loader_ + +/* +** Defines +*/ + + +/* +** Typedefs +*/ + +typedef struct +{ + uint32 valid; + uint32 flags; + cpuaddr code_address; + cpuaddr code_size; + cpuaddr data_address; + cpuaddr data_size; + cpuaddr bss_address; + cpuaddr bss_size; +} OS_module_address_t; + +typedef struct +{ + cpuaddr entry_point; + uint32 host_module_id; + char filename[OS_MAX_PATH_LEN]; + char name[OS_MAX_API_NAME]; + OS_module_address_t addr; +} OS_module_prop_t; + +/* + * Define the former "OS_module_record_t" type as equivalent + * to the OS_module_prop_t. This is what the OS_ModuleInfo() + * will output. It used to be the same as the internal record + * just without all the fields filled in. This has been changed + * to make it a separate structure, which will allow the internal + * implementation to change without further changing the API. + * + * Ideally OS_module_record_t type should be removed to avoid confusion, + * but this would break existing code that calls OS_ModuleInfo(). + */ +#ifndef OSAL_OMIT_DEPRECATED +typedef OS_module_prop_t OS_module_record_t; +#endif + +/* +** Loader API +*/ +int32 OS_ModuleTableInit ( void ); + +int32 OS_SymbolLookup (cpuaddr *symbol_address, const char *symbol_name ); + +int32 OS_SymbolTableDump ( const char *filename, uint32 size_limit ); + +int32 OS_ModuleLoad ( uint32 *module_id, const char *module_name, const char *filename ); + +int32 OS_ModuleUnload ( uint32 module_id ); + +int32 OS_ModuleInfo ( uint32 module_id, OS_module_prop_t *module_info ); + + +#endif diff --git a/src/components/interface/cFE/osapi-os-net.h b/src/components/interface/cFE/osapi-os-net.h new file mode 100644 index 0000000000..41335e0699 --- /dev/null +++ b/src/components/interface/cFE/osapi-os-net.h @@ -0,0 +1,129 @@ +/* +** File: osapi-os-net.h +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software was created at NASAs Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Author: Alan Cudmore Code 582 +** +** Purpose: Contains functions prototype definitions and variables declarations +** for the OS Abstraction Layer, Network Module +** +** $Revision: 1.2 $ +** +** $Date: 2010/11/12 12:00:19GMT-05:00 $ +** +** $Log: osapi-os-net.h $ +** Revision 1.2 2010/11/12 12:00:19GMT-05:00 acudmore +** replaced copyright character with (c) and added open source notice where needed. +** Revision 1.1 2008/04/20 22:36:02EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/os/inc/project.pj +** Revision 1.1 2007/10/16 16:14:52EDT apcudmore +** Initial revision +** Member added to project d:/mksdata/MKS-OSAL-REPOSITORY/src/os/inc/project.pj +** Revision 1.1 2007/08/24 13:43:25EDT apcudmore +** Initial revision +** Member added to project d:/mksdata/MKS-CFE-PROJECT/fsw/cfe-core/os/inc/project.pj +** Revision 1.3 2006/01/20 11:56:18EST njyanchik +** Fixed header file information to match api document +** Revision 1.4 2005/06/07 16:49:31 nyanchik +** changed returns code for osapi.c to all int32 from uint32 +** +** Revision 1.3 2005/03/22 19:04:54 acudmore +** fixed uint type +** +** Revision 1.2 2005/03/22 18:59:33 acudmore +** updated prototype +** +** Revision 1.1 2005/03/22 18:58:51 acudmore +** added osapi network interface +** +** Revision 1.1 2005/03/15 18:26:32 nyanchik +** *** empty log message *** +** +** +** Date Written: +** +** +*/ +#ifndef _osapi_network_ +#define _osapi_network_ + +/* + * Sockets API wrapper functions + */ + +typedef enum +{ + OS_SocketDomain_INVALID, +#ifdef OS_INCLUDE_NETWORK + OS_SocketDomain_INET, + OS_SocketDomain_INET6, +#endif + OS_SocketDomain_MAX +} OS_SocketDomain_t; + +typedef enum +{ + OS_SocketType_INVALID, +#ifdef OS_INCLUDE_NETWORK + OS_SocketType_DATAGRAM, + OS_SocketType_STREAM, +#endif + OS_SocketType_MAX +} OS_SocketType_t; + +#ifdef OS_INCLUDE_NETWORK + +/* NOTE - osconfig.h may optionally specify the value for OS_SOCADDR_MAX_LEN */ +#include + +#ifndef OS_SOCKADDR_MAX_LEN +#define OS_SOCKADDR_MAX_LEN 32 +#endif + +typedef struct +{ + uint32 ActualLength; + char AddrData[OS_SOCKADDR_MAX_LEN]; +} OS_SockAddr_t; + +typedef struct +{ + char name [OS_MAX_API_NAME]; + uint32 creator; +} OS_socket_prop_t; + + +int32 OS_SocketOpen(uint32 *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t Type); +int32 OS_SocketClose(uint32 sock_id); +int32 OS_SocketBind(uint32 sock_id, const OS_SockAddr_t *Addr); +int32 OS_SocketConnect(uint32 sock_id, const OS_SockAddr_t *Addr, int32 timeout); +int32 OS_SocketAccept(uint32 sock_id, uint32 *connsock_id, OS_SockAddr_t *Addr, int32 timeout); +int32 OS_SocketRecvFrom(uint32 sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout); +int32 OS_SocketSendTo(uint32 sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr); +int32 OS_SocketGetIdByName (uint32 *sock_id, const char *sock_name); +int32 OS_SocketGetInfo (uint32 sock_id, OS_socket_prop_t *sock_prop); + +int32 OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain); +int32 OS_SocketAddrToString(char *buffer, uint32 buflen, const OS_SockAddr_t *Addr); +int32 OS_SocketAddrFromString(OS_SockAddr_t *Addr, const char *string); +int32 OS_SocketAddrGetPort(uint16 *PortNum, const OS_SockAddr_t *Addr); +int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum); + +/* +** OS_NetworkGetID is currently [[deprecated]] as its behavior is +** unknown and not consistent across operating systems. +*/ +int32 OS_NetworkGetID (void); +int32 OS_NetworkGetHostName (char *host_name, uint32 name_len); + +#endif /* OS_INCLUDE_NETWORK */ + +#endif diff --git a/src/components/interface/cFE/osapi-os-timer.h b/src/components/interface/cFE/osapi-os-timer.h new file mode 100644 index 0000000000..89ca47db9e --- /dev/null +++ b/src/components/interface/cFE/osapi-os-timer.h @@ -0,0 +1,82 @@ +/* +** File: osapi-os-timer.h +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software was created at NASAs Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Author: Alan Cudmore - Code 582 +** +** Purpose: Contains functions prototype definitions and variable declarations +** for the OS Abstraction Layer, Timer API +** +** $Revision: 1.5 $ +** +** $Date: 2013/07/25 10:02:20GMT-05:00 $ +** +** $Log: osapi-os-timer.h $ +** Revision 1.5 2013/07/25 10:02:20GMT-05:00 acudmore +** removed circular include "osapi.h" +** Revision 1.4 2010/11/12 12:00:19GMT-05:00 acudmore +** replaced copyright character with (c) and added open source notice where needed. +** Revision 1.3 2010/02/01 12:38:34EST acudmore +** Added return code to OS_TimerAPIInit +** Revision 1.2 2008/08/26 13:52:52EDT apcudmore +** removed linux specific define +** Revision 1.1 2008/08/20 16:12:07EDT apcudmore +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/os/inc/project.pj +** +** +*/ + +#ifndef _osapi_timer_ +#define _osapi_timer_ + +/* +** Typedefs +*/ +typedef void (*OS_TimerCallback_t)(uint32 timer_id); +typedef int32 (*OS_TimerSync_t)(uint32 timer_id); + +typedef struct +{ + char name[OS_MAX_API_NAME]; + uint32 creator; + uint32 start_time; + uint32 interval_time; + uint32 accuracy; + +} OS_timer_prop_t; + +typedef struct +{ + char name[OS_MAX_API_NAME]; + uint32 creator; + uint32 interval_time; + uint32 accuracy; +} OS_timebase_prop_t; + +/* +** Timer API +*/ +int32 OS_TimerAPIInit (void); + +int32 OS_TimeBaseCreate (uint32 *timer_id, const char *timebase_name, OS_TimerSync_t external_sync); +int32 OS_TimeBaseSet (uint32 timer_id, uint32 start_time, uint32 interval_time); +int32 OS_TimeBaseDelete (uint32 timer_id); +int32 OS_TimeBaseGetIdByName (uint32 *timer_id, const char *timebase_name); + +int32 OS_TimerCreate (uint32 *timer_id, const char *timer_name, uint32 *clock_accuracy, OS_TimerCallback_t callback_ptr); +int32 OS_TimerAdd (uint32 *timer_id, const char *timer_name, uint32 timebase_id, OS_ArgCallback_t callback_ptr, void *callback_arg); +int32 OS_TimerSet (uint32 timer_id, uint32 start_time, uint32 interval_time); +int32 OS_TimerDelete (uint32 timer_id); + +int32 OS_TimerGetIdByName (uint32 *timer_id, const char *timer_name); +int32 OS_TimerGetInfo (uint32 timer_id, OS_timer_prop_t *timer_prop); + +#endif diff --git a/src/components/interface/cFE/osapi-version.h b/src/components/interface/cFE/osapi-version.h new file mode 100644 index 0000000000..5c2a3afb83 --- /dev/null +++ b/src/components/interface/cFE/osapi-version.h @@ -0,0 +1,69 @@ +/************************************************************************ +** File: +** $Id: osapi-version.h 1.10 2014/01/23 16:33:31GMT-05:00 acudmore Exp $ +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software was created at NASAs Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Purpose: +** The OSAL version numbers +** +** Notes: +** +** $Log: osapi-version.h $ +** Revision 1.10 2014/01/23 16:33:31GMT-05:00 acudmore +** Update for 4.1 release +** Revision 1.9 2013/01/16 14:35:18GMT-05:00 acudmore +** updated version label +** Revision 1.8 2012/04/16 14:57:04GMT-05:00 acudmore +** Updated version label to 3.5.0.0 +** Revision 1.7 2012/01/17 16:04:29EST acudmore +** Updated version to 3.4.1 +** Revision 1.6 2011/12/05 15:45:16EST acudmore +** Updated version label to 3.4.0 +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/os/inc/project.pj +** +*************************************************************************/ +#ifndef _osapi_version_h_ +#define _osapi_version_h_ + +/* + * Note about the OS_REVISION value: + * During development of the "next" version of OSAL (whatever number it might be), the + * OS_REVISION value should be something high (>90) to indicate the fact that this is a development + * version and not an official release version. For instance, at the time of this writing + * the official version is 4.1.1 and the next version would likely be 4.2.0. So anyone + * who uses the "bleeding edge" development branch before 4.2.0 is officially released will + * get a version that reads e.g. "4.1.91" to show that this is a pre-4.2 build. + * + * This still leaves room for patches to be applied to 4.1.1 to produce 4.1.2 if needed. + * + * During development, if an API-affecting change is introduced then the OS_REVISION value should + * be incremented with it to indicate this. Client code that depends on the new API can do a "#if" + * against the development version number e.g. "#if OSAL_API_VERSION >= 40191" and this check + * will still be valid after the version becomes 40200 (although at some point it can be cleaned + * up to reflect the official version number, it is not going to break the build in the meantime). + */ + +#define OS_MAJOR_VERSION 4 +#define OS_MINOR_VERSION 2 +#define OS_REVISION 1 +#define OS_MISSION_REV 0 + +/** + * Combine the revision components into a single value that application code can check against + * e.g. "#if OSAL_API_VERSION >= 40100" would check if some feature added in OSAL 4.1 is present. + */ +#define OSAL_API_VERSION ((OS_MAJOR_VERSION * 10000) + (OS_MINOR_VERSION * 100) + OS_REVISION) + +#endif /* _osapi_version_h_ */ + +/************************/ +/* End of File Comment */ +/************************/ diff --git a/src/components/interface/cFE/osapi.h b/src/components/interface/cFE/osapi.h new file mode 100644 index 0000000000..b22991548d --- /dev/null +++ b/src/components/interface/cFE/osapi.h @@ -0,0 +1,149 @@ +/* +** File: osapi.h +** +** Copyright (c) 2004-2006, United States government as represented by the +** administrator of the National Aeronautics Space Administration. +** All rights reserved. This software was created at NASAs Goddard +** Space Flight Center pursuant to government contracts. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Author: Alan Cudmore - Code 582 +** +** Purpose: Contains functions prototype definitions and variables declarations +** for the OS Abstraction Layer, Core OS module +** +** $Revision: 1.10 $ +** +** $Date: 2013/07/25 10:01:32GMT-05:00 $ +** +** $Log: osapi.h $ +** Revision 1.10 2013/07/25 10:01:32GMT-05:00 acudmore +** Added C++ support +** Revision 1.9 2010/11/12 12:00:17GMT-05:00 acudmore +** replaced copyright character with (c) and added open source notice where needed. +** Revision 1.8 2010/03/08 15:57:20EST acudmore +** include new OSAL version header file +** Revision 1.7 2009/08/10 14:01:10EDT acudmore +** Reset OSAL version for trunk +** Revision 1.6 2009/08/10 13:55:49EDT acudmore +** Updated OSAL version defines to 3.0 +** Revision 1.5 2009/06/10 14:15:55EDT acudmore +** Removed HAL include files. HAL code was removed from OSAL. +** Revision 1.4 2008/08/20 16:12:51EDT apcudmore +** Updated timer error codes +** Revision 1.3 2008/08/20 15:46:27EDT apcudmore +** Add support for timer API +** Revision 1.2 2008/06/20 15:13:43EDT apcudmore +** Checked in new Module loader/symbol table functionality +** Revision 1.1 2008/04/20 22:36:02EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/os/inc/project.pj +** Revision 1.6 2008/02/14 11:29:10EST apcudmore +** Updated version define ( 2.11 ) +** Revision 1.5 2008/02/07 11:31:58EST apcudmore +** Fixed merge problem +** Revision 1.4 2008/02/07 11:07:29EST apcudmore +** Added dynamic loader / Symbol lookup API +** -- API only, next release will have functionality +** Revision 1.2 2008/01/29 14:30:49EST njyanchik +** I added code to all the ports that allow the values of both binary and counting semaphores to be +** gotten through the OS_*SemGetInfo API. +** Revision 1.1 2007/10/16 16:14:52EDT apcudmore +** Initial revision +** Member added to project d:/mksdata/MKS-OSAL-REPOSITORY/src/os/inc/project.pj +** Revision 1.2 2007/09/28 15:46:49EDT rjmcgraw +** Updated version numbers to 5.0 +** Revision 1.1 2007/08/24 13:43:25EDT apcudmore +** Initial revision +** Member added to project d:/mksdata/MKS-CFE-PROJECT/fsw/cfe-core/os/inc/project.pj +** Revision 1.9.1.1 2007/05/21 08:58:51EDT njyanchik +** The trunk version number has been updated to version 0.0 +** Revision 1.9 2006/06/12 10:20:07EDT rjmcgraw +** Updated OS_MINOR_VERSION from 3 to 4 +** Revision 1.8 2006/02/03 09:30:45EST njyanchik +** Changed version number to 2.3 +** Revision 1.7 2006/01/20 11:56:16EST njyanchik +** Fixed header file information to match api document +** Revision 1.15 2005/11/09 13:35:49 nyanchik +** Revisions for 2.2 include: +** a new scheduler mapper for Linux and OS X +** addition of OS_printf function +** fixed issues that would cause warnings at compile time +** +** +*/ + +#ifndef _osapi_ +#define _osapi_ + +#include "common_types.h" + +#ifdef __cplusplus + extern "C" { +#endif + +#define OS_SUCCESS (0) +#define OS_ERROR (-1) +#define OS_INVALID_POINTER (-2) +#define OS_ERROR_ADDRESS_MISALIGNED (-3) +#define OS_ERROR_TIMEOUT (-4) +#define OS_INVALID_INT_NUM (-5) +#define OS_SEM_FAILURE (-6) +#define OS_SEM_TIMEOUT (-7) +#define OS_QUEUE_EMPTY (-8) +#define OS_QUEUE_FULL (-9) +#define OS_QUEUE_TIMEOUT (-10) +#define OS_QUEUE_INVALID_SIZE (-11) +#define OS_QUEUE_ID_ERROR (-12) +#define OS_ERR_NAME_TOO_LONG (-13) +#define OS_ERR_NO_FREE_IDS (-14) +#define OS_ERR_NAME_TAKEN (-15) +#define OS_ERR_INVALID_ID (-16) +#define OS_ERR_NAME_NOT_FOUND (-17) +#define OS_ERR_SEM_NOT_FULL (-18) +#define OS_ERR_INVALID_PRIORITY (-19) +#define OS_INVALID_SEM_VALUE (-20) +#define OS_ERR_FILE (-27) +#define OS_ERR_NOT_IMPLEMENTED (-28) +#define OS_TIMER_ERR_INVALID_ARGS (-29) +#define OS_TIMER_ERR_TIMER_ID (-30) +#define OS_TIMER_ERR_UNAVAILABLE (-31) +#define OS_TIMER_ERR_INTERNAL (-32) + +/* +** Defines for Queue Timeout parameters +*/ +#define OS_PEND (-1) +#define OS_CHECK (0) + +#include "osapi-version.h" + +/* +** Include the configuration file +*/ +#include "osconfig.h" + +/* +** Include the OS API modules +*/ +#include "osapi-os-core.h" +#include "osapi-os-filesys.h" +#include "osapi-os-net.h" +#include "osapi-os-loader.h" +#include "osapi-os-timer.h" + +/* + ****************************************************************************** + * Items below here are internal OSAL-use definitions and are not part of the + * OSAL API + ***************************************************************************** + */ + +#ifdef __cplusplus + } +#endif + +#endif + diff --git a/src/components/interface/cFE/osconfig.h b/src/components/interface/cFE/osconfig.h new file mode 100644 index 0000000000..f3fb52439b --- /dev/null +++ b/src/components/interface/cFE/osconfig.h @@ -0,0 +1,219 @@ +/****************************************************************************** +** File: osconfig.h +** $Id: osconfig.h 1.2 2013/12/16 13:07:17GMT-05:00 acudmore Exp $ +** +** Purpose: +** This header file contains the OS API configuration parameters. +** +** Author: A. Cudmore +** +** Notes: +** +** $Date: 2013/12/16 13:07:17GMT-05:00 $ +** $Revision: 1.2 $ +** $Log: osconfig.h $ +** Revision 1.2 2013/12/16 13:07:17GMT-05:00 acudmore +** use OS_FS_PHYS_NAME_LEN macro instead of hard-coded value +** Revision 1.1 2013/07/19 14:05:01GMT-05:00 acudmore +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/bsp/pc-linux/config/project.pj +** Revision 1.8 2011/12/05 12:41:15GMT-05:00 acudmore +** Removed OS_MEM_TABLE_SIZE parameter +** Revision 1.7 2009/07/14 14:24:53EDT acudmore +** Added parameter for local path size. +** Revision 1.6 2009/07/07 14:01:02EDT acudmore +** Changed OS_MAX_NUM_OPEN_FILES to 50 to preserve data/telmetry space +** Revision 1.5 2009/07/07 13:58:22EDT acudmore +** Added OS_STATIC_LOADER define to switch between static and dynamic loaders. +** Revision 1.4 2009/06/04 11:43:43EDT rmcgraw +** DCR8290:1 Increased settings for max tasks,queues,sems and modules +** Revision 1.3 2008/08/20 15:49:37EDT apcudmore +** Add OS_MAX_TIMERS parameter for Timer API +** Revision 1.2 2008/06/20 15:17:56EDT apcudmore +** Added conditional define for Module Loader API configuration +** Revision 1.1 2008/04/20 22:35:19EDT ruperera +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/build/inc/project.pj +** Revision 1.6 2008/02/12 13:27:59EST apcudmore +** New API updates: +** - fixed RTEMS osapi compile error +** - related makefile fixes +** - header file parameter update +** +** Revision 1.1 2005/06/09 10:57:58EDT rperera +** Initial revision +** +******************************************************************************/ + +#ifndef _osconfig_ +#define _osconfig_ + +/* +** Platform Configuration Parameters for the OS API +*/ + +#define OS_MAX_TASKS 64 +#define OS_MAX_QUEUES 64 +#define OS_MAX_COUNT_SEMAPHORES 20 +#define OS_MAX_BIN_SEMAPHORES 20 +#define OS_MAX_MUTEXES 20 + +/* +** Maximum length for an absolute path name +*/ +#define OS_MAX_PATH_LEN 64 + +/* +** Maximum length for a local or host path/filename. +** This parameter can consist of the OSAL filename/path + +** the host OS physical volume name or path. +*/ +#define OS_MAX_LOCAL_PATH_LEN (OS_MAX_PATH_LEN + OS_FS_PHYS_NAME_LEN) + +/* +** The maxium length allowed for a object (task,queue....) name +*/ +#define OS_MAX_API_NAME 20 + +/* +** The maximum length for a file name +*/ +#define OS_MAX_FILE_NAME 20 + +/* +** These defines are for OS_printf +*/ +#define OS_BUFFER_SIZE 172 +#define OS_BUFFER_MSG_DEPTH 100 + +/* This #define turns on a utility task that + * will read the statements to print from + * the OS_printf function. If you want OS_printf + * to print the text out itself, comment this out + * + * NOTE: The Utility Task #defines only have meaning + * on the VxWorks operating systems + */ + +#define OS_UTILITY_TASK_ON + + +#ifdef OS_UTILITY_TASK_ON + #define OS_UTILITYTASK_STACK_SIZE 2048 + /* some room is left for other lower priority tasks */ + #define OS_UTILITYTASK_PRIORITY 245 +#endif + + +/* +** the size of a command that can be passed to the underlying OS +*/ +#define OS_MAX_CMD_LEN 1000 + +/* +** This define will include the OS network API. +** It should be turned off for targtets that do not have a network stack or +** device ( like the basic RAD750 vxWorks BSP ) +*/ +#define OS_INCLUDE_NETWORK + +/* +** This is the maximum number of open file descriptors allowed at a time +*/ +#define OS_MAX_NUM_OPEN_FILES 50 + +/* +** This defines the filethe input command of OS_ShellOutputToFile +** is written to in the VxWorks6 port +*/ +#define OS_SHELL_CMD_INPUT_FILE_NAME "/ram/OS_ShellCmd.in" + +/* +** This define sets the queue implentation of the Linux port to use sockets +** commenting this out makes the Linux port use the POSIX message queues. +*/ +/* #define OSAL_SOCKET_QUEUE */ + +/* +** Module loader/symbol table is optional +*/ +#define OS_INCLUDE_MODULE_LOADER + +#ifdef OS_INCLUDE_MODULE_LOADER + /* + ** This define sets the size of the OS Module Table, which keeps track of the loaded modules in + ** the running system. This define must be set high enough to support the maximum number of + ** loadable modules in the system. If the the table is filled up at runtime, a new module load + ** would fail. + */ + #define OS_MAX_MODULES 20 + + /* + ** The Static Loader define is used for switching between the Dynamic and Static loader implementations. + */ + /* #define OS_STATIC_LOADER */ + +#endif + + +/* +** This define sets the maximum symbol name string length. It is used in implementations that +** support the symbols and symbol lookup. +*/ +#define OS_MAX_SYM_LEN 64 + +/* +** This define sets the maximum number of time base objects +** The limit depends on the underlying OS and the resources it offers, but in general +** these are a limited resource and only a handful can be created. +** +** This is included as an example, for OSAL implementations that do not [yet] support +** separate timebase objects, this directive will be ignored. However, the OSAL unit +** test stub code does require that this is defined. +*/ +#define OS_MAX_TIMEBASES 5 + +/* +** This define sets the maximum number of user timers available +** The limit here depends on whether the OSAL implementation uses limited resources +** for a timer object; in the case of the newer "posix-ng" and "rtems-ng" variants, +** the "timebase" allocates the OS resources and the timer does not use any additional +** OS resources. Therefore this limit can be higher. +*/ +#define OS_MAX_TIMERS 5 + +/* +** This define sets the maximum number of open directories +*/ +#define OS_MAX_NUM_OPEN_DIRS 4 + +/* +** This define sets the maximum depth of an OSAL message queue. On some implementations this may +** affect the overall OSAL memory footprint so it may be beneficial to set this limit according to +** what the application actually needs. +*/ +#define OS_QUEUE_MAX_DEPTH 50 + +/* + * If OS_DEBUG_PRINTF is defined, this will enable the "OS_DEBUG" statements in the code + * This should be left disabled in a normal build as it may affect real time performance as + * well as producing extra console output. + */ +#undef OS_DEBUG_PRINTF + +/* + * If OSAL_DEBUG_PERMISSIVE_MODE is defined, this will enable features to make the + * OSAL library compatible with a non-root (normal user mode) environment. In the PC-Linux/Posix + * build, this means: + * - A message queue deeper than the maximum system limit will be silently truncated + * to the maximum system limit (no error). + * - If the user does not have permission to create elevated priority tasks, then the tasks will + * be created at the default priority (no error). Note this behavior can also be forced by the + * OSAL_DEBUG_DISABLE_TASK_PRIORITIES macro below. + * + * Leaving this undefined will produce the default behavior, which is to return errors to the caller + * for these conditions. + */ +#define OSAL_DEBUG_PERMISSIVE_MODE + +#endif diff --git a/src/components/interface/cFE/private/README.txt b/src/components/interface/cFE/private/README.txt new file mode 100644 index 0000000000..e5e32ba57f --- /dev/null +++ b/src/components/interface/cFE/private/README.txt @@ -0,0 +1,22 @@ +About the "private" cFE include directory +----------------------------------------- + +This directory is for include files that are used within the cFE core library +only, including types and definitions that are shared between more than one +cFE module. + +External libraries and applications should *NOT* include anything from this +directory. Doing so may cause the build to break. The reason is because +directly using definitions in here at compile-time will cause the external +entity (lib or app) to become hard-linked to the same specific cFE config +used to build the cFE - and it will surely break if that app is used with +a cFE instance that has been built with a different config (and probably +in a non-obvious way). + +Instead, the external app or lib should use the configuration exported from +the cFE library via the proper external ABI. + +Include files in here should check that _CFE_CORE_ is defined to prevent +accidental usage by external entities. + + diff --git a/src/components/interface/cFE/private/cfe_es_erlog_typedef.h b/src/components/interface/cFE/private/cfe_es_erlog_typedef.h new file mode 100644 index 0000000000..b848c37fec --- /dev/null +++ b/src/components/interface/cFE/private/cfe_es_erlog_typedef.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2004-2015, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Glenn + * Research Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + */ + +/** + * \file cfe_es_erlog_typedef.h + * + * Created on: Jan 22, 2015 + * Author: joseph.p.hickey@nasa.gov + * + * Definition of the CFE_ES_ERLog structure type. + * This was moved into its own header file since it is referenced by multiple CFE core apps. + */ + +#ifndef CFE_ES_ERLOG_TYPEDEF_H_ +#define CFE_ES_ERLOG_TYPEDEF_H_ + +#include +#include /* Needed for CFE_TIME_SysTime_t */ + +/* +** Debug variables type +*/ +typedef struct +{ + uint32 DebugFlag; + uint32 WatchdogWriteFlag; + uint32 PrintfEnabledFlag; + uint32 LastAppId; + +} CFE_ES_DebugVariables_t; + +/* +** Exception and Reset Log Structure +*/ +typedef struct +{ + uint32 LogEntryType; /* What type of log entry */ + uint32 ResetType; /* Main cause for the reset */ + uint32 ResetSubtype; /* The sub-type for the reset */ + uint32 BootSource; /* The boot source */ + uint32 ProcessorResetCount; /* The number of processor resets */ + uint32 MaxProcessorResetCount; /* The maximum number before a Power On */ + CFE_ES_DebugVariables_t DebugVars; /* ES Debug variables */ + CFE_TIME_SysTime_t TimeCode; /* Time code */ + char Description[80]; /* The ascii data for the event */ + uint32 ContextSize; /* Indicates the context data is valid */ + uint32 AppID; /* The application ID */ + uint32 Context[CFE_ES_ER_LOG_MAX_CONTEXT_SIZE / sizeof(uint32)]; /* cpu context */ +} CFE_ES_ERLog_t; + + + +#endif /* CFE_ES_ERLOG_TYPEDEF_H_ */ diff --git a/src/components/interface/cFE/private/cfe_es_perfdata_typedef.h b/src/components/interface/cFE/private/cfe_es_perfdata_typedef.h new file mode 100644 index 0000000000..15344908d5 --- /dev/null +++ b/src/components/interface/cFE/private/cfe_es_perfdata_typedef.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2004-2015, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Glenn + * Research Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + */ + +/** + * \file cfe_es_perfdata_typedef.h + * + * Created on: Jan 22, 2015 + * Author: joseph.p.hickey@nasa.gov + * + * Placeholder for file content description + */ + +#ifndef CFE_ES_PERFDATA_TYPEDEF_H_ +#define CFE_ES_PERFDATA_TYPEDEF_H_ + +#include +#include "cfe_platform_cfg.h" /* Required for CFE_ES_PERF_MAX_IDS */ + +#define CFE_ES_PERF_32BIT_WORDS_IN_MASK ((CFE_ES_PERF_MAX_IDS) / 32) + + +typedef struct { + uint32 Data; + uint32 TimerUpper32; /* TBU - timebase register */ + uint32 TimerLower32; /* TBL - timebase register */ +} CFE_ES_PerfDataEntry_t; + +typedef struct { + uint8 Version; + uint8 Endian; + uint8 Spare[2]; + uint32 TimerTicksPerSecond; + uint32 TimerLow32Rollover; + uint32 State; + uint32 Mode; + uint32 TriggerCount; + uint32 DataStart; + uint32 DataEnd; + uint32 DataCount; + uint32 InvalidMarkerReported; + uint32 FilterTriggerMaskSize; + uint32 FilterMask[CFE_ES_PERF_32BIT_WORDS_IN_MASK]; + uint32 TriggerMask[CFE_ES_PERF_32BIT_WORDS_IN_MASK]; +} CFE_ES_PerfMetaData_t; + +typedef struct { + CFE_ES_PerfMetaData_t MetaData; + CFE_ES_PerfDataEntry_t DataBuffer[CFE_ES_PERF_DATA_BUFFER_SIZE]; +} CFE_ES_PerfData_t; + + + +#endif /* CFE_ES_PERFDATA_TYPEDEF_H_ */ diff --git a/src/components/interface/cFE/private/cfe_es_resetdata_typedef.h b/src/components/interface/cFE/private/cfe_es_resetdata_typedef.h new file mode 100644 index 0000000000..297cb6dfae --- /dev/null +++ b/src/components/interface/cFE/private/cfe_es_resetdata_typedef.h @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2004-2015, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Glenn + * Research Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + */ + +/** + * \file cfe_es_resetdata_typedef.h + * + * Created on: Jan 22, 2015 + * Author: joseph.p.hickey@nasa.gov + * + * Definition of the CFE_ES_ResetData structure type. + * This was moved into its own header file since it is referenced by multiple CFE core apps. + */ + +#ifndef CFE_ES_RESETDATA_TYPEDEF_H_ +#define CFE_ES_RESETDATA_TYPEDEF_H_ + +#include + +#include /* Required for CFE_TIME_ResetVars_t definition */ +#include "cfe_es_erlog_typedef.h" /* Required for CFE_ES_ERLog_t definition */ +#include "cfe_es_perfdata_typedef.h" /* Required for CFE_ES_PerfData_t definition */ +#include "cfe_evs_log_typedef.h" /* Required for CFE_EVS_Log_t definition */ +#include "cfe_platform_cfg.h" /* CFE_EVS_LOG_ON, CFE_ES_ER_LOG_ENTRIES, CFE_ES_SYSTEM_LOG_SIZE */ + +/* +** Reset Variables type +*/ +typedef struct +{ + uint32 ResetType; + uint32 ResetSubtype; + uint32 BootSource; + uint32 ES_CausedReset; + uint32 ProcessorResetCount; + uint32 MaxProcessorResetCount; +} CFE_ES_ResetVariables_t; + + +/* +** Executive Services Global Reset Data type +** This is the special memory area for ES that is preserved +** on a processor reset. +*/ +typedef struct +{ + /* + ** Exception and Reset log declaration + */ + CFE_ES_ERLog_t ERLog[CFE_ES_ER_LOG_ENTRIES]; + uint32 ERLogIndex; + uint32 ERLogEntries; + uint32 LastAppId; + + /* + ** System Log declaration + */ + char SystemLog[CFE_ES_SYSTEM_LOG_SIZE]; + uint32 SystemLogIndex; + uint32 SystemLogMode; + uint32 SystemLogEntryNum; + + /* + ** Performance Data + */ + CFE_ES_PerfData_t Perf; + + /* + ** Reset Variables + */ + CFE_ES_ResetVariables_t ResetVars; + + /* + ** Time variables that are + ** preserved on a processor reset + */ + CFE_TIME_ResetVars_t TimeResetVars; + +#ifdef CFE_EVS_LOG_ON + /* + ** EVS Log and associated variables. This needs to be preserved on a processor reset. + */ + CFE_EVS_Log_t EVS_Log; +#endif + +} CFE_ES_ResetData_t; + + + +#endif /* CFE_ES_RESETDATA_TYPEDEF_H_ */ diff --git a/src/components/interface/cFE/private/cfe_evs_log_typedef.h b/src/components/interface/cFE/private/cfe_evs_log_typedef.h new file mode 100644 index 0000000000..6c7c6e5d44 --- /dev/null +++ b/src/components/interface/cFE/private/cfe_evs_log_typedef.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2004-2015, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Glenn + * Research Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + */ + +/** + * \file cfe_evs_log_typedef.h + * + * Created on: Jan 22, 2015 + * Author: joseph.p.hickey@nasa.gov + * + * Definition of the CFE_EVS_Log structure type. + * This was moved into its own header file since it is referenced by multiple CFE core apps. + */ + +#ifndef CFE_EVS_LOG_TYPEDEF_H_ +#define CFE_EVS_LOG_TYPEDEF_H_ + +#include +#include "cfe_evs_msg.h" /* Required for CFE_EVS_Packet_t definition */ + +/* +** \brief EVS Log type definition. This is declared here so ES can include it +** in the reset area structure +*/ +typedef struct { + uint16 Next; /**< \brief Index of the next entry in the local event log */ + uint16 LogCount; /**< \brief Local Event Kog counter */ + uint8 LogFullFlag; /**< \brief Local Event Log full flag */ + uint8 LogMode; /**< \brief Local Event Logging mode (overwrite/discard) */ + uint16 LogOverflowCounter; /**< \brief Local Event Log overflow counter */ + CFE_EVS_Packet_t LogEntry[CFE_EVS_LOG_MAX];/**< \brief The actual Local Event Log entry */ + +} CFE_EVS_Log_t; + + + +#endif /* CFE_EVS_LOG_TYPEDEF_H_ */ diff --git a/src/components/interface/cFE/private/cfe_private.h b/src/components/interface/cFE/private/cfe_private.h new file mode 100644 index 0000000000..c1cc0cf114 --- /dev/null +++ b/src/components/interface/cFE/private/cfe_private.h @@ -0,0 +1,319 @@ +/* + * cfe_private.h + * + * Created on: Dec 3, 2013 + * Author: jphickey + */ + +#ifndef CFE_PRIVATE_H_ +#define CFE_PRIVATE_H_ + +#include "common_types.h" +#include "cfe.h" + +#include "cfe_platform_cfg.h" /* Define platform configuration parameters */ + + +/*****************************************************************************/ +/** cFE Core task entry point prototypes *************************************/ +/*****************************************************************************/ +/* + * All cFE core apps should define an entry point and the prototype should be here + * These may also be called from the unit test + */ + +/*****************************************************************************/ +/** +** \brief Entry Point for cFE Core Application +** +** \par Description +** This is the entry point to the cFE TIME Core Application. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \retval None +******************************************************************************/ +extern void CFE_TIME_TaskMain(void); + +/*****************************************************************************/ +/** +** \brief Entry Point for cFE Core Application +** +** \par Description +** This is the entry point to the cFE SB Core Application. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \retval None +******************************************************************************/ +extern void CFE_SB_TaskMain(void); + +/*****************************************************************************/ +/** +** \brief Entry Point for cFE Core Application +** +** \par Description +** This is the entry point to the cFE EVS Core Application. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \retval None +******************************************************************************/ +extern void CFE_EVS_TaskMain(void); + +/*****************************************************************************/ +/** +** \brief Entry Point for cFE Core Application +** +** \par Description +** This is the entry point to the cFE ES Core Application. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \retval None +******************************************************************************/ +extern void CFE_ES_TaskMain(void); + +/*****************************************************************************/ +/** +** \brief Entry Point for cFE Table Services Core Application +** +** \par Description +** This is the entry point to the cFE Table Services Core Application. +** This Application provides the ground interface to the cFE Table +** Services. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \retval None +******************************************************************************/ +extern void CFE_TBL_TaskMain(void); + + + + +/*****************************************************************************/ +/** cFE Core task early init prototypes **************************************/ +/*****************************************************************************/ +/* + * cFE core apps may define an early init function and the prototype should be here + * These may also be called from the unit test + */ + +/*****************************************************************************/ +/** +** \brief Initializes the cFE core module API Library +** +** \par Description +** Initializes the cFE core module API Library +** +** \par Assumptions, External Events, and Notes: +** -# This function MUST be called before any module API's are called. +** +******************************************************************************/ +extern int32 CFE_EVS_EarlyInit(void); + +/*****************************************************************************/ +/** +** \brief Initializes the cFE core module API Library +** +** \par Description +** Initializes the cFE core module API Library +** +** \par Assumptions, External Events, and Notes: +** -# This function MUST be called before any module API's are called. +** +******************************************************************************/ +extern int32 CFE_SB_EarlyInit(void); + +/*****************************************************************************/ +/** +** \brief Initializes the cFE core module API Library +** +** \par Description +** Initializes the cFE core module API Library +** +** \par Assumptions, External Events, and Notes: +** -# This function MUST be called before any module API's are called. +** +******************************************************************************/ +extern int32 CFE_TIME_EarlyInit(void); + +/*****************************************************************************/ +/** +** \brief Initializes the Table Services API Library +** +** \par Description +** Initializes the Table Services API Library +** +** \par Assumptions, External Events, and Notes: +** -# This function MUST be called before any TBL API's are called. +** +******************************************************************************/ +extern int32 CFE_TBL_EarlyInit(void); + +/*****************************************************************************/ +/** +** \brief Initializes the cFE core module API Library +** +** \par Description +** Initializes the cFE core module API Library +** +** \par Assumptions, External Events, and Notes: +** -# This function MUST be called before any module API's are called. +** +******************************************************************************/ +extern int32 CFE_ES_CDS_EarlyInit(void); + +/*****************************************************************************/ +/** +** \brief Initializes the cFE core module API Library +** +** \par Description +** Initializes the cFE core module API Library +** +** \par Assumptions, External Events, and Notes: +** -# This function MUST be called before any module API's are called. +** +******************************************************************************/ +extern int32 CFE_FS_EarlyInit(void); + + + +/*****************************************************************************/ +/** cFE Core task clean up prototypes ****************************************/ +/*****************************************************************************/ +/* + * cFE core apps may define a clean up function and the prototype should be here + * These may also be called from the unit test + */ +/*****************************************************************************/ +/** +** \brief Removes TBL resources associated with specified Application +** +** \par Description +** This function is called by cFE Executive Services to cleanup after +** an Application has been terminated. It frees TBL services resources +** that have been allocated to the specified Application. +** +** \par Assumptions, External Events, and Notes: +** -# This function DOES NOT remove any critical tables associated with +** the specified application from the Critical Data Store. +** +******************************************************************************/ +extern int32 CFE_TBL_CleanUpApp(uint32 AppId); + +/*****************************************************************************/ +/** +** \brief Removes SB resources associated with specified Application +** +** \par Description +** This function is called by cFE Executive Services to cleanup after +** an Application has been terminated. It frees resources +** that have been allocated to the specified Application. +** +******************************************************************************/ +extern int32 CFE_SB_CleanUpApp(uint32 AppId); + +/*****************************************************************************/ +/** +** \brief Removes EVS resources associated with specified Application +** +** \par Description +** This function is called by cFE Executive Services to cleanup after +** an Application has been terminated. It frees resources +** that have been allocated to the specified Application. +** +******************************************************************************/ +extern int32 CFE_EVS_CleanUpApp(uint32 AppId); + +/*****************************************************************************/ +/** +** \brief Removes TIME resources associated with specified Application +** +** \par Description +** This function is called by cFE Executive Services to cleanup after +** an Application has been terminated. It frees resources +** that have been allocated to the specified Application. +** +******************************************************************************/ +extern int32 CFE_TIME_CleanUpApp(uint32 AppId); + + +/*****************************************************************************/ +/** cFE Core task other function call prototypes *****************************/ +/*****************************************************************************/ +/* + * Functions that are used in a cFE core module other than the module that + * actually defines the function should be prototyped here. + * + * Including the prototype here allows the function to be called properly + * without redefining it at the point of use. + */ + +/*****************************************************************************/ +/** +** \brief Reserve space (or re-obtain previously reserved space) in the Critical Data Store (CDS) +** +** \par Description +** This routine is identical to #CFE_ES_RegisterCDS except it identifies the contents +** of the CDS as a critical table. This is crucial because a critical table CDS must +** only be deleted by cFE Table Services, not via an ES delete CDS command. Otherwise, +** Table Services may be out of sync with the contents of the CDS. +** +** \par Assumptions, External Events, and Notes: +** -# This function assumes input parameters are error free and have met size/value restrictions. +** -# The calling function is responsible for issuing any event messages associated with errors. +** +** \param[in] HandlePtr Pointer Application's variable that will contain the CDS Memory Block Handle. +** +** \param[in] BlockSize The number of bytes needed in the CDS. +** +** \param[in] Name Pointer to character string containing the Application's local name for +** the CDS. +** +** \param[in] CriticalTbl Indicates whether the CDS is to be used as a Critical Table or not +** +** \param[out] *HandlePtr The handle of the CDS block that can be used in #CFE_ES_CopyToCDS and #CFE_ES_RestoreFromCDS. +** +** \return See return codes for #CFE_ES_RegisterCDS +** +******************************************************************************/ +int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, int32 BlockSize, const char *Name, boolean CriticalTbl); + +/*****************************************************************************/ +/** +** \brief Deletes the specified CDS from the CDS Registry and frees CDS Memory +** +** \par Description +** Removes the record of the specified CDS from the CDS Registry and +** frees the associated CDS memory for future use. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] CDSName - Pointer to character string containing complete +** CDS Name (of the format "AppName.CDSName"). +** +** \param[in] CalledByTblServices - Flag that identifies whether the CDS is supposed to +** be a Critical Table Image or not. +** +** \return #CFE_SUCCESS \copydoc CFE_SUCCESS +** \return #CFE_ES_CDS_WRONG_TYPE_ERR \copydoc CFE_ES_CDS_WRONG_TYPE_ERR +** \return #CFE_ES_CDS_OWNER_ACTIVE_ERR \copydoc CFE_ES_CDS_OWNER_ACTIVE_ERR +** \return #CFE_ES_CDS_NOT_FOUND_ERR \copydoc CFE_ES_CDS_NOT_FOUND_ERR +** \return Any of the return values from #CFE_ES_UpdateCDSRegistry +** \return Any of the return values from #CFE_ES_PutCDSBlock +** +******************************************************************************/ +int32 CFE_ES_DeleteCDS(const char *CDSName, boolean CalledByTblServices); + + + + +#endif /* CFE_PRIVATE_H_ */ diff --git a/src/components/interface/cFE/psp_version.h b/src/components/interface/cFE/psp_version.h new file mode 100644 index 0000000000..10c2eb4201 --- /dev/null +++ b/src/components/interface/cFE/psp_version.h @@ -0,0 +1,44 @@ +/* +** $Id: psp_version.h 1.2.2.3 2014/10/01 15:41:26GMT-05:00 sstrege Exp $ +** +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** +** +** Purpose: +** Provide version identifiers for the cFE Platform Support Packages (PSP). +** +*/ + +#ifndef _psp_version_ +#define _psp_version_ + + +/* +** Macro Definitions +*/ +#define CFE_PSP_IMPL_MAJOR_VERSION 1 +#define CFE_PSP_IMPL_MINOR_VERSION 3 +#define CFE_PSP_IMPL_REVISION 0 +#define CFE_PSP_IMPL_MISSION_REV 0 + +#ifndef _ENHANCED_BUILD_ + +#define CFE_PSP_MAJOR_VERSION CFE_PSP_IMPL_MAJOR_VERSION +#define CFE_PSP_MINOR_VERSION CFE_PSP_IMPL_MINOR_VERSION +#define CFE_PSP_REVISION CFE_PSP_IMPL_REVISION +#define CFE_PSP_MISSION_REV CFE_PSP_IMPL_MISSION_REV + +/* For backwards compatibility */ +#define CFE_PSP_SUBMINOR_VERSION CFE_PSP_IMPL_REVISION + +#endif + +#endif /* _psp_version_ */ + diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S new file mode 100644 index 0000000000..ef5e41acd2 --- /dev/null +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -0,0 +1,35 @@ +/** + * Copyright 2009 by Gabriel Parmer, gabep1@cs.bu.edu + * + * Redistribution of this file is permitted under the GNU General + * Public License v2. + */ + +//#include +#include + +.text + +cos_asm_server_stub(OS_printf) +cos_asm_server_stub(OS_TaskInstallDeleteHandler) +cos_asm_server_stub(OS_TaskDelay) + + +cos_asm_server_stub(CFE_ES_ExitApp) +cos_asm_server_stub(CFE_ES_PerfLogAdd) +cos_asm_server_stub(CFE_ES_RegisterApp) +cos_asm_server_stub(CFE_EVS_Register) +cos_asm_server_stub(CFE_EVS_SendEvent) +cos_asm_server_stub(CFE_SB_CreatePipe) +cos_asm_server_stub(CFE_SB_GetCmdCode) +cos_asm_server_stub(CFE_SB_GetMsgId) +cos_asm_server_stub(CFE_SB_GetTotalMsgLength) +cos_asm_server_stub(CFE_SB_RcvMsg) +cos_asm_server_stub(CFE_SB_SendMsg) +cos_asm_server_stub(CFE_SB_Subscribe) +cos_asm_server_stub(CFE_SB_TimeStampMsg) +cos_asm_server_stub(CFE_ES_RunLoop) +cos_asm_server_stub(CFE_SB_InitMsg) +cos_asm_server_stub(CFE_SB_MessageStringGet) +cos_asm_server_stub(CFE_SB_SubscribeEx) +cos_asm_server_stub(CFE_SB_Unsubscribe) diff --git a/src/components/lib/cos_kernel_api.c b/src/components/lib/cos_kernel_api.c index 960c076a7e..8a4da8a9b7 100644 --- a/src/components/lib/cos_kernel_api.c +++ b/src/components/lib/cos_kernel_api.c @@ -3,16 +3,16 @@ * * This uses a two clause BSD License. */ + #include + #include #include #include -#include +#include -#include -#include +#include #ifdef NIL -#include #define printd(...) printc(__VA_ARGS__) #else #define printd(...) @@ -280,6 +280,8 @@ __capid_bump_alloc(struct cos_compinfo *ci, cap_t cap) static pgtblcap_t __bump_mem_expand_intern(struct cos_compinfo *ci, pgtblcap_t cipgtbl, vaddr_t mem_ptr, pgtblcap_t intern) { + printc("__bump_mem_expand_intern(%p, %lu, %p, %lu)\n", ci, cipgtbl, (void *) mem_ptr, intern); + struct cos_compinfo *meta = __compinfo_metacap(ci); capid_t pte_cap; vaddr_t ptemem_cap; @@ -289,6 +291,7 @@ __bump_mem_expand_intern(struct cos_compinfo *ci, pgtblcap_t cipgtbl, vaddr_t me if (!intern) { pte_cap = __capid_bump_alloc(meta, CAP_PGTBL); ptemem_cap = __kmem_bump_alloc(meta); + printc("pte_cap = %d, ptemem_cap = %p\n", (int) pte_cap, (void *) ptemem_cap); /* TODO: handle the case of running out of memory */ if (pte_cap == 0 || ptemem_cap == 0) return 0; @@ -302,8 +305,10 @@ __bump_mem_expand_intern(struct cos_compinfo *ci, pgtblcap_t cipgtbl, vaddr_t me pte_cap = intern; } + int res = call_cap_op(cipgtbl, CAPTBL_OP_CONS, pte_cap, mem_ptr, 0, 0); + printc("call_cap_op(%lu, %d, %lu, %p) = %d\n", cipgtbl, CAPTBL_OP_CONS, pte_cap, (void *) mem_ptr, res); /* Construct pgtbl */ - if (call_cap_op(cipgtbl, CAPTBL_OP_CONS, pte_cap, mem_ptr, 0, 0)) { + if (res) { assert(0); /* race? */ return 0; } @@ -314,9 +319,11 @@ __bump_mem_expand_intern(struct cos_compinfo *ci, pgtblcap_t cipgtbl, vaddr_t me static vaddr_t __bump_mem_expand_range(struct cos_compinfo *ci, pgtblcap_t cipgtbl, vaddr_t mem_ptr, unsigned long mem_sz) { + printc("__bump_mem_expand_range(%p, %lu, %p, %lu)\n", ci, cipgtbl, (void *) mem_ptr, mem_sz); vaddr_t addr; for (addr = mem_ptr ; addr < mem_ptr + mem_sz ; addr += PGD_RANGE) { + printc("addr = %p\n", (void *) addr); /* ignore errors likely due to races here as we want to keep expanding regardless */ __bump_mem_expand_intern(ci, cipgtbl, addr, 0); } From 6caddb5e50470993ed39b6e7d94a29b75ec99f8f Mon Sep 17 00:00:00 2001 From: Zach Day Date: Fri, 25 Aug 2017 15:56:43 -0400 Subject: [PATCH 078/122] Refine app loading in `osloader` A selection of sample apps are compiled with the cFE. `osloader` loads those apps and links their undefined functions via the functions previously made to `llbooter`. Currently, the app being run (`sample_app`) does not actually perform any of its desired functionality. This could be caused by one of several bugs: * `qemu` could be dropping timer interrupts, which are relied upon by the scheduler * A possible bug in the scheduler * A flaw in one of our other implementations of cFE primitives --- .../no_interface/cFE_booter/osloader.c | 30 ++++++++++++++----- .../no_interface/sch_lab/Makefile | 10 +++++++ src/platform/i386/runscripts/cFE_booter.sh | 3 +- 3 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 src/components/implementation/no_interface/sch_lab/Makefile diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index 3648ff5a40..d80d1f6f9c 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -7,10 +7,11 @@ #include "gen/osapi.h" #include "gen/common_types.h" +#include "gen/cfe_es.h" +#include "gen/cfe_evs.h" #define USER_CAPS_SYMB_NAME "ST_user_caps" - int cobj_count; struct cobj_header *hs[MAX_NUM_SPDS+1]; @@ -102,6 +103,26 @@ struct symbol_of_jank { struct symbol_of_jank soj[] = { { .name = "OS_printf", .fn = OS_printf }, + { .name = "OS_TaskInstallDeleteHandler", .fn = OS_TaskInstallDeleteHandler }, + { .name = "OS_TaskDelay", .fn = OS_TaskDelay }, + { .name = "CFE_ES_ExitApp", .fn = CFE_ES_ExitApp }, + { .name = "CFE_ES_PerfLogAdd", .fn = CFE_ES_PerfLogAdd }, + { .name = "CFE_ES_RegisterApp", .fn = CFE_ES_RegisterApp }, + { .name = "CFE_EVS_Register", .fn = CFE_EVS_Register }, + { .name = "CFE_EVS_SendEvent", .fn = CFE_EVS_SendEvent }, + { .name = "CFE_SB_CreatePipe", .fn = CFE_SB_CreatePipe }, + { .name = "CFE_SB_GetCmdCode", .fn = CFE_SB_GetCmdCode }, + { .name = "CFE_SB_GetMsgId", .fn = CFE_SB_GetMsgId }, + { .name = "CFE_SB_GetTotalMsgLength", .fn = CFE_SB_GetTotalMsgLength }, + { .name = "CFE_SB_RcvMsg", .fn = CFE_SB_RcvMsg }, + { .name = "CFE_SB_SendMsg", .fn = CFE_SB_SendMsg }, + { .name = "CFE_SB_Subscribe", .fn = CFE_SB_Subscribe }, + { .name = "CFE_SB_TimeStampMsg", .fn = CFE_SB_TimeStampMsg }, + { .name = "CFE_ES_RunLoop", .fn = CFE_ES_RunLoop }, + { .name = "CFE_SB_InitMsg", .fn = CFE_SB_InitMsg }, + { .name = "CFE_SB_MessageStringGet", .fn = CFE_SB_MessageStringGet }, + { .name = "CFE_SB_SubscribeEx", .fn = CFE_SB_SubscribeEx }, + { .name = "CFE_SB_Unsubscribe", .fn = CFE_SB_Unsubscribe }, { .name = "", .fn = NULL }, }; @@ -573,13 +594,6 @@ int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) cpuaddr addr = search_cobj_for_symbol(module_table[i].header, symbol_name); if (addr != 0) { printc("osloader: found cobj symbol for %s, address %p\n", symbol_name, (void *) addr); - size_t j; - printc("[ "); - for(j = 0; j < 1000; j++) - { - printc("%02x ", ((char *) addr)[j]); - } - printc("]\n"); *symbol_address = addr; return OS_SUCCESS; } diff --git a/src/components/implementation/no_interface/sch_lab/Makefile b/src/components/implementation/no_interface/sch_lab/Makefile new file mode 100644 index 0000000000..e804696fd2 --- /dev/null +++ b/src/components/implementation/no_interface/sch_lab/Makefile @@ -0,0 +1,10 @@ +# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c +ASM_OBJS= +COMPONENT=sch_lab.o +INTERFACES= +DEPENDENCIES=cFE +IF_LIB:=./cFE_sch_lab_app.o +ADDITIONAL_LIBS= + +include ../../Makefile.subsubdir +MANDITORY_LIB=simple_stklib.o diff --git a/src/platform/i386/runscripts/cFE_booter.sh b/src/platform/i386/runscripts/cFE_booter.sh index 6d6ea8dd9d..c21523e47c 100644 --- a/src/platform/i386/runscripts/cFE_booter.sh +++ b/src/platform/i386/runscripts/cFE_booter.sh @@ -1,5 +1,4 @@ #!/bin/sh cp cFE_booter.o llboot.o -./cos_linker "llboot.o, ;test_boot.o, :" ./gen_client_stub - +./cos_linker 'llboot.o, ;sample_lib.o, ;sample_app.o, ;to_lab.o, ;ci_lab.o, ;sch_lab.o, :sample_app.o-llboot.o;sample_lib.o-llboot.o;to_lab.o-llboot.o;ci_lab.o-llboot.o;sch_lab.o-llboot.o' ./gen_client_stub From 06b7f8f7fa4af4cbb8ec5c3c090668505cc6d5be Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 28 Aug 2017 15:47:53 -0400 Subject: [PATCH 079/122] Add diagnostic information, and add queue waiting hack --- .../no_interface/cFE_booter/osapi.c | 2 + .../no_interface/cFE_booter/osqueue.c | 46 ++++++++++++------- .../no_interface/cFE_booter/ostask.c | 17 ++++++- .../no_interface/cFE_booter/sl_mod_fprr.c | 12 +++++ 4 files changed, 58 insertions(+), 19 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 6bfd7b4560..3744b716d7 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -100,6 +100,7 @@ OS_time_t local_time; microsec_t last_time_check; OS_time_t OS_AdvanceTime(OS_time_t initial_time, microsec_t usec) { + printc("Advancing time\n"); microsec_t old_seconds = (microsec_t) initial_time.seconds; microsec_t old_additional_usec = (microsec_t) initial_time.microsecs; @@ -108,6 +109,7 @@ OS_time_t OS_AdvanceTime(OS_time_t initial_time, microsec_t usec) { microsec_t new_seconds = new_usec / (1000 * 1000); microsec_t new_additional_usec = new_usec % (1000 * 1000); + printc("Done advancing time!\n"); return (OS_time_t) { .seconds = new_seconds, diff --git a/src/components/implementation/no_interface/cFE_booter/osqueue.c b/src/components/implementation/no_interface/cFE_booter/osqueue.c index eb42bda053..a75817fe98 100644 --- a/src/components/implementation/no_interface/cFE_booter/osqueue.c +++ b/src/components/implementation/no_interface/cFE_booter/osqueue.c @@ -3,6 +3,8 @@ #include "gen/common_types.h" #include "gen/osapi.h" +#include + #include #undef OS_MAX_QUEUES @@ -118,29 +120,39 @@ OS_QueueGet(uint32 queue_id, void* data, uint32 size, uint32* size_copied, int32 return OS_INVALID_POINTER; } - // Check if there are messages to be received. - if (queues[queue_id].head == queues[queue_id].tail) { - return OS_QUEUE_EMPTY; - } + int32 intervals = timeout / 50 + 1; + int32 inter = 0; + int result = OS_ERROR; + for (inter = 0; inter < intervals; inter++) { + OS_TaskDelay(50); + // Check if there are messages to be received. + if (queues[queue_id].head == queues[queue_id].tail) { + result = OS_QUEUE_EMPTY; + continue; + } - // TODO: Implement logic for returning OS_QUEUE_TIMEOUT (waiting on mutex implementation). + // TODO: Implement logic for returning OS_QUEUE_TIMEOUT (waiting on mutex implementation). - if (size < queues[queue_id].data_size) { - return OS_QUEUE_INVALID_SIZE; - } + if (size < queues[queue_id].data_size) { + result = OS_QUEUE_INVALID_SIZE; + continue; + } - // A helper reference to the currently selected queue. - struct queue* cur = &queues[queue_id]; + // A helper reference to the currently selected queue. + struct queue* cur = &queues[queue_id]; - // Walk through the bytes at the head of the queue and write them to buffer `data`. - for (i = 0; i < size; i++) { - *((char*)data + i) = queue_data[queue_id][cur->head * cur->data_size + i]; - } + // Walk through the bytes at the head of the queue and write them to buffer `data`. + for (i = 0; i < size; i++) { + *((char*)data + i) = queue_data[queue_id][cur->head * cur->data_size + i]; + } - // Advance the queue head, wrapping if it is passed `depth`. - cur->head = (cur->head + 1) % cur->depth; + // Advance the queue head, wrapping if it is passed `depth`. + cur->head = (cur->head + 1) % cur->depth; - return OS_SUCCESS; + return OS_SUCCESS; + } + assert(result != OS_ERROR); + return result; } /* diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index b59dd94b11..92f52fc013 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -14,16 +14,22 @@ ** Internal Task helper functions */ // We need to keep track of this to check if register or delete handler calls are invalid +#define MAIN_DELEGATE_THREAD_PRIORITY 1 thdid_t main_delegate_thread_id; void OS_SchedulerStart(cos_thd_fn_t main_delegate) { sl_init(); struct sl_thd* main_delegate_thread = sl_thd_alloc(main_delegate, NULL); - union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = 255}}; + union sched_param sp = {.c = {.type = SCHEDP_PRIO, .value = MAIN_DELEGATE_THREAD_PRIORITY}}; sl_thd_param_set(main_delegate_thread, sp.v); main_delegate_thread_id = main_delegate_thread->thdid; + struct sl_thd_policy* policy = sl_mod_thd_policy_get(main_delegate_thread); + strcpy(policy->osal_task_prop.name, "MAIN_THREAD"); + policy->osal_task_prop.priority = MAIN_DELEGATE_THREAD_PRIORITY; + policy->osal_task_prop.OStask_id = (uint32) main_delegate_thread->thdid; + sl_sched_loop(); } @@ -67,11 +73,11 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, uint32 priority, uint32 flags) { // TODO: Verify that we don't need to take the cs here - // Stack pointers can sometimes be null and that's ok for us if(task_id == NULL || task_name == NULL || function_pointer == NULL){ return OS_INVALID_POINTER; } + printc("ostask: Attempting to create task %s, priority %d\n", task_name, (int) priority); // Validate the name if(!is_valid_name(task_name)) { @@ -100,6 +106,8 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, *task_id = (uint32) thd->thdid; + printc("ostask: Created task %s, thdid %d!\n", task_name, (int) thd->thdid); + return OS_SUCCESS; } @@ -145,6 +153,7 @@ int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer) int32 OS_TaskDelay(uint32 millisecond) { + // printc("ostask: Delaying task by %d milliseconds\n", (int) millisecond); cycles_t wakeup = sl_now() + sl_usec2cyc(millisecond * 1000); sl_thd_block_timeout(0, wakeup); return OS_SUCCESS; @@ -501,6 +510,8 @@ int32 OS_SemaphoreGive(struct semaphore* semaphores, uint32 max_semaphores, uint goto exit; } + printc("ostask: Giving semaphore %s!\n", semaphores[sem_id].name); + // FIXME: Add some checks that the semaphore was actually taken by this thread semaphores[sem_id].count += 1; @@ -523,6 +534,8 @@ int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint int starting_epoch = semaphores[sem_id].epoch; + printc("ostask: Taking semaphore %s!\n", semaphores[sem_id].name); + while (semaphores[sem_id].used && semaphores[sem_id].count == 0) { if(semaphores[sem_id].epoch != starting_epoch) { goto exit; diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c index 4720528ca1..869b145dca 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c +++ b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c @@ -16,6 +16,8 @@ void sl_mod_execution(struct sl_thd_policy *t, cycles_t cycles) { } + +volatile int count = 0; struct sl_thd_policy * sl_mod_schedule(void) { @@ -26,9 +28,19 @@ sl_mod_schedule(void) if (ps_list_head_empty(&threads[i])) continue; t = ps_list_head_first_d(&threads[i], struct sl_thd_policy); + if (count % 2017 == 0) { + printc("Scheduling thread %s, thdid %d\n", t->osal_task_prop.name, (int) t->thd.thdid); + } + count++; + return t; } + if (count % 200 == 0) { + printc("Scheduling nothing...\n"); + } + count++; + return NULL; } From 497f0ebeb993bd30888896371643d25f54a354c5 Mon Sep 17 00:00:00 2001 From: Zach Day Date: Mon, 28 Aug 2017 17:07:52 -0400 Subject: [PATCH 080/122] Add locking to `OS_QueueGet` `osqueue.c` declares a mutex for it to use when getting from a queue, preventing data races. --- .../no_interface/cFE_booter/osqueue.c | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osqueue.c b/src/components/implementation/no_interface/cFE_booter/osqueue.c index a75817fe98..1248350e14 100644 --- a/src/components/implementation/no_interface/cFE_booter/osqueue.c +++ b/src/components/implementation/no_interface/cFE_booter/osqueue.c @@ -5,6 +5,8 @@ #include +#include + #include #undef OS_MAX_QUEUES @@ -12,6 +14,8 @@ #define MAX_QUEUE_DATA_SIZE (1024 * 1024) +struct sl_lock queue_lock = SL_LOCK_STATIC_INIT(); + // The main queue data structure. struct queue { // Whether or not the index of this queue is already taken. @@ -109,20 +113,25 @@ int32 OS_QueueGet(uint32 queue_id, void* data, uint32 size, uint32* size_copied, int32 timeout) { uint32 i; + int result = OS_ERROR; + + sl_lock_take(queue_lock); // Check if the requested queue exists. if (queue_id > OS_MAX_QUEUES || queues[queue_id].used == FALSE) { - return OS_ERR_INVALID_ID; + result = OS_ERR_INVALID_ID; + goto exit; } // Check for a NULL pointer. if (data == NULL || size_copied == NULL) { - return OS_INVALID_POINTER; + result = OS_INVALID_POINTER; + goto exit; } + /* FIXME: Block instead of poll */ int32 intervals = timeout / 50 + 1; int32 inter = 0; - int result = OS_ERROR; for (inter = 0; inter < intervals; inter++) { OS_TaskDelay(50); // Check if there are messages to be received. @@ -149,9 +158,13 @@ OS_QueueGet(uint32 queue_id, void* data, uint32 size, uint32* size_copied, int32 // Advance the queue head, wrapping if it is passed `depth`. cur->head = (cur->head + 1) % cur->depth; - return OS_SUCCESS; + result = OS_SUCCESS; + goto exit; } assert(result != OS_ERROR); + +exit: + sl_lock_release(queue_lock); return result; } From a5d45cb62268511bd3f99987018bf05aabd70b59 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sun, 3 Sep 2017 18:35:13 -0400 Subject: [PATCH 081/122] Fix timeout handling in OS_QueueCreate --- .../no_interface/cFE_booter/osqueue.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osqueue.c b/src/components/implementation/no_interface/cFE_booter/osqueue.c index 1248350e14..38b57821b5 100644 --- a/src/components/implementation/no_interface/cFE_booter/osqueue.c +++ b/src/components/implementation/no_interface/cFE_booter/osqueue.c @@ -115,7 +115,7 @@ OS_QueueGet(uint32 queue_id, void* data, uint32 size, uint32* size_copied, int32 uint32 i; int result = OS_ERROR; - sl_lock_take(queue_lock); + sl_lock_take(&queue_lock); // Check if the requested queue exists. if (queue_id > OS_MAX_QUEUES || queues[queue_id].used == FALSE) { @@ -130,10 +130,19 @@ OS_QueueGet(uint32 queue_id, void* data, uint32 size, uint32* size_copied, int32 } /* FIXME: Block instead of poll */ - int32 intervals = timeout / 50 + 1; + int32 intervals; + if (timeout == OS_CHECK) { + intervals = 0; + } else if (timeout == OS_PEND) { + intervals = 0xFFFFFF; + } else { + intervals = timeout / 50 + 1; + } int32 inter = 0; for (inter = 0; inter < intervals; inter++) { + sl_lock_release(&queue_lock); OS_TaskDelay(50); + sl_lock_take(&queue_lock); // Check if there are messages to be received. if (queues[queue_id].head == queues[queue_id].tail) { result = OS_QUEUE_EMPTY; @@ -164,7 +173,7 @@ OS_QueueGet(uint32 queue_id, void* data, uint32 size, uint32* size_copied, int32 assert(result != OS_ERROR); exit: - sl_lock_release(queue_lock); + sl_lock_release(&queue_lock); return result; } From 9a366d8883418eb434fb8b101af655b27334660b Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 11 Sep 2017 21:22:45 -0400 Subject: [PATCH 082/122] Fix some inelegence in the queue implementation --- .../no_interface/cFE_booter/osqueue.c | 67 +++++++++++-------- .../no_interface/cFE_booter/sl_mod_fprr.c | 19 ++++++ 2 files changed, 59 insertions(+), 27 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osqueue.c b/src/components/implementation/no_interface/cFE_booter/osqueue.c index 38b57821b5..fe927e989f 100644 --- a/src/components/implementation/no_interface/cFE_booter/osqueue.c +++ b/src/components/implementation/no_interface/cFE_booter/osqueue.c @@ -109,6 +109,36 @@ OS_QueueDelete(uint32 queue_id) { return OS_SUCCESS; } +int32 +OS_QueuePoll(uint32 queue_id, void* data, uint32 size, uint32* size_copied) +{ + uint32 i; + + // Check if there are messages to be received. + if (queues[queue_id].head == queues[queue_id].tail) { + return OS_QUEUE_EMPTY; + } + + // TODO: Implement logic for returning OS_QUEUE_TIMEOUT (waiting on mutex implementation). + + if (size < queues[queue_id].data_size) { + return OS_QUEUE_INVALID_SIZE; + } + + // A helper reference to the currently selected queue. + struct queue* cur = &queues[queue_id]; + + // Walk through the bytes at the head of the queue and write them to buffer `data`. + for (i = 0; i < size; i++) { + *((char*)data + i) = queue_data[queue_id][cur->head * cur->data_size + i]; + } + + // Advance the queue head, wrapping if it is passed `depth`. + cur->head = (cur->head + 1) % cur->depth; + + return OS_SUCCESS; +} + int32 OS_QueueGet(uint32 queue_id, void* data, uint32 size, uint32* size_copied, int32 timeout) { @@ -132,48 +162,31 @@ OS_QueueGet(uint32 queue_id, void* data, uint32 size, uint32* size_copied, int32 /* FIXME: Block instead of poll */ int32 intervals; if (timeout == OS_CHECK) { - intervals = 0; + result = OS_QueuePoll(queue_id, data, size, size_copied); + goto exit; } else if (timeout == OS_PEND) { intervals = 0xFFFFFF; } else { intervals = timeout / 50 + 1; } + int32 inter = 0; for (inter = 0; inter < intervals; inter++) { + result = OS_QueuePoll(queue_id, data, size, size_copied); + if (result == OS_SUCCESS) { + goto exit; + } sl_lock_release(&queue_lock); OS_TaskDelay(50); sl_lock_take(&queue_lock); - // Check if there are messages to be received. - if (queues[queue_id].head == queues[queue_id].tail) { - result = OS_QUEUE_EMPTY; - continue; - } - - // TODO: Implement logic for returning OS_QUEUE_TIMEOUT (waiting on mutex implementation). - - if (size < queues[queue_id].data_size) { - result = OS_QUEUE_INVALID_SIZE; - continue; - } - - // A helper reference to the currently selected queue. - struct queue* cur = &queues[queue_id]; - - // Walk through the bytes at the head of the queue and write them to buffer `data`. - for (i = 0; i < size; i++) { - *((char*)data + i) = queue_data[queue_id][cur->head * cur->data_size + i]; - } - - // Advance the queue head, wrapping if it is passed `depth`. - cur->head = (cur->head + 1) % cur->depth; - - result = OS_SUCCESS; - goto exit; } assert(result != OS_ERROR); exit: sl_lock_release(&queue_lock); + if (result != OS_SUCCESS && timeout != OS_CHECK) { + return OS_QUEUE_TIMEOUT; + } return result; } diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c index 4720528ca1..2929707111 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c +++ b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -16,6 +18,9 @@ void sl_mod_execution(struct sl_thd_policy *t, cycles_t cycles) { } + +volatile int global = 0; + struct sl_thd_policy * sl_mod_schedule(void) { @@ -26,6 +31,20 @@ sl_mod_schedule(void) if (ps_list_head_empty(&threads[i])) continue; t = ps_list_head_first_d(&threads[i], struct sl_thd_policy); + struct sl_thd *thd = sl_mod_thd_get(t); + + if (global % 1000 == 0) { + printc("switching to thd %d\n", (int) thd->thdid); + } + global++; + + /* + * We want to move the selected thread to the back of the list. + * Otherwise fprr won't be truly round robin + */ + ps_list_rem_d(t); + ps_list_head_append_d(&threads[i], t); + return t; } From 3c9159051a7b901ccdf8d9cba0d57eb7f1b4cf9f Mon Sep 17 00:00:00 2001 From: Joseph Espy Date: Wed, 27 Sep 2017 12:00:06 -0400 Subject: [PATCH 083/122] Increased usability by cleaning up old code I removed a number of debugging print statements that were not left intentionally. I removed build directories related to apps that we do not and will not soon support. The print statements in the loader should not have been left there to begin with, but @others argues they should be kept for now because the code is not stable. I wrapped these print statements with an #if so they are disabled by default, and the cFE startup is not too verbose to be readable. --- .../no_interface/cFE_booter/osloader.c | 176 ++++++++++++------ .../no_interface/cFE_booter/ostask.c | 8 - .../no_interface/cFE_booter/sl_mod_fprr.c | 3 - .../no_interface/ci_lab/Makefile | 10 - .../no_interface/to_lab/Makefile | 10 - 5 files changed, 123 insertions(+), 84 deletions(-) delete mode 100644 src/components/implementation/no_interface/ci_lab/Makefile delete mode 100644 src/components/implementation/no_interface/to_lab/Makefile diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index d80d1f6f9c..8b39e8dfd2 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -11,6 +11,7 @@ #include "gen/cfe_evs.h" #define USER_CAPS_SYMB_NAME "ST_user_caps" +#define PRINT_ENABLE 0 int cobj_count; struct cobj_header *hs[MAX_NUM_SPDS+1]; @@ -22,8 +23,10 @@ find_cobjs(struct cobj_header *h, int n) vaddr_t start, end; start = (vaddr_t)h; +#if PRINT_ENABLE printc("First cobj is '%s'.\n", h->name); - hs[0] = h; +#endif + hs[0] = h; for (i = 1 ; i < n ; i++) { int j = 0, size = 0, tot = 0; @@ -32,9 +35,10 @@ find_cobjs(struct cobj_header *h, int n) for (j = 0 ; j < (int)h->nsect ; j++) { tot += cobj_sect_size(h, j); } +#if PRINT_ENABLE printc("cobj %s:%d found at %p:%x, size %x -> %x\n", h->name, h->id, hs[i-1], size, tot, cobj_sect_get(hs[i-1], 0)->vaddr); - +#endif end = start + round_up_to_cacheline(size); hs[i] = h = (struct cobj_header*)end; start = end; @@ -42,8 +46,10 @@ find_cobjs(struct cobj_header *h, int n) hs[n] = NULL; cobj_count = i; - printc("cobj %s:%d found at %p -> %x\n", +#if PRINT_ENABLE + printc("cobj %s:%d found at %p -> %x\n", hs[n-1]->name, hs[n-1]->id, hs[n-1], cobj_sect_get(hs[n-1], 0)->vaddr); +#endif } struct module_internal_record { @@ -133,7 +139,9 @@ struct symbol_of_jank* lookup_symbol_in_soj(const char *symb_name) for (i = 0; soj[i].fn != NULL; i++) { if (!strcmp(symb_name, soj[i].name)) { /* We have found the matching SOJ. */ +#if PRINT_ENABLE printc("Found matching SOJ @ %p for undef '%s'.\n", soj[i].fn, symb_name); +#endif return &soj[i]; } } @@ -150,28 +158,35 @@ struct cobj_header *get_cobj_header(const char* path) { char name[OS_MAX_PATH_LEN]; - printc("cobj: Object path is %s\n", path); - +#if PRINT_ENABLE + printc("cobj: Object path is %s\n", path); +#endif int slash_index; for (slash_index = strlen(path); path[slash_index] != '/' && slash_index != 0; slash_index--) { } - if (slash_index == 0) { +#if PRINT_ENABLE + if (slash_index == 0) { PANIC("Could not find slash in object name, aborting..."); } +#endif /* We just want the name after the slash_index */ strcpy(name, path + slash_index + 1); - printc("cobj: Object name appears to be %s\n", name); - +#if PRINT_ENABLE + printc("cobj: Object name appears to be %s\n", name); +#endif /* But before the '.' */ int dot_index; for (dot_index = 0; name[dot_index] != '.' && name[dot_index] != '\0'; dot_index++) { } +#if PRINT_ENABLE if (name[dot_index] == '\0') { PANIC("Invalid object name, aborting..."); } +#endif name[dot_index] = '\0'; - printc("cobj: Trimmed object name appears to be %s\n", name); - +#if PRINT_ENABLE + printc("cobj: Trimmed object name appears to be %s\n", name); +#endif int cobj_index; for (cobj_index = 0; hs[cobj_index] != NULL; cobj_index++) { if (!strcmp(hs[cobj_index]->name, name)) { @@ -188,7 +203,9 @@ struct user_cap *find_user_caps(struct cobj_header *h) for (i = 0; i < h->nsymb; i++) { struct cobj_symb *curr = cobj_symb_get(h, i); if (!strcmp(curr->name, USER_CAPS_SYMB_NAME)) { +#if PRINT_ENABLE printc("cobj: found user caps array '%s' @ %x.\n", USER_CAPS_SYMB_NAME, curr->vaddr); +#endif /* Set to the first user cap in the array. */ return (struct user_cap *) (intptr_t) curr->vaddr; @@ -202,33 +219,46 @@ void inspect_cobj_symbols(struct cobj_header *h, vaddr_t *comp_info) { unsigned int i; - printc("cobj: getting spd symbs for header %s, nsymbs %d.\n", h->name, h->nsymb); - for (i = 0 ; i < h->nsymb ; i++) { +#if PRINT_ENABLE + printc("cobj: getting spd symbs for header %s, nsymbs %d.\n", h->name, h->nsymb); +#endif + + for (i = 0 ; i < h->nsymb ; i++) { struct cobj_symb *symb; symb = cobj_symb_get(h, i); assert(symb); if (symb->type == COBJ_SYMB_UNDEF) { - printc("cobj: undefined symbol %s: nsymb %d, usercap offset %d\n", symb->name, i, symb->user_caps_offset); - continue; +#if PRINT_ENABLE + printc("cobj: undefined symbol %s: nsymb %d, usercap offset %d\n", symb->name, i, symb->user_caps_offset); +#endif + continue; } else if (symb->type == COBJ_SYMB_EXPORTED) { - printc("cobj: exported symbol %s: nsymb %d, addr %x\n", symb->name, i, symb->vaddr); - continue; +#if PRINT_ENABLE + printc("cobj: exported symbol %s: nsymb %d, addr %x\n", symb->name, i, symb->vaddr); +#endif + continue; } switch (symb->type) { case COBJ_SYMB_COMP_INFO: - printc("cobj: comp info %s: addr %x\n", symb->name, symb->vaddr); - *comp_info = symb->vaddr; +#if PRINT_ENABLE + printc("cobj: comp info %s: addr %x\n", symb->name, symb->vaddr); +#endif + *comp_info = symb->vaddr; break; case COBJ_SYMB_COMP_PLT: /* Otherwise known as ST_user_caps. */ - printc("cobj: capability array %s: addr %x\n", symb->name, symb->vaddr); - break; +#if PRINT_ENABLE + printc("cobj: capability array %s: addr %x\n", symb->name, symb->vaddr); +#endif + break; default: - printc("boot: Unknown symbol type %d\n", symb->type); - break; +#if PRINT_ENABLE + printc("boot: Unknown symbol type %d\n", symb->type); +#endif + break; } } } @@ -236,8 +266,10 @@ void inspect_cobj_symbols(struct cobj_header *h, vaddr_t *comp_info) static void expand_pgtbl(int n_pte, pgtblcap_t pt, vaddr_t vaddr, struct cobj_header *h) { - printc("expand_pgtbl(%d, %lu, %lu, %p)\n", n_pte, pt, vaddr, h); - int i; +#if PRINT_ENABLE + printc("expand_pgtbl(%d, %lu, %lu, %p)\n", n_pte, pt, vaddr, h); +#endif + int i; int tot = 0; struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); @@ -254,8 +286,10 @@ expand_pgtbl(int n_pte, pgtblcap_t pt, vaddr_t vaddr, struct cobj_header *h) } for (i = 0 ; i < n_pte ; i++) { - printc("cos_pgtbl_intern_alloc(%p, %lu, %lu, %d)\n", ci, pt, vaddr, SERVICE_SIZE); - if (!cos_pgtbl_intern_alloc(ci, pt, vaddr, SERVICE_SIZE)) PANIC("BUG"); +#if PRINT_ENABLE + printc("cos_pgtbl_intern_alloc(%p, %lu, %lu, %d)\n", ci, pt, vaddr, SERVICE_SIZE); +#endif + if (!cos_pgtbl_intern_alloc(ci, pt, vaddr, SERVICE_SIZE)) PANIC("BUG"); } } @@ -280,7 +314,10 @@ void map_cobj_memory(struct cobj_header *h, pgtblcap_t pt) { int n_pte = 1; struct cobj_sect *sect = cobj_sect_get(h, 0); +#if PRINT_ENABLE printc("cobj: Expanding pgtbl\n"); +#endif + expand_pgtbl(n_pte, pt, sect->vaddr, h); /* NOTE: We just hardcode this, since we also want to map into this components memory` */ @@ -387,23 +424,28 @@ void populate_cobj_memory(struct cobj_header *h, spdid_t spdid, vaddr_t comp_inf lsrc = cobj_sect_contents(h, i); /* how much is left to copy? */ left = cobj_sect_size(h, i); - +#if PRINT_ENABLE printc("Destination is %p\n", (void*) dest_daddr); - +#endif /* Initialize memory. */ if (!(sect->flags & COBJ_SECT_KMEM) && (first_time || !(sect->flags & COBJ_SECT_INITONCE))) { if (sect->flags & COBJ_SECT_ZEROS) { char * to = (char *) dest_daddr; +#if PRINT_ENABLE printc("Zeroing some memory %p (%d bytes)!\n", to, left); - // HACK: Should actually resolve this +#endif + + // HACK: Should actually resolve this // memset(start_addr + (dest_daddr - init_daddr), 0, left); memset(to, 0, left); } else { char * to = (char *) dest_daddr; char * from = lsrc; +#if PRINT_ENABLE printc("Setting some memory to %p from %p (%d bytes)!\n", to, from, left); - // HACK: Should actually resolve this +#endif + // HACK: Should actually resolve this // memcpy(start_addr + (dest_daddr - init_daddr), lsrc, left); memcpy(to, from, left); } @@ -427,11 +469,15 @@ void populate_cobj_memory(struct cobj_header *h, spdid_t spdid, vaddr_t comp_inf void setup_cobj_memory(struct cobj_header *h, spdid_t spdid, vaddr_t comp_info, pgtblcap_t pt) { /* Allocating memory and mapping it to the booter's address space */ - printc("cobj: doing map_cobj_memory\n"); - map_cobj_memory(h, pt); - - printc("cobj: doing populate_cobj_memory\n"); - populate_cobj_memory(h, spdid, comp_info, 1); +#if PRINT_ENABLE + printc("cobj: doing map_cobj_memory\n"); +#endif + map_cobj_memory(h, pt); + +#if print_enable + printc("cobj: doing populate_cobj_memory\n"); +#endif + populate_cobj_memory(h, spdid, comp_info, 1); } @@ -440,9 +486,9 @@ void load_cobj_into_memory(struct cobj_header *h) vaddr_t ci = 0; pgtblcap_t pt = BOOT_CAPTBL_SELF_PT; spdid_t spdid = h->id; - +#if print_enable printc("cobj: Loading cobj with id %d, name %s\n", h->id, h->name); - +#endif // NOTE: We end up not needing this information // struct cobj_sect *sect; @@ -456,7 +502,9 @@ void load_cobj_into_memory(struct cobj_header *h) PANIC("Could not find component info in cobj!"); } +#if print_enable printc("Mapping cobj '%s'.\n", h->name); +#endif setup_cobj_memory(h, spdid, ci, pt); } @@ -464,6 +512,7 @@ void link_cobj(struct cobj_header *h, struct user_cap *user_caps) { unsigned int i; +#if print_enable printc("link: printing symbols of jank.\n"); for (i = 0; soj[i].fn != NULL; i++) { printc("\tlink: symbol of jank %d '%s' with fn @ %p\n", i, soj[i].name, soj[i].fn); @@ -471,39 +520,47 @@ void link_cobj(struct cobj_header *h, struct user_cap *user_caps) /* Iterate through each symbol in the header. If it is undefined, index into the user caps array and set the `invfn`. */ printc("link: parsing symbols for cobj header '%s'.\n", h->name); +#endif for (i = 0; i < h->nsymb; i++) { struct cobj_symb *symb = cobj_symb_get(h, i); assert(symb); if (symb->type == COBJ_SYMB_UNDEF) { +#if print_enable printc("link: found undefined symbol '%s': nsymb %u, usercap offset %d\n", symb->name, i, symb->user_caps_offset); - +#endif // FIXME: Figure out if this is an ok way to do this // struct symbol_of_jank *symbol = lookup_symbol_in_soj(symb->name); cpuaddr addr; int result = OS_SymbolLookup(&addr, symb->name); if (result != OS_SUCCESS) { - printc("link: ERROR: could not find matching symbol for '%s'.\n", symb->name); - PANIC("Cannot resolve symbol!"); +#if print_enable + printc("link: ERROR: could not find matching symbol for '%s'.\n", symb->name); +#endif + PANIC("Cannot resolve symbol!"); } struct user_cap cap = (struct user_cap) { .invfn = (void *) addr }; +#if print_enable printc("link: setting user cap index %d invfn @ %p\n", symb->user_caps_offset, cap.invfn); +#endif user_caps[symb->user_caps_offset] = cap; } } +#if print_enable printc("link: done parsing symbols for cobj header '%s'.\n", h->name); - +#endif } int32 OS_ModuleLoad(uint32 *module_id, const char *module_name, const char *filename) { +#if print_enable printc("OS_ModuleLoad start\n"); - +#endif uint32 i; uint32 possible_id; @@ -511,31 +568,37 @@ int32 OS_ModuleLoad(uint32 *module_id, const char *module_name, const char *file if (module_id == NULL || module_name == NULL || filename == NULL) { return OS_INVALID_POINTER; } +#if print_enable printc("OS_ModuleLoad %s %s\n", module_name, filename); - +#endif /* Find a free id. */ for (possible_id = 0; possible_id < OS_MAX_MODULES; possible_id++) { if (module_table[possible_id].free == TRUE) break; } - /* Check bounds of that id. */ if (possible_id >= OS_MAX_MODULES || module_table[possible_id].free == FALSE) { - printc("OS_ERR_NO_FREE_IDS\n"); +#if print_enable + printc("OS_ERR_NO_FREE_IDS\n"); +#endif return OS_ERR_NO_FREE_IDS; } /* Check if the module was already loaded. */ for (i = 0; i < OS_MAX_MODULES; i++) { if (module_table[i].free == FALSE && strcmp(module_name, module_table[i].name) == 0) { - printc("OS_ERR_NAME_TAKEN\n"); +#if print_enable + printc("OS_ERR_NAME_TAKEN\n"); +#endif return OS_ERR_NAME_TAKEN; } } struct cobj_header *h = get_cobj_header(filename); if (!h) { - printc("Could not find cobj for designated object %s!\n", filename); - return OS_ERROR; +#if print_enable + printc("Could not find cobj for designated object %s!\n", filename); +#endif + return OS_ERROR; } /* Claim the module id. */ @@ -549,8 +612,9 @@ int32 OS_ModuleLoad(uint32 *module_id, const char *module_name, const char *file load_cobj_into_memory(h); link_cobj(h, caps); +#if print_enable printc("osloader: Loading finished successfully, returning OS_SUCCESS\n"); - +#endif return OS_SUCCESS; } @@ -575,7 +639,9 @@ cpuaddr search_cobj_for_symbol(struct cobj_header *h, const char *symbol_name) int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) { +#if print_enable printc("osloader: doing symbol lookup for %s\n", symbol_name); +#endif /* Check parameters. */ if (symbol_address == NULL || symbol_name == NULL) { return OS_INVALID_POINTER; @@ -584,8 +650,10 @@ int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) struct symbol_of_jank *jank_symbol = lookup_symbol_in_soj(symbol_name); if (jank_symbol->fn != NULL) { *symbol_address = (cpuaddr) jank_symbol->fn; - printc("osloader: found soj for %s, address %p\n", symbol_name, (void *) jank_symbol->fn); - return OS_SUCCESS; +#if print_enable + printc("osloader: found soj for %s, address %p\n", symbol_name, (void *) jank_symbol->fn); +#endif + return OS_SUCCESS; } int i; @@ -593,8 +661,10 @@ int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) if(!module_table[i].free) { cpuaddr addr = search_cobj_for_symbol(module_table[i].header, symbol_name); if (addr != 0) { - printc("osloader: found cobj symbol for %s, address %p\n", symbol_name, (void *) addr); - *symbol_address = addr; +#if print_enable + printc("osloader: found cobj symbol for %s, address %p\n", symbol_name, (void *) addr); +#endif + *symbol_address = addr; return OS_SUCCESS; } } diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 60b9c3f00c..3a3467dec8 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -77,7 +77,6 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, if(task_id == NULL || task_name == NULL || function_pointer == NULL){ return OS_INVALID_POINTER; } - printc("ostask: Attempting to create task %s, priority %d\n", task_name, (int) priority); // Validate the name if(!is_valid_name(task_name)) { @@ -106,8 +105,6 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, *task_id = (uint32) thd->thdid; - printc("ostask: Created task %s, thdid %d!\n", task_name, (int) thd->thdid); - return OS_SUCCESS; } @@ -153,7 +150,6 @@ int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer) int32 OS_TaskDelay(uint32 millisecond) { - // printc("ostask: Delaying task by %d milliseconds\n", (int) millisecond); cycles_t wakeup = sl_now() + sl_usec2cyc(millisecond * 1000); sl_thd_block_timeout(0, wakeup); return OS_SUCCESS; @@ -510,8 +506,6 @@ int32 OS_SemaphoreGive(struct semaphore* semaphores, uint32 max_semaphores, uint goto exit; } - printc("ostask: Giving semaphore %s!\n", semaphores[sem_id].name); - // FIXME: Add some checks that the semaphore was actually taken by this thread semaphores[sem_id].count += 1; @@ -534,8 +528,6 @@ int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint int starting_epoch = semaphores[sem_id].epoch; - printc("ostask: Taking semaphore %s!\n", semaphores[sem_id].name); - while (semaphores[sem_id].used && semaphores[sem_id].count == 0) { if(semaphores[sem_id].epoch != starting_epoch) { goto exit; diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c index 2929707111..934d37e53b 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c +++ b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c @@ -33,9 +33,6 @@ sl_mod_schedule(void) struct sl_thd *thd = sl_mod_thd_get(t); - if (global % 1000 == 0) { - printc("switching to thd %d\n", (int) thd->thdid); - } global++; /* diff --git a/src/components/implementation/no_interface/ci_lab/Makefile b/src/components/implementation/no_interface/ci_lab/Makefile deleted file mode 100644 index 3569653431..0000000000 --- a/src/components/implementation/no_interface/ci_lab/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c -ASM_OBJS= -COMPONENT=ci_lab.o -INTERFACES= -DEPENDENCIES=cFE -IF_LIB:=./cFE_ci_lab_app.o -ADDITIONAL_LIBS= - -include ../../Makefile.subsubdir -MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/to_lab/Makefile b/src/components/implementation/no_interface/to_lab/Makefile deleted file mode 100644 index 35515bd780..0000000000 --- a/src/components/implementation/no_interface/to_lab/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c -ASM_OBJS= -COMPONENT=to_lab.o -INTERFACES= -DEPENDENCIES=cFE -IF_LIB:=./cFE_to_lab_app.o -ADDITIONAL_LIBS= - -include ../../Makefile.subsubdir -MANDITORY_LIB=simple_stklib.o From 75af8e6f8f3fe7beb3e10f599e4f4e37b8f75464 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Wed, 25 Oct 2017 16:02:42 -0400 Subject: [PATCH 084/122] Remove broken ifdefs in the cFE loader code --- .../no_interface/cFE_booter/osloader.c | 161 +++++++++--------- 1 file changed, 80 insertions(+), 81 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index 8b39e8dfd2..7833a87664 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -11,7 +11,6 @@ #include "gen/cfe_evs.h" #define USER_CAPS_SYMB_NAME "ST_user_caps" -#define PRINT_ENABLE 0 int cobj_count; struct cobj_header *hs[MAX_NUM_SPDS+1]; @@ -23,9 +22,9 @@ find_cobjs(struct cobj_header *h, int n) vaddr_t start, end; start = (vaddr_t)h; -#if PRINT_ENABLE + printc("First cobj is '%s'.\n", h->name); -#endif + hs[0] = h; for (i = 1 ; i < n ; i++) { @@ -35,10 +34,10 @@ find_cobjs(struct cobj_header *h, int n) for (j = 0 ; j < (int)h->nsect ; j++) { tot += cobj_sect_size(h, j); } -#if PRINT_ENABLE + printc("cobj %s:%d found at %p:%x, size %x -> %x\n", h->name, h->id, hs[i-1], size, tot, cobj_sect_get(hs[i-1], 0)->vaddr); -#endif + end = start + round_up_to_cacheline(size); hs[i] = h = (struct cobj_header*)end; start = end; @@ -46,10 +45,10 @@ find_cobjs(struct cobj_header *h, int n) hs[n] = NULL; cobj_count = i; -#if PRINT_ENABLE + printc("cobj %s:%d found at %p -> %x\n", hs[n-1]->name, hs[n-1]->id, hs[n-1], cobj_sect_get(hs[n-1], 0)->vaddr); -#endif + } struct module_internal_record { @@ -139,9 +138,9 @@ struct symbol_of_jank* lookup_symbol_in_soj(const char *symb_name) for (i = 0; soj[i].fn != NULL; i++) { if (!strcmp(symb_name, soj[i].name)) { /* We have found the matching SOJ. */ -#if PRINT_ENABLE + printc("Found matching SOJ @ %p for undef '%s'.\n", soj[i].fn, symb_name); -#endif + return &soj[i]; } } @@ -158,35 +157,35 @@ struct cobj_header *get_cobj_header(const char* path) { char name[OS_MAX_PATH_LEN]; -#if PRINT_ENABLE + printc("cobj: Object path is %s\n", path); -#endif + int slash_index; for (slash_index = strlen(path); path[slash_index] != '/' && slash_index != 0; slash_index--) { } -#if PRINT_ENABLE + if (slash_index == 0) { PANIC("Could not find slash in object name, aborting..."); } -#endif + /* We just want the name after the slash_index */ strcpy(name, path + slash_index + 1); -#if PRINT_ENABLE + printc("cobj: Object name appears to be %s\n", name); -#endif + /* But before the '.' */ int dot_index; for (dot_index = 0; name[dot_index] != '.' && name[dot_index] != '\0'; dot_index++) { } -#if PRINT_ENABLE + if (name[dot_index] == '\0') { PANIC("Invalid object name, aborting..."); } -#endif + name[dot_index] = '\0'; -#if PRINT_ENABLE + printc("cobj: Trimmed object name appears to be %s\n", name); -#endif + int cobj_index; for (cobj_index = 0; hs[cobj_index] != NULL; cobj_index++) { if (!strcmp(hs[cobj_index]->name, name)) { @@ -203,9 +202,9 @@ struct user_cap *find_user_caps(struct cobj_header *h) for (i = 0; i < h->nsymb; i++) { struct cobj_symb *curr = cobj_symb_get(h, i); if (!strcmp(curr->name, USER_CAPS_SYMB_NAME)) { -#if PRINT_ENABLE + printc("cobj: found user caps array '%s' @ %x.\n", USER_CAPS_SYMB_NAME, curr->vaddr); -#endif + /* Set to the first user cap in the array. */ return (struct user_cap *) (intptr_t) curr->vaddr; @@ -219,9 +218,9 @@ void inspect_cobj_symbols(struct cobj_header *h, vaddr_t *comp_info) { unsigned int i; -#if PRINT_ENABLE + printc("cobj: getting spd symbs for header %s, nsymbs %d.\n", h->name, h->nsymb); -#endif + for (i = 0 ; i < h->nsymb ; i++) { struct cobj_symb *symb; @@ -230,34 +229,34 @@ void inspect_cobj_symbols(struct cobj_header *h, vaddr_t *comp_info) assert(symb); if (symb->type == COBJ_SYMB_UNDEF) { -#if PRINT_ENABLE + printc("cobj: undefined symbol %s: nsymb %d, usercap offset %d\n", symb->name, i, symb->user_caps_offset); -#endif + continue; } else if (symb->type == COBJ_SYMB_EXPORTED) { -#if PRINT_ENABLE + printc("cobj: exported symbol %s: nsymb %d, addr %x\n", symb->name, i, symb->vaddr); -#endif + continue; } switch (symb->type) { case COBJ_SYMB_COMP_INFO: -#if PRINT_ENABLE + printc("cobj: comp info %s: addr %x\n", symb->name, symb->vaddr); -#endif + *comp_info = symb->vaddr; break; case COBJ_SYMB_COMP_PLT: /* Otherwise known as ST_user_caps. */ -#if PRINT_ENABLE + printc("cobj: capability array %s: addr %x\n", symb->name, symb->vaddr); -#endif + break; default: -#if PRINT_ENABLE + printc("boot: Unknown symbol type %d\n", symb->type); -#endif + break; } } @@ -266,9 +265,9 @@ void inspect_cobj_symbols(struct cobj_header *h, vaddr_t *comp_info) static void expand_pgtbl(int n_pte, pgtblcap_t pt, vaddr_t vaddr, struct cobj_header *h) { -#if PRINT_ENABLE + printc("expand_pgtbl(%d, %lu, %lu, %p)\n", n_pte, pt, vaddr, h); -#endif + int i; int tot = 0; @@ -286,9 +285,9 @@ expand_pgtbl(int n_pte, pgtblcap_t pt, vaddr_t vaddr, struct cobj_header *h) } for (i = 0 ; i < n_pte ; i++) { -#if PRINT_ENABLE + printc("cos_pgtbl_intern_alloc(%p, %lu, %lu, %d)\n", ci, pt, vaddr, SERVICE_SIZE); -#endif + if (!cos_pgtbl_intern_alloc(ci, pt, vaddr, SERVICE_SIZE)) PANIC("BUG"); } } @@ -314,9 +313,9 @@ void map_cobj_memory(struct cobj_header *h, pgtblcap_t pt) { int n_pte = 1; struct cobj_sect *sect = cobj_sect_get(h, 0); -#if PRINT_ENABLE + printc("cobj: Expanding pgtbl\n"); -#endif + expand_pgtbl(n_pte, pt, sect->vaddr, h); @@ -424,17 +423,17 @@ void populate_cobj_memory(struct cobj_header *h, spdid_t spdid, vaddr_t comp_inf lsrc = cobj_sect_contents(h, i); /* how much is left to copy? */ left = cobj_sect_size(h, i); -#if PRINT_ENABLE + printc("Destination is %p\n", (void*) dest_daddr); -#endif + /* Initialize memory. */ if (!(sect->flags & COBJ_SECT_KMEM) && (first_time || !(sect->flags & COBJ_SECT_INITONCE))) { if (sect->flags & COBJ_SECT_ZEROS) { char * to = (char *) dest_daddr; -#if PRINT_ENABLE + printc("Zeroing some memory %p (%d bytes)!\n", to, left); -#endif + // HACK: Should actually resolve this // memset(start_addr + (dest_daddr - init_daddr), 0, left); @@ -442,9 +441,9 @@ void populate_cobj_memory(struct cobj_header *h, spdid_t spdid, vaddr_t comp_inf } else { char * to = (char *) dest_daddr; char * from = lsrc; -#if PRINT_ENABLE + printc("Setting some memory to %p from %p (%d bytes)!\n", to, from, left); -#endif + // HACK: Should actually resolve this // memcpy(start_addr + (dest_daddr - init_daddr), lsrc, left); memcpy(to, from, left); @@ -469,14 +468,14 @@ void populate_cobj_memory(struct cobj_header *h, spdid_t spdid, vaddr_t comp_inf void setup_cobj_memory(struct cobj_header *h, spdid_t spdid, vaddr_t comp_info, pgtblcap_t pt) { /* Allocating memory and mapping it to the booter's address space */ -#if PRINT_ENABLE + printc("cobj: doing map_cobj_memory\n"); -#endif + map_cobj_memory(h, pt); -#if print_enable + printc("cobj: doing populate_cobj_memory\n"); -#endif + populate_cobj_memory(h, spdid, comp_info, 1); } @@ -486,9 +485,9 @@ void load_cobj_into_memory(struct cobj_header *h) vaddr_t ci = 0; pgtblcap_t pt = BOOT_CAPTBL_SELF_PT; spdid_t spdid = h->id; -#if print_enable + printc("cobj: Loading cobj with id %d, name %s\n", h->id, h->name); -#endif + // NOTE: We end up not needing this information // struct cobj_sect *sect; @@ -502,9 +501,9 @@ void load_cobj_into_memory(struct cobj_header *h) PANIC("Could not find component info in cobj!"); } -#if print_enable + printc("Mapping cobj '%s'.\n", h->name); -#endif + setup_cobj_memory(h, spdid, ci, pt); } @@ -512,7 +511,7 @@ void link_cobj(struct cobj_header *h, struct user_cap *user_caps) { unsigned int i; -#if print_enable + printc("link: printing symbols of jank.\n"); for (i = 0; soj[i].fn != NULL; i++) { printc("\tlink: symbol of jank %d '%s' with fn @ %p\n", i, soj[i].name, soj[i].fn); @@ -520,23 +519,23 @@ void link_cobj(struct cobj_header *h, struct user_cap *user_caps) /* Iterate through each symbol in the header. If it is undefined, index into the user caps array and set the `invfn`. */ printc("link: parsing symbols for cobj header '%s'.\n", h->name); -#endif + for (i = 0; i < h->nsymb; i++) { struct cobj_symb *symb = cobj_symb_get(h, i); assert(symb); if (symb->type == COBJ_SYMB_UNDEF) { -#if print_enable + printc("link: found undefined symbol '%s': nsymb %u, usercap offset %d\n", symb->name, i, symb->user_caps_offset); -#endif + // FIXME: Figure out if this is an ok way to do this // struct symbol_of_jank *symbol = lookup_symbol_in_soj(symb->name); cpuaddr addr; int result = OS_SymbolLookup(&addr, symb->name); if (result != OS_SUCCESS) { -#if print_enable + printc("link: ERROR: could not find matching symbol for '%s'.\n", symb->name); -#endif + PANIC("Cannot resolve symbol!"); } @@ -544,23 +543,23 @@ void link_cobj(struct cobj_header *h, struct user_cap *user_caps) .invfn = (void *) addr }; -#if print_enable + printc("link: setting user cap index %d invfn @ %p\n", symb->user_caps_offset, cap.invfn); -#endif + user_caps[symb->user_caps_offset] = cap; } } -#if print_enable + printc("link: done parsing symbols for cobj header '%s'.\n", h->name); -#endif + } int32 OS_ModuleLoad(uint32 *module_id, const char *module_name, const char *filename) { -#if print_enable + printc("OS_ModuleLoad start\n"); -#endif + uint32 i; uint32 possible_id; @@ -568,36 +567,36 @@ int32 OS_ModuleLoad(uint32 *module_id, const char *module_name, const char *file if (module_id == NULL || module_name == NULL || filename == NULL) { return OS_INVALID_POINTER; } -#if print_enable + printc("OS_ModuleLoad %s %s\n", module_name, filename); -#endif + /* Find a free id. */ for (possible_id = 0; possible_id < OS_MAX_MODULES; possible_id++) { if (module_table[possible_id].free == TRUE) break; } /* Check bounds of that id. */ if (possible_id >= OS_MAX_MODULES || module_table[possible_id].free == FALSE) { -#if print_enable + printc("OS_ERR_NO_FREE_IDS\n"); -#endif + return OS_ERR_NO_FREE_IDS; } /* Check if the module was already loaded. */ for (i = 0; i < OS_MAX_MODULES; i++) { if (module_table[i].free == FALSE && strcmp(module_name, module_table[i].name) == 0) { -#if print_enable + printc("OS_ERR_NAME_TAKEN\n"); -#endif + return OS_ERR_NAME_TAKEN; } } struct cobj_header *h = get_cobj_header(filename); if (!h) { -#if print_enable + printc("Could not find cobj for designated object %s!\n", filename); -#endif + return OS_ERROR; } @@ -612,9 +611,9 @@ int32 OS_ModuleLoad(uint32 *module_id, const char *module_name, const char *file load_cobj_into_memory(h); link_cobj(h, caps); -#if print_enable + printc("osloader: Loading finished successfully, returning OS_SUCCESS\n"); -#endif + return OS_SUCCESS; } @@ -639,9 +638,9 @@ cpuaddr search_cobj_for_symbol(struct cobj_header *h, const char *symbol_name) int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) { -#if print_enable + printc("osloader: doing symbol lookup for %s\n", symbol_name); -#endif + /* Check parameters. */ if (symbol_address == NULL || symbol_name == NULL) { return OS_INVALID_POINTER; @@ -650,9 +649,9 @@ int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) struct symbol_of_jank *jank_symbol = lookup_symbol_in_soj(symbol_name); if (jank_symbol->fn != NULL) { *symbol_address = (cpuaddr) jank_symbol->fn; -#if print_enable + printc("osloader: found soj for %s, address %p\n", symbol_name, (void *) jank_symbol->fn); -#endif + return OS_SUCCESS; } @@ -661,9 +660,9 @@ int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) if(!module_table[i].free) { cpuaddr addr = search_cobj_for_symbol(module_table[i].header, symbol_name); if (addr != 0) { -#if print_enable + printc("osloader: found cobj symbol for %s, address %p\n", symbol_name, (void *) addr); -#endif + *symbol_address = addr; return OS_SUCCESS; } From d2b1a6f5782257b84512541e6a0946be2150c8c7 Mon Sep 17 00:00:00 2001 From: Zach Day Date: Sat, 4 Nov 2017 19:12:24 -0400 Subject: [PATCH 085/122] Add more symbols to cFE assembly stubs This is a trivial change that allows more apps to be compiled in cFE2cos by adding their required functions as exports. --- .../no_interface/cFE_booter/osloader.c | 32 +++++++++++++++++++ src/components/interface/cFE/stubs/s_stub.S | 31 ++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index 7833a87664..4f6d265ff5 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -9,6 +9,7 @@ #include "gen/common_types.h" #include "gen/cfe_es.h" #include "gen/cfe_evs.h" +#include "gen/cfe_tbl.h" #define USER_CAPS_SYMB_NAME "ST_user_caps" @@ -108,6 +109,8 @@ struct symbol_of_jank { struct symbol_of_jank soj[] = { { .name = "OS_printf", .fn = OS_printf }, + { .name = "OS_close", .fn = OS_close }, + { .name = "OS_open", .fn = OS_open }, { .name = "OS_TaskInstallDeleteHandler", .fn = OS_TaskInstallDeleteHandler }, { .name = "OS_TaskDelay", .fn = OS_TaskDelay }, { .name = "CFE_ES_ExitApp", .fn = CFE_ES_ExitApp }, @@ -128,6 +131,35 @@ struct symbol_of_jank soj[] = { { .name = "CFE_SB_MessageStringGet", .fn = CFE_SB_MessageStringGet }, { .name = "CFE_SB_SubscribeEx", .fn = CFE_SB_SubscribeEx }, { .name = "CFE_SB_Unsubscribe", .fn = CFE_SB_Unsubscribe }, + { .name = "CFE_ES_RegisterChildTask", .fn = CFE_ES_RegisterChildTask }, + { .name = "CFE_ES_CalculateCRC", .fn = CFE_ES_CalculateCRC }, + { .name = "CFE_ES_CopyToCDS", .fn = CFE_ES_CopyToCDS }, + { .name = "CFE_ES_CreateChildTask", .fn = CFE_ES_CreateChildTask }, + { .name = "CFE_ES_DeleteChildTask", .fn = CFE_ES_DeleteChildTask }, + { .name = "CFE_ES_ExitChildTask", .fn = CFE_ES_ExitChildTask }, + { .name = "CFE_ES_GetAppID", .fn = CFE_ES_GetAppID }, + { .name = "CFE_ES_GetAppIDByName", .fn = CFE_ES_GetAppIDByName }, + { .name = "CFE_ES_GetAppInfo", .fn = CFE_ES_GetAppInfo }, + { .name = "CFE_ES_GetAppName", .fn = CFE_ES_GetAppName }, + { .name = "CFE_ES_RegisterCDS", .fn = CFE_ES_RegisterCDS }, + { .name = "CFE_ES_RegisterChildTask", .fn = CFE_ES_RegisterChildTask }, + { .name = "CFE_ES_RestoreFromCDS", .fn = CFE_ES_RestoreFromCDS }, + { .name = "CFE_ES_WaitForStartupSync", .fn = CFE_ES_WaitForStartupSync }, + { .name = "CFE_ES_WriteToSysLog", .fn = CFE_ES_WriteToSysLog }, + { .name = "CFE_PSP_GetCFETextSegmentInfo", .fn = CFE_PSP_GetCFETextSegmentInfo }, + { .name = "CFE_PSP_GetKernelTextSegmentInfo", .fn = CFE_PSP_GetKernelTextSegmentInfo }, + { .name = "CFE_PSP_MemCpy", .fn = CFE_PSP_MemCpy }, + { .name = "CFE_PSP_MemSet", .fn = CFE_PSP_MemSet }, + { .name = "CFE_PSP_MemValidateRange", .fn = CFE_PSP_MemValidateRange }, + { .name = "CFE_TBL_GetAddress", .fn = CFE_TBL_GetAddress }, + { .name = "CFE_TBL_GetInfo", .fn = CFE_TBL_GetInfo }, + { .name = "CFE_TBL_Load", .fn = CFE_TBL_Load }, + { .name = "CFE_TBL_Manage", .fn = CFE_TBL_Manage }, + { .name = "CFE_TBL_Modified", .fn = CFE_TBL_Modified }, + { .name = "CFE_TBL_Register", .fn = CFE_TBL_Register }, + { .name = "CFE_TBL_ReleaseAddress", .fn = CFE_TBL_ReleaseAddress }, + { .name = "CFE_TBL_Share", .fn = CFE_TBL_Share }, + { .name = "CFE_TBL_Unregister", .fn = CFE_TBL_Unregister }, { .name = "", .fn = NULL }, }; diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index ef5e41acd2..1fbd10d489 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -33,3 +33,34 @@ cos_asm_server_stub(CFE_SB_InitMsg) cos_asm_server_stub(CFE_SB_MessageStringGet) cos_asm_server_stub(CFE_SB_SubscribeEx) cos_asm_server_stub(CFE_SB_Unsubscribe) + +cos_asm_server_stub(CFE_ES_CalculateCRC) +cos_asm_server_stub(CFE_ES_CopyToCDS) +cos_asm_server_stub(CFE_ES_CreateChildTask) +cos_asm_server_stub(CFE_ES_DeleteChildTask) +cos_asm_server_stub(CFE_ES_ExitChildTask) +cos_asm_server_stub(CFE_ES_GetAppID) +cos_asm_server_stub(CFE_ES_GetAppIDByName) +cos_asm_server_stub(CFE_ES_GetAppInfo) +cos_asm_server_stub(CFE_ES_GetAppName) +cos_asm_server_stub(CFE_ES_RegisterCDS) +cos_asm_server_stub(CFE_ES_RegisterChildTask) +cos_asm_server_stub(CFE_ES_RestoreFromCDS) +cos_asm_server_stub(CFE_ES_WaitForStartupSync) +cos_asm_server_stub(CFE_ES_WriteToSysLog) +cos_asm_server_stub(CFE_PSP_GetCFETextSegmentInfo) +cos_asm_server_stub(CFE_PSP_GetKernelTextSegmentInfo) +cos_asm_server_stub(CFE_PSP_MemCpy) +cos_asm_server_stub(CFE_PSP_MemSet) +cos_asm_server_stub(CFE_PSP_MemValidateRange) +cos_asm_server_stub(CFE_TBL_GetAddress) +cos_asm_server_stub(CFE_TBL_GetInfo) +cos_asm_server_stub(CFE_TBL_Load) +cos_asm_server_stub(CFE_TBL_Manage) +cos_asm_server_stub(CFE_TBL_Modified) +cos_asm_server_stub(CFE_TBL_Register) +cos_asm_server_stub(CFE_TBL_ReleaseAddress) +cos_asm_server_stub(CFE_TBL_Share) +cos_asm_server_stub(CFE_TBL_Unregister) +cos_asm_server_stub(OS_close) +cos_asm_server_stub(OS_open) From b34d5399ffa8dfd194b19d1c39b394ef1c1428f8 Mon Sep 17 00:00:00 2001 From: Zach Day Date: Thu, 16 Nov 2017 13:08:42 -0500 Subject: [PATCH 086/122] Add task for starting 1hz timer The `sch_lab` app appeared not to do anything because the CFE's 1hz timer, implemented as a SIGALRM handler on POSIX, was never started. This commit adds logic to `ostask.c` to use `sl` to serve as the timer. Additionally, more CFE symbols have been added to the assembly stub. --- .../no_interface/cFE_booter/ostask.c | 24 +++++++++++++++++++ src/components/interface/cFE/stubs/s_stub.S | 9 +++++++ 2 files changed, 33 insertions(+) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 3a3467dec8..6ceb336abf 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -9,6 +9,24 @@ #include +void +timer_fn_1hz(void *d) +{ + int first = 0; + cycles_t now, start; + + rdtscll(start); + start += sl_usec2cyc(250000); //250ms after + + while (1) { + rdtscll(now); + if (now > start) { + CFE_TIME_Local1HzISR(); /* input param is signum. but CFE_PSP_TimerHandler doesn't seem to use it. */ + } + + sl_thd_block_periodic(0); + } +} /* ** Internal Task helper functions @@ -30,6 +48,12 @@ void OS_SchedulerStart(cos_thd_fn_t main_delegate) { policy->osal_task_prop.priority = MAIN_DELEGATE_THREAD_PRIORITY; policy->osal_task_prop.OStask_id = (uint32) main_delegate_thread->thdid; + struct sl_thd *timer_thd = sl_thd_alloc(timer_fn_1hz, NULL); + union sched_param_union spperiod = {.c = {.type = SCHEDP_WINDOW, .value = 250000 }}; + union sched_param_union spprio = {.c = {.type = SCHEDP_PRIO, .value = MAIN_DELEGATE_THREAD_PRIORITY+1}}; + sl_thd_param_set(timer_thd, spperiod.v); + sl_thd_param_set(timer_thd, spprio.v); + sl_sched_loop(); } diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index 1fbd10d489..9f618ea89e 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -64,3 +64,12 @@ cos_asm_server_stub(CFE_TBL_Share) cos_asm_server_stub(CFE_TBL_Unregister) cos_asm_server_stub(OS_close) cos_asm_server_stub(OS_open) + +cos_asm_server_stub(CFE_ES_GetPoolBuf) +cos_asm_server_stub(CFE_ES_PoolCreate) +cos_asm_server_stub(CFE_ES_PutPoolBuf) +cos_asm_server_stub(CFE_SB_GetUserData) +cos_asm_server_stub(CFE_TBL_DumpToBuffer) +cos_asm_server_stub(CFE_TBL_GetStatus) +cos_asm_server_stub(CFE_TBL_Update) +cos_asm_server_stub(CFE_TBL_Validate) From 993190fe86434440b645f98b747bbb5d168f1ffc Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 27 Nov 2017 13:58:22 -0500 Subject: [PATCH 087/122] Fix buffer overrun in sl_thd_policy array + cleanup redundant code --- .../no_interface/cFE_booter/Makefile | 2 +- .../no_interface/cFE_booter/osloader.c | 2 - .../no_interface/cFE_booter/ostask.c | 2 +- .../no_interface/cFE_booter/sl_mod_fprr.c | 5 -- .../no_interface/cFE_booter/sl_mod_policy.h | 6 +-- .../cFE_booter/sl_thd_static_backend.c | 46 +++++++++++++++++++ 6 files changed, 51 insertions(+), 12 deletions(-) create mode 100644 src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index 3273f8bae0..6ada829bd0 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -4,7 +4,7 @@ COMPONENT=cFE_booter.o INTERFACES=cFE DEPENDENCIES= IF_LIB:=./composite_cFE.o $(wildcard test/*.o) -ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api -lcos_defkernel_api -lsl -lheap -lsl_thd_static_backend -lsl_lock +ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api -lcos_defkernel_api -lsl -lheap -lsl_lock include ../../Makefile.subsubdir CFLAGS += -I./gen -I ./test/shared $(CPPFLAGS) diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index 7833a87664..bd594c416a 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -12,7 +12,6 @@ #define USER_CAPS_SYMB_NAME "ST_user_caps" -int cobj_count; struct cobj_header *hs[MAX_NUM_SPDS+1]; static void @@ -44,7 +43,6 @@ find_cobjs(struct cobj_header *h, int n) } hs[n] = NULL; - cobj_count = i; printc("cobj %s:%d found at %p -> %x\n", hs[n-1]->name, hs[n-1]->id, hs[n-1], cobj_sect_get(hs[n-1], 0)->vaddr); diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 3a3467dec8..41994e9584 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -102,6 +102,7 @@ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, policy->osal_task_prop.stack_size = stack_size; policy->osal_task_prop.priority = priority; policy->osal_task_prop.OStask_id = (uint32) thd->thdid; + policy->delete_handler = NULL; *task_id = (uint32) thd->thdid; @@ -115,7 +116,6 @@ int32 OS_TaskDelete(uint32 task_id) return OS_ERR_INVALID_ID; } - struct sl_thd_policy* thd_policy = sl_mod_thd_policy_get(thd); osal_task_entry delete_handler = thd_policy->delete_handler; diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c index 934d37e53b..6d7412aa6b 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c +++ b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c @@ -18,9 +18,6 @@ void sl_mod_execution(struct sl_thd_policy *t, cycles_t cycles) { } - -volatile int global = 0; - struct sl_thd_policy * sl_mod_schedule(void) { @@ -33,8 +30,6 @@ sl_mod_schedule(void) struct sl_thd *thd = sl_mod_thd_get(t); - global++; - /* * We want to move the selected thread to the back of the list. * Otherwise fprr won't be truly round robin diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h b/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h index ed862c60a9..329910b5cb 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h +++ b/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h @@ -1,5 +1,5 @@ -#ifndef SL_MOD_POLICY_H -#define SL_MOD_POLICY_H +#ifndef SL_CUSTOM_MOD_POLICY_H +#define SL_CUSTOM_MOD_POLICY_H #include #include @@ -27,4 +27,4 @@ static inline struct sl_thd_policy * sl_mod_thd_policy_get(struct sl_thd *t) { return ps_container(t, struct sl_thd_policy, thd); } -#endif /* SL_MOD_POLICY_H */ +#endif /* SL_CUSTOM_MOD_POLICY_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c b/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c new file mode 100644 index 0000000000..11ff73774c --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c @@ -0,0 +1,46 @@ +/** + * Redistribution of this file is permitted under the BSD two clause license. + * + * Copyright 2017, The George Washington University + * Author: Gabriel Parmer, gparmer@gwu.edu + */ + +#include +#include +#include +#include + +#include "sl_mod_policy.h" + +static struct sl_thd_policy sl_threads[SL_MAX_NUM_THDS]; + +/* Default implementations of backend functions */ +struct sl_thd_policy * +sl_thd_alloc_backend(thdid_t tid) +{ + assert(tid < SL_MAX_NUM_THDS); + return &sl_threads[tid]; +} + +void +sl_thd_free_backend(struct sl_thd_policy *t) +{ } + +void +sl_thd_index_add_backend(struct sl_thd_policy *t) +{ } + +void +sl_thd_index_rem_backend(struct sl_thd_policy *t) +{ } + +struct sl_thd_policy * +sl_thd_lookup_backend(thdid_t tid) +{ + assert(tid < SL_MAX_NUM_THDS); + return &sl_threads[tid]; +} + +void +sl_thd_init_backend(void) +{ assert(SL_MAX_NUM_THDS <= MAX_NUM_THREADS); } From 4c557d6f895d0907e0800f52cd9100edf55e37ec Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sun, 21 Jan 2018 13:30:16 -0500 Subject: [PATCH 088/122] Add logging to llbooter --- .../no_interface/llbooter/boot_deps.h | 9 ++++-- .../no_interface/llbooter/llbooter.c | 28 ++++++++++++++----- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/components/implementation/no_interface/llbooter/boot_deps.h b/src/components/implementation/no_interface/llbooter/boot_deps.h index cf9d94cf55..04176bbd48 100644 --- a/src/components/implementation/no_interface/llbooter/boot_deps.h +++ b/src/components/implementation/no_interface/llbooter/boot_deps.h @@ -53,9 +53,9 @@ boot_comp_pgtbl_expand(size_t n_pte, pgtblcap_t pt, vaddr_t vaddr, struct cobj_h if (tot % SERVICE_SIZE) n_pte++; } - for (i = 0; i < n_pte; i++) { - if (!cos_pgtbl_intern_alloc(&boot_info, pt, vaddr, SERVICE_SIZE)) BUG(); - } + printc("Expanding pgtbl by %d\n", (int) n_pte); + int ret = cos_pgtbl_intern_alloc(&boot_info, pt, vaddr, SERVICE_SIZE * n_pte); + if (!ret) BUG(); } /* Initialize just the captblcap and pgtblcap, due to hack for upcall_fn addr */ @@ -136,10 +136,13 @@ boot_newcomp_create(spdid_t spdid, struct cos_compinfo *comp_info) static void boot_bootcomp_init(void) { + printc("boot_bootcomp_init\n"); cos_meminfo_init(&boot_info.mi, BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); cos_compinfo_init(&boot_info, BOOT_CAPTBL_SELF_PT, BOOT_CAPTBL_SELF_CT, BOOT_CAPTBL_SELF_COMP, (vaddr_t)cos_get_heap_ptr(), BOOT_CAPTBL_FREE, &boot_info); + printc("boot_bootcomp_init done\n"); + } static void diff --git a/src/components/implementation/no_interface/llbooter/llbooter.c b/src/components/implementation/no_interface/llbooter/llbooter.c index e45e97ca87..3813466143 100644 --- a/src/components/implementation/no_interface/llbooter/llbooter.c +++ b/src/components/implementation/no_interface/llbooter/llbooter.c @@ -65,10 +65,12 @@ boot_comp_map_memory(struct cobj_header *h, spdid_t spdid, pgtblcap_t pt) int n_pte = 1; struct cobj_sect *sect = cobj_sect_get(h, 0); + printc("expanding pgtbl...\n"); boot_comp_pgtbl_expand(n_pte, pt, sect->vaddr, h); /* We'll map the component into booter's heap. */ + printc("mapping component into booter's heap...\n"); for (i = 0; i < (int)h->nsect; i++) { int left; @@ -115,6 +117,7 @@ boot_spd_end(struct cobj_header *h) int boot_spd_symbs(struct cobj_header *h, spdid_t spdid, vaddr_t *comp_info, vaddr_t *user_caps) { + printc("boot_spd_symbs\n"); int i = 0; for (i = 0; i < (int)h->nsymb; i++) { @@ -136,6 +139,7 @@ boot_spd_symbs(struct cobj_header *h, spdid_t spdid, vaddr_t *comp_info, vaddr_t break; } } + printc("boot_spd_symbs done\n"); return 0; } @@ -226,7 +230,9 @@ boot_comp_map_populate(struct cobj_header *h, spdid_t spdid, vaddr_t comp_info) int boot_comp_map(struct cobj_header *h, spdid_t spdid, vaddr_t comp_info, pgtblcap_t pt) { + printc("Mapping memory...\n"); boot_comp_map_memory(h, spdid, pt); + printc("Populating memory...\n"); boot_comp_map_populate(h, spdid, comp_info); return 0; } @@ -244,26 +250,26 @@ int boot_spd_inv_cap_alloc(struct cobj_header *h, spdid_t spdid) { struct cobj_cap *cap; - struct usr_inv_cap inv_cap; + struct usr_inv_cap inv_cap; int cap_offset; - int i; + int i; for (i = 0; i < h->ncap ; i++) { - + cap = cobj_cap_get(h, i); assert(cap); /* 0 index of inv_cap array is special, so start at 1 */ - cap_offset = cap->cap_off + 1; + cap_offset = cap->cap_off + 1; /* Create the user cap for the undef symb */ inv_cap = (struct usr_inv_cap) { .invocation_fn = (vaddr_t) cap->cstub, .service_entry_inst = (vaddr_t) cap->sstub, .invocation_count = cap->dest_id - }; - - new_comp_cap_info[spdid].ST_user_caps[cap_offset] = inv_cap; + }; + + new_comp_cap_info[spdid].ST_user_caps[cap_offset] = inv_cap; } return 0; } @@ -285,13 +291,21 @@ boot_create_cap_system(void) spdid = h->id; sect = cobj_sect_get(h, 0); + + printc("\nCreating comp %d (%s) @ %x!\n", h->id, h->name, sect->vaddr); + + new_comp_cap_info[spdid].addr_start = sect->vaddr; boot_compinfo_init(spdid, &ct, &pt, sect->vaddr); + printc("Doing spd symbs\n"); if (boot_spd_symbs(h, spdid, &ci, &new_comp_cap_info[spdid].vaddr_user_caps)) BUG(); + printc("Doing spd invocation capability allocation\n"); if (boot_spd_inv_cap_alloc(h, spdid)) BUG(); + printc("Doing component map\n"); if (boot_comp_map(h, spdid, ci, pt)) BUG(); + printc("Actually creating the new component...\n"); boot_newcomp_create(spdid, new_comp_cap_info[spdid].compinfo); printc("\nComp %d (%s) created @ %x!\n\n", h->id, h->name, sect->vaddr); } From dcdddf1dca1fe0e9b3431bc3dfd512b1439b2dd3 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Fri, 16 Feb 2018 18:13:09 -0500 Subject: [PATCH 089/122] Convert the cFE to boot multicomponent This rips out much of our loading infrastructure, and replaces it with code to support multicomponent stuff. This breaks a lot, so this commit is really more of regression than anything else... Nessesary for forward progress though! --- .../no_interface/cFE_booter/osloader.c | 745 +------ .../no_interface/cFE_booter/ostask.c | 11 +- .../no_interface/llbooter/inv.S | 2 +- .../no_interface/llbooter/llbooter.c | 3 +- .../no_interface/sample_app/Makefile | 2 +- .../no_interface/sample_app/init.c | 14 + .../no_interface/sample_lib/Makefile | 2 +- .../no_interface/sample_lib/init.c | 14 + .../no_interface/sch_lab/Makefile | 2 +- .../no_interface/sch_lab/init.c | 14 + src/components/include/sl.h | 15 +- src/components/interface/cFE/ccsds.h | 463 ---- src/components/interface/cFE/cfe.h | 81 - src/components/interface/cFE/cfe_error.h | 1317 ------------ src/components/interface/cFE/cfe_es.h | 1604 -------------- src/components/interface/cFE/cfe_es_events.h | 1562 -------------- src/components/interface/cFE/cfe_es_msg.h | 1666 --------------- src/components/interface/cFE/cfe_es_perfids.h | 86 - src/components/interface/cFE/cfe_evs.h | 427 ---- src/components/interface/cFE/cfe_evs_events.h | 704 ------- src/components/interface/cFE/cfe_evs_msg.h | 1188 ----------- src/components/interface/cFE/cfe_fs.h | 363 ---- .../interface/cFE/cfe_mission_cfg.h | 477 ----- .../interface/cFE/cfe_platform_cfg.h | 1857 ----------------- src/components/interface/cFE/cfe_psp.h | 422 ---- src/components/interface/cFE/cfe_psp_config.h | 57 - .../interface/cFE/cfe_psp_configdata.h | 88 - src/components/interface/cFE/cfe_sb.h | 1267 ----------- src/components/interface/cFE/cfe_sb_events.h | 798 ------- src/components/interface/cFE/cfe_sb_msg.h | 769 ------- src/components/interface/cFE/cfe_tbl.h | 858 -------- src/components/interface/cFE/cfe_tbl_events.h | 1082 ---------- .../interface/cFE/cfe_tbl_filedef.h | 122 -- src/components/interface/cFE/cfe_tbl_msg.h | 851 -------- src/components/interface/cFE/cfe_time.h | 939 --------- .../interface/cFE/cfe_time_events.h | 592 ------ src/components/interface/cFE/cfe_time_msg.h | 1187 ----------- src/components/interface/cFE/cfe_version.h | 83 - src/components/interface/cFE/common_types.h | 374 ---- .../interface/cFE/network_includes.h | 104 - src/components/interface/cFE/osapi-os-core.h | 330 --- .../interface/cFE/osapi-os-filesys.h | 440 ---- .../interface/cFE/osapi-os-loader.h | 104 - src/components/interface/cFE/osapi-os-net.h | 129 -- src/components/interface/cFE/osapi-os-timer.h | 82 - src/components/interface/cFE/osapi-version.h | 69 - src/components/interface/cFE/osapi.h | 149 -- src/components/interface/cFE/osconfig.h | 219 -- src/components/interface/cFE/psp_version.h | 44 - src/components/interface/cFE/stubs/s_stub.S | 54 +- src/components/lib/Makefile | 2 +- src/components/lib/cFE_emu.c | 21 + src/components/lib/sl/sl.c | 32 +- src/platform/i386/runscripts/llboot_cFE.sh | 3 +- 54 files changed, 178 insertions(+), 23712 deletions(-) create mode 100644 src/components/implementation/no_interface/sample_app/init.c create mode 100644 src/components/implementation/no_interface/sample_lib/init.c create mode 100644 src/components/implementation/no_interface/sch_lab/init.c delete mode 100644 src/components/interface/cFE/ccsds.h delete mode 100644 src/components/interface/cFE/cfe.h delete mode 100644 src/components/interface/cFE/cfe_error.h delete mode 100644 src/components/interface/cFE/cfe_es.h delete mode 100644 src/components/interface/cFE/cfe_es_events.h delete mode 100644 src/components/interface/cFE/cfe_es_msg.h delete mode 100644 src/components/interface/cFE/cfe_es_perfids.h delete mode 100644 src/components/interface/cFE/cfe_evs.h delete mode 100644 src/components/interface/cFE/cfe_evs_events.h delete mode 100644 src/components/interface/cFE/cfe_evs_msg.h delete mode 100644 src/components/interface/cFE/cfe_fs.h delete mode 100644 src/components/interface/cFE/cfe_mission_cfg.h delete mode 100644 src/components/interface/cFE/cfe_platform_cfg.h delete mode 100644 src/components/interface/cFE/cfe_psp.h delete mode 100644 src/components/interface/cFE/cfe_psp_config.h delete mode 100644 src/components/interface/cFE/cfe_psp_configdata.h delete mode 100644 src/components/interface/cFE/cfe_sb.h delete mode 100644 src/components/interface/cFE/cfe_sb_events.h delete mode 100644 src/components/interface/cFE/cfe_sb_msg.h delete mode 100644 src/components/interface/cFE/cfe_tbl.h delete mode 100644 src/components/interface/cFE/cfe_tbl_events.h delete mode 100644 src/components/interface/cFE/cfe_tbl_filedef.h delete mode 100644 src/components/interface/cFE/cfe_tbl_msg.h delete mode 100644 src/components/interface/cFE/cfe_time.h delete mode 100644 src/components/interface/cFE/cfe_time_events.h delete mode 100644 src/components/interface/cFE/cfe_time_msg.h delete mode 100644 src/components/interface/cFE/cfe_version.h delete mode 100644 src/components/interface/cFE/common_types.h delete mode 100644 src/components/interface/cFE/network_includes.h delete mode 100644 src/components/interface/cFE/osapi-os-core.h delete mode 100644 src/components/interface/cFE/osapi-os-filesys.h delete mode 100644 src/components/interface/cFE/osapi-os-loader.h delete mode 100644 src/components/interface/cFE/osapi-os-net.h delete mode 100644 src/components/interface/cFE/osapi-os-timer.h delete mode 100644 src/components/interface/cFE/osapi-version.h delete mode 100644 src/components/interface/cFE/osapi.h delete mode 100644 src/components/interface/cFE/osconfig.h delete mode 100644 src/components/interface/cFE/psp_version.h create mode 100644 src/components/lib/cFE_emu.c diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index 0087042e42..faf30e58cf 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -2,737 +2,106 @@ #include #include +#include +#include +#include #include "cFE_util.h" #include "gen/osapi.h" #include "gen/common_types.h" -#include "gen/cfe_es.h" -#include "gen/cfe_evs.h" -#include "gen/cfe_tbl.h" - -#define USER_CAPS_SYMB_NAME "ST_user_caps" - -struct cobj_header *hs[MAX_NUM_SPDS+1]; - -static void -find_cobjs(struct cobj_header *h, int n) -{ - int i; - vaddr_t start, end; - - start = (vaddr_t)h; - - printc("First cobj is '%s'.\n", h->name); - - hs[0] = h; - - for (i = 1 ; i < n ; i++) { - int j = 0, size = 0, tot = 0; - - size = h->size; - for (j = 0 ; j < (int)h->nsect ; j++) { - tot += cobj_sect_size(h, j); - } - - printc("cobj %s:%d found at %p:%x, size %x -> %x\n", - h->name, h->id, hs[i-1], size, tot, cobj_sect_get(hs[i-1], 0)->vaddr); - - end = start + round_up_to_cacheline(size); - hs[i] = h = (struct cobj_header*)end; - start = end; - } - - hs[n] = NULL; - - printc("cobj %s:%d found at %p -> %x\n", - hs[n-1]->name, hs[n-1]->id, hs[n-1], cobj_sect_get(hs[n-1], 0)->vaddr); - -} - -struct module_internal_record { - int free; - cpuaddr entry_point; - uint32 host_module_id; - char filename[OS_MAX_PATH_LEN]; - char name[OS_MAX_API_NAME]; - struct cobj_header *header; -}; - -struct module_internal_record module_table[OS_MAX_MODULES]; - -#define INIT_STR_SZ 52 -struct component_init_str { - unsigned int spdid, schedid; - int startup; - char init_str[INIT_STR_SZ]; -}__attribute__((packed)); - -struct component_init_str *init_args; int32 OS_ModuleTableInit(void) { - struct cobj_header *h = (struct cobj_header *)cos_comp_info.cos_poly[0]; - - int num_cobj = (int)cos_comp_info.cos_poly[1]; - - init_args = (struct component_init_str *)cos_comp_info.cos_poly[3]; - init_args++; - - find_cobjs(h, num_cobj); - - uint32 i; - for (i = 0; i < OS_MAX_MODULES; i++) { - module_table[i].free = TRUE; - module_table[i].entry_point = 0; - module_table[i].host_module_id = 0; - strcpy(module_table[i].name, ""); - strcpy(module_table[i].filename, ""); - } - - /* TODO: Module table mutex. */ - - return OS_ERR_NOT_IMPLEMENTED; -} - -struct user_cap { - void (*invfn)(void); - int entryfn, invcount, capnum; -} __attribute__((packed)); - -struct symbol_of_jank { - char name[64]; - void *fn; -}; - -struct symbol_of_jank soj[] = { - { .name = "OS_printf", .fn = OS_printf }, - { .name = "OS_close", .fn = OS_close }, - { .name = "OS_open", .fn = OS_open }, - { .name = "OS_TaskInstallDeleteHandler", .fn = OS_TaskInstallDeleteHandler }, - { .name = "OS_TaskDelay", .fn = OS_TaskDelay }, - { .name = "CFE_ES_ExitApp", .fn = CFE_ES_ExitApp }, - { .name = "CFE_ES_PerfLogAdd", .fn = CFE_ES_PerfLogAdd }, - { .name = "CFE_ES_RegisterApp", .fn = CFE_ES_RegisterApp }, - { .name = "CFE_EVS_Register", .fn = CFE_EVS_Register }, - { .name = "CFE_EVS_SendEvent", .fn = CFE_EVS_SendEvent }, - { .name = "CFE_SB_CreatePipe", .fn = CFE_SB_CreatePipe }, - { .name = "CFE_SB_GetCmdCode", .fn = CFE_SB_GetCmdCode }, - { .name = "CFE_SB_GetMsgId", .fn = CFE_SB_GetMsgId }, - { .name = "CFE_SB_GetTotalMsgLength", .fn = CFE_SB_GetTotalMsgLength }, - { .name = "CFE_SB_RcvMsg", .fn = CFE_SB_RcvMsg }, - { .name = "CFE_SB_SendMsg", .fn = CFE_SB_SendMsg }, - { .name = "CFE_SB_Subscribe", .fn = CFE_SB_Subscribe }, - { .name = "CFE_SB_TimeStampMsg", .fn = CFE_SB_TimeStampMsg }, - { .name = "CFE_ES_RunLoop", .fn = CFE_ES_RunLoop }, - { .name = "CFE_SB_InitMsg", .fn = CFE_SB_InitMsg }, - { .name = "CFE_SB_MessageStringGet", .fn = CFE_SB_MessageStringGet }, - { .name = "CFE_SB_SubscribeEx", .fn = CFE_SB_SubscribeEx }, - { .name = "CFE_SB_Unsubscribe", .fn = CFE_SB_Unsubscribe }, - { .name = "CFE_ES_RegisterChildTask", .fn = CFE_ES_RegisterChildTask }, - { .name = "CFE_ES_CalculateCRC", .fn = CFE_ES_CalculateCRC }, - { .name = "CFE_ES_CopyToCDS", .fn = CFE_ES_CopyToCDS }, - { .name = "CFE_ES_CreateChildTask", .fn = CFE_ES_CreateChildTask }, - { .name = "CFE_ES_DeleteChildTask", .fn = CFE_ES_DeleteChildTask }, - { .name = "CFE_ES_ExitChildTask", .fn = CFE_ES_ExitChildTask }, - { .name = "CFE_ES_GetAppID", .fn = CFE_ES_GetAppID }, - { .name = "CFE_ES_GetAppIDByName", .fn = CFE_ES_GetAppIDByName }, - { .name = "CFE_ES_GetAppInfo", .fn = CFE_ES_GetAppInfo }, - { .name = "CFE_ES_GetAppName", .fn = CFE_ES_GetAppName }, - { .name = "CFE_ES_RegisterCDS", .fn = CFE_ES_RegisterCDS }, - { .name = "CFE_ES_RegisterChildTask", .fn = CFE_ES_RegisterChildTask }, - { .name = "CFE_ES_RestoreFromCDS", .fn = CFE_ES_RestoreFromCDS }, - { .name = "CFE_ES_WaitForStartupSync", .fn = CFE_ES_WaitForStartupSync }, - { .name = "CFE_ES_WriteToSysLog", .fn = CFE_ES_WriteToSysLog }, - { .name = "CFE_PSP_GetCFETextSegmentInfo", .fn = CFE_PSP_GetCFETextSegmentInfo }, - { .name = "CFE_PSP_GetKernelTextSegmentInfo", .fn = CFE_PSP_GetKernelTextSegmentInfo }, - { .name = "CFE_PSP_MemCpy", .fn = CFE_PSP_MemCpy }, - { .name = "CFE_PSP_MemSet", .fn = CFE_PSP_MemSet }, - { .name = "CFE_PSP_MemValidateRange", .fn = CFE_PSP_MemValidateRange }, - { .name = "CFE_TBL_GetAddress", .fn = CFE_TBL_GetAddress }, - { .name = "CFE_TBL_GetInfo", .fn = CFE_TBL_GetInfo }, - { .name = "CFE_TBL_Load", .fn = CFE_TBL_Load }, - { .name = "CFE_TBL_Manage", .fn = CFE_TBL_Manage }, - { .name = "CFE_TBL_Modified", .fn = CFE_TBL_Modified }, - { .name = "CFE_TBL_Register", .fn = CFE_TBL_Register }, - { .name = "CFE_TBL_ReleaseAddress", .fn = CFE_TBL_ReleaseAddress }, - { .name = "CFE_TBL_Share", .fn = CFE_TBL_Share }, - { .name = "CFE_TBL_Unregister", .fn = CFE_TBL_Unregister }, - { .name = "", .fn = NULL }, -}; - -struct symbol_of_jank* lookup_symbol_in_soj(const char *symb_name) -{ - size_t i; - - for (i = 0; soj[i].fn != NULL; i++) { - if (!strcmp(symb_name, soj[i].name)) { - /* We have found the matching SOJ. */ - - printc("Found matching SOJ @ %p for undef '%s'.\n", soj[i].fn, symb_name); - - return &soj[i]; - } - } - - return &soj[i]; -} - -/* -** Loader API -*/ - - -struct cobj_header *get_cobj_header(const char* path) -{ - char name[OS_MAX_PATH_LEN]; - - - printc("cobj: Object path is %s\n", path); - - int slash_index; - for (slash_index = strlen(path); path[slash_index] != '/' && slash_index != 0; slash_index--) { - } - - if (slash_index == 0) { - PANIC("Could not find slash in object name, aborting..."); - } - - /* We just want the name after the slash_index */ - strcpy(name, path + slash_index + 1); - - printc("cobj: Object name appears to be %s\n", name); - - /* But before the '.' */ - int dot_index; - for (dot_index = 0; name[dot_index] != '.' && name[dot_index] != '\0'; dot_index++) { - } - - if (name[dot_index] == '\0') { - PANIC("Invalid object name, aborting..."); - } - - name[dot_index] = '\0'; - - printc("cobj: Trimmed object name appears to be %s\n", name); - - int cobj_index; - for (cobj_index = 0; hs[cobj_index] != NULL; cobj_index++) { - if (!strcmp(hs[cobj_index]->name, name)) { - return hs[cobj_index]; - } - } - return NULL; -} - -struct user_cap *find_user_caps(struct cobj_header *h) -{ - size_t i; - - for (i = 0; i < h->nsymb; i++) { - struct cobj_symb *curr = cobj_symb_get(h, i); - if (!strcmp(curr->name, USER_CAPS_SYMB_NAME)) { - - printc("cobj: found user caps array '%s' @ %x.\n", USER_CAPS_SYMB_NAME, curr->vaddr); - - - /* Set to the first user cap in the array. */ - return (struct user_cap *) (intptr_t) curr->vaddr; - } - } - PANIC("Could not find user capability array!\n"); - return NULL; -} - -void inspect_cobj_symbols(struct cobj_header *h, vaddr_t *comp_info) -{ - unsigned int i; - - - printc("cobj: getting spd symbs for header %s, nsymbs %d.\n", h->name, h->nsymb); - - - for (i = 0 ; i < h->nsymb ; i++) { - struct cobj_symb *symb; - - symb = cobj_symb_get(h, i); - assert(symb); - - if (symb->type == COBJ_SYMB_UNDEF) { - - printc("cobj: undefined symbol %s: nsymb %d, usercap offset %d\n", symb->name, i, symb->user_caps_offset); - - continue; - } else if (symb->type == COBJ_SYMB_EXPORTED) { - - printc("cobj: exported symbol %s: nsymb %d, addr %x\n", symb->name, i, symb->vaddr); - - continue; - } - - switch (symb->type) { - case COBJ_SYMB_COMP_INFO: - - printc("cobj: comp info %s: addr %x\n", symb->name, symb->vaddr); - - *comp_info = symb->vaddr; - break; - case COBJ_SYMB_COMP_PLT: - /* Otherwise known as ST_user_caps. */ - - printc("cobj: capability array %s: addr %x\n", symb->name, symb->vaddr); - - break; - default: - - printc("boot: Unknown symbol type %d\n", symb->type); - - break; - } - } -} - -static void -expand_pgtbl(int n_pte, pgtblcap_t pt, vaddr_t vaddr, struct cobj_header *h) -{ - - printc("expand_pgtbl(%d, %lu, %lu, %p)\n", n_pte, pt, vaddr, h); - - int i; - int tot = 0; - - struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); - struct cos_compinfo *ci = cos_compinfo_get(defci); - - /* Expand Page table, could do this faster */ - for (i = 0 ; i < (int)h->nsect ; i++) { - tot += cobj_sect_size(h, i); - } - - if (tot > SERVICE_SIZE) { - n_pte = tot / SERVICE_SIZE; - if (tot % SERVICE_SIZE) n_pte++; - } - - for (i = 0 ; i < n_pte ; i++) { - - printc("cos_pgtbl_intern_alloc(%p, %lu, %lu, %d)\n", ci, pt, vaddr, SERVICE_SIZE); - - if (!cos_pgtbl_intern_alloc(ci, pt, vaddr, SERVICE_SIZE)) PANIC("BUG"); - } -} - -static vaddr_t -map_cobj_section(vaddr_t dest_daddr) -{ - struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); - struct cos_compinfo *ci = cos_compinfo_get(defci); - - vaddr_t addr = (vaddr_t) cos_page_bump_alloc(ci); - assert(addr); - - if (cos_mem_alias_at(ci, dest_daddr, ci, addr)) PANIC("BUG"); - - return addr; -} - -void map_cobj_memory(struct cobj_header *h, pgtblcap_t pt) { - int i; - int flag; - vaddr_t dest_daddr, prev_map = 0; - int n_pte = 1; - struct cobj_sect *sect = cobj_sect_get(h, 0); - - - printc("cobj: Expanding pgtbl\n"); - - - expand_pgtbl(n_pte, pt, sect->vaddr, h); - - /* NOTE: We just hardcode this, since we also want to map into this components memory` */ - /* We'll map the component into booter's heap. */ - // new_comp_cap_info[spdid].vaddr_mapped_in_booter = (vaddr_t)cos_get_heap_ptr(); - - for (i = 0 ; i < (int)h->nsect ; i++) { - int left; - - sect = cobj_sect_get(h, i); - flag = MAPPING_RW; - if (sect->flags & COBJ_SECT_KMEM) { - flag |= MAPPING_KMEM; - } - - dest_daddr = sect->vaddr; - left = cobj_sect_size(h, i); - - /* previous section overlaps with this one, don't remap! */ - if (round_to_page(dest_daddr) == prev_map) { - left -= (prev_map + PAGE_SIZE - dest_daddr); - dest_daddr = prev_map + PAGE_SIZE; - } - - while (left > 0) { - map_cobj_section(dest_daddr); - - prev_map = dest_daddr; - dest_daddr += PAGE_SIZE; - left -= PAGE_SIZE; - } - } + return OS_SUCCESS; } -static int -process_cinfo(struct cobj_header *h, spdid_t spdid, vaddr_t heap_val, - char *mem, vaddr_t symb_addr) +int32 OS_ModuleLoad(uint32 *module_id, const char *module_name, const char *filename) { - int i; - struct cos_component_information *ci; - - assert(symb_addr == round_to_page(symb_addr)); - ci = (struct cos_component_information*)(mem); - - if (!ci->cos_heap_ptr) ci->cos_heap_ptr = heap_val; - - ci->cos_this_spd_id = spdid; - ci->init_string[0] = '\0'; - - for (i = 0 ; init_args[i].spdid ; i++) { - char *start, *end; - int len; - - if (init_args[i].spdid != spdid) continue; - - start = strchr(init_args[i].init_str, '\''); - if (!start) break; - start++; - end = strchr(start, '\''); - if (!end) break; - len = (int)(end-start); - memcpy(&ci->init_string[0], start, len); - ci->init_string[len] = '\0'; - } - - return 1; + return OS_SUCCESS; } -static vaddr_t -find_end(struct cobj_header *h) +int32 OS_ModuleUnload(uint32 module_id) { - struct cobj_sect *sect; - int max_sect; - - max_sect = h->nsect-1; - sect = cobj_sect_get(h, max_sect); - - return sect->vaddr + round_up_to_page(sect->bytes); -} - - -void populate_cobj_memory(struct cobj_header *h, spdid_t spdid, vaddr_t comp_info, int first_time) { - unsigned int i; - /* Where are we in the actual component's memory in the booter? */ - char *start_addr; - /* Where are we in the destination address space? */ - vaddr_t init_daddr; - - // TODO: Verify this transformation is correct - // start_addr = (char *)(new_comp_cap_info[spdid].vaddr_mapped_in_booter); - start_addr = (char *) cos_get_heap_ptr(); - - init_daddr = cobj_sect_get(h, 0)->vaddr; - for (i = 0 ; i < h->nsect ; i++) { - struct cobj_sect *sect; - vaddr_t dest_daddr; - char *lsrc; - int left; - - sect = cobj_sect_get(h, i); - /* virtual address in the destination address space */ - dest_daddr = sect->vaddr; - /* where we're copying from in the cobj */ - lsrc = cobj_sect_contents(h, i); - /* how much is left to copy? */ - left = cobj_sect_size(h, i); - - printc("Destination is %p\n", (void*) dest_daddr); - - /* Initialize memory. */ - if (!(sect->flags & COBJ_SECT_KMEM) && - (first_time || !(sect->flags & COBJ_SECT_INITONCE))) { - if (sect->flags & COBJ_SECT_ZEROS) { - char * to = (char *) dest_daddr; - - printc("Zeroing some memory %p (%d bytes)!\n", to, left); - - - // HACK: Should actually resolve this - // memset(start_addr + (dest_daddr - init_daddr), 0, left); - memset(to, 0, left); - } else { - char * to = (char *) dest_daddr; - char * from = lsrc; - - printc("Setting some memory to %p from %p (%d bytes)!\n", to, from, left); - - // HACK: Should actually resolve this - // memcpy(start_addr + (dest_daddr - init_daddr), lsrc, left); - memcpy(to, from, left); - } - } - - if (sect->flags & COBJ_SECT_CINFO) { - assert(left == PAGE_SIZE); - assert(comp_info == dest_daddr); - process_cinfo(h, spdid, find_end(h), start_addr + (comp_info-init_daddr), comp_info); - // NOTE: This is useless, since we never upcall - // struct cos_component_information *ci; - // ci = (struct cos_component_information*)(start_addr + (comp_info-init_daddr)); - // new_comp_cap_info[h->id].upcall_entry = ci->cos_upcall_entry; - - } - } - + return OS_SUCCESS; } +void launch_other_component(int component_id) { + struct cos_defcompinfo *dci; + struct cos_compinfo *ci; + struct sl_thd *t; -void setup_cobj_memory(struct cobj_header *h, spdid_t spdid, vaddr_t comp_info, pgtblcap_t pt) -{ - /* Allocating memory and mapping it to the booter's address space */ + thdcap_t thd; + struct cos_aep_info udpserv_aep; - printc("cobj: doing map_cobj_memory\n"); + dci = cos_defcompinfo_curr_get(); + assert(dci); + ci = cos_compinfo_get(dci); + assert(ci); - map_cobj_memory(h, pt); + // HACK: Fix me + int spdid = 1; + int cap_index = (int)cos_hypervisor_hypercall(BOOT_HYP_COMP_CAP, + (void *)spdid, + (void *)component_id, ci); + assert(cap_index > 0); - printc("cobj: doing populate_cobj_memory\n"); + thd = cos_initthd_alloc(ci, cap_index); + assert(thd); - populate_cobj_memory(h, spdid, comp_info, 1); + udpserv_aep.thd = thd; + t = sl_thd_init(&udpserv_aep, 0); + sl_thd_param_set(t, sched_param_pack(SCHEDP_PRIO, 1)); + sl_thd_yield(t->thdid); } +// Component proxy hack +// To add new component: +// 1) Do all the cFE stuff +// 2) Create a component from the app +// 3) Add an init routine in the component +// 4) Add a proxy here -void load_cobj_into_memory(struct cobj_header *h) -{ - vaddr_t ci = 0; - pgtblcap_t pt = BOOT_CAPTBL_SELF_PT; - spdid_t spdid = h->id; - - printc("cobj: Loading cobj with id %d, name %s\n", h->id, h->name); - - - // NOTE: We end up not needing this information - // struct cobj_sect *sect; - // sect = cobj_sect_get(h, 0); - // new_comp_cap_info[spdid].addr_start = sect->vaddr; - - - inspect_cobj_symbols(h, &ci); - - if (ci == 0) { - PANIC("Could not find component info in cobj!"); - } - - - printc("Mapping cobj '%s'.\n", h->name); - - setup_cobj_memory(h, spdid, ci, pt); +void sample_lib_proxy() { + launch_other_component(2); } -void link_cobj(struct cobj_header *h, struct user_cap *user_caps) -{ - unsigned int i; - - - printc("link: printing symbols of jank.\n"); - for (i = 0; soj[i].fn != NULL; i++) { - printc("\tlink: symbol of jank %d '%s' with fn @ %p\n", i, soj[i].name, soj[i].fn); - } - - /* Iterate through each symbol in the header. If it is undefined, index into the user caps array and set the `invfn`. */ - printc("link: parsing symbols for cobj header '%s'.\n", h->name); - - for (i = 0; i < h->nsymb; i++) { - struct cobj_symb *symb = cobj_symb_get(h, i); - assert(symb); - - if (symb->type == COBJ_SYMB_UNDEF) { - - printc("link: found undefined symbol '%s': nsymb %u, usercap offset %d\n", symb->name, i, symb->user_caps_offset); - - // FIXME: Figure out if this is an ok way to do this - // struct symbol_of_jank *symbol = lookup_symbol_in_soj(symb->name); - cpuaddr addr; - int result = OS_SymbolLookup(&addr, symb->name); - if (result != OS_SUCCESS) { - - printc("link: ERROR: could not find matching symbol for '%s'.\n", symb->name); - - PANIC("Cannot resolve symbol!"); - } - - struct user_cap cap = (struct user_cap) { - .invfn = (void *) addr - }; - - - printc("link: setting user cap index %d invfn @ %p\n", symb->user_caps_offset, cap.invfn); - - user_caps[symb->user_caps_offset] = cap; - } - } - - - printc("link: done parsing symbols for cobj header '%s'.\n", h->name); - +void sample_app_proxy() { + launch_other_component(3); } -int32 OS_ModuleLoad(uint32 *module_id, const char *module_name, const char *filename) -{ - - printc("OS_ModuleLoad start\n"); - - uint32 i; - uint32 possible_id; - - /* Check parameters. */ - if (module_id == NULL || module_name == NULL || filename == NULL) { - return OS_INVALID_POINTER; - } - - printc("OS_ModuleLoad %s %s\n", module_name, filename); - - /* Find a free id. */ - for (possible_id = 0; possible_id < OS_MAX_MODULES; possible_id++) { - if (module_table[possible_id].free == TRUE) break; - } - /* Check bounds of that id. */ - if (possible_id >= OS_MAX_MODULES || module_table[possible_id].free == FALSE) { - - printc("OS_ERR_NO_FREE_IDS\n"); - - return OS_ERR_NO_FREE_IDS; - } - - /* Check if the module was already loaded. */ - for (i = 0; i < OS_MAX_MODULES; i++) { - if (module_table[i].free == FALSE && strcmp(module_name, module_table[i].name) == 0) { - - printc("OS_ERR_NAME_TAKEN\n"); - - return OS_ERR_NAME_TAKEN; - } - } - - struct cobj_header *h = get_cobj_header(filename); - if (!h) { - - printc("Could not find cobj for designated object %s!\n", filename); - - return OS_ERROR; - } - - /* Claim the module id. */ - module_table[possible_id].free = FALSE; - - module_table[possible_id].header = h; - - struct user_cap *caps = find_user_caps(h); - - // Load + link the cobj - load_cobj_into_memory(h); - link_cobj(h, caps); - - - printc("osloader: Loading finished successfully, returning OS_SUCCESS\n"); - - return OS_SUCCESS; +void sch_lab_proxy() { + launch_other_component(4); } -cpuaddr search_cobj_for_symbol(struct cobj_header *h, const char *symbol_name) -{ - unsigned int i; - - for (i = 0 ; i < h->nsymb ; i++) { - struct cobj_symb *symb; - - symb = cobj_symb_get(h, i); - assert(symb); - +struct symbol_proxy { + char* symbol_name; + void* proxy; +}; - // TODO: Check if we need to do more work for certain symbol types (eg. undefined symbols) - if (!strcmp(symb->name, symbol_name) && symb->type == COBJ_SYMB_EXPORTED) { - return (cpuaddr) symb->vaddr; - } - } - return 0; -} +#define NUM_PROXIES 3 +struct symbol_proxy proxies[NUM_PROXIES] = { + {"SAMPLE_LibInit", sample_lib_proxy}, + {"SAMPLE_AppMain", sample_app_proxy}, + {"SCH_Lab_AppMain", sch_lab_proxy} +}; int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) { - - printc("osloader: doing symbol lookup for %s\n", symbol_name); - - /* Check parameters. */ - if (symbol_address == NULL || symbol_name == NULL) { - return OS_INVALID_POINTER; - } - - struct symbol_of_jank *jank_symbol = lookup_symbol_in_soj(symbol_name); - if (jank_symbol->fn != NULL) { - *symbol_address = (cpuaddr) jank_symbol->fn; - - printc("osloader: found soj for %s, address %p\n", symbol_name, (void *) jank_symbol->fn); - - return OS_SUCCESS; - } - int i; - for(i = 0; i < OS_MAX_MODULES; i++) { - if(!module_table[i].free) { - cpuaddr addr = search_cobj_for_symbol(module_table[i].header, symbol_name); - if (addr != 0) { - - printc("osloader: found cobj symbol for %s, address %p\n", symbol_name, (void *) addr); - - *symbol_address = addr; - return OS_SUCCESS; - } + for (i = 0; i < NUM_PROXIES; i++) { + if (!strcmp(symbol_name, proxies[i].symbol_name)) { + *symbol_address = (cpuaddr) proxies[i].proxy; + return OS_SUCCESS; } } - return OS_ERROR; } - -int32 OS_ModuleUnload(uint32 module_id) -{ - /* Check the given id. */ - if (module_id >= OS_MAX_MODULES || module_table[module_id].free == TRUE) { - return OS_ERR_INVALID_ID; - } - - // TODO: Verify that doing nothing here makes sense - - module_table[module_id].free = TRUE; - - return OS_SUCCESS; -} - int32 OS_ModuleInfo(uint32 module_id, OS_module_prop_t *module_info) { - if (module_info == NULL) { - return OS_INVALID_POINTER; - } - - if (module_id >= OS_MAX_MODULES || module_table[module_id].free == TRUE) { - return OS_ERR_INVALID_ID; - } - - module_info->entry_point = module_table[module_id].entry_point; - module_info->host_module_id = module_table[module_id].host_module_id; - strncpy(module_info->filename, module_table[module_id].filename, OS_MAX_API_NAME); - strncpy(module_info->name, module_info[module_id].name, OS_MAX_API_NAME); - - return OS_SUCCESS; + return OS_ERR_NOT_IMPLEMENTED; } int32 OS_SymbolTableDump(const char *filename, uint32 size_limit) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index be1727489d..f586be0917 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -1,13 +1,14 @@ +#include +#include +#include + #include "cFE_util.h" #include "ostask.h" #include "gen/osapi.h" #include "gen/common_types.h" +#include "gen/cFE_time.h" -#include "sl.h" -#include "sl_lock.h" - -#include void timer_fn_1hz(void *d) @@ -244,7 +245,7 @@ int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) */ void OS_IdleLoop(void) { - sl_thd_block(0); + while(1) sl_thd_block(0); } /* diff --git a/src/components/implementation/no_interface/llbooter/inv.S b/src/components/implementation/no_interface/llbooter/inv.S index a85e208eae..1fc35321c3 100644 --- a/src/components/implementation/no_interface/llbooter/inv.S +++ b/src/components/implementation/no_interface/llbooter/inv.S @@ -14,7 +14,7 @@ __inv_test_entry: pushl %edi /* arg 3 */ pushl %esi /* arg 2 */ pushl %ebx /* arg 1 */ - call boot_thd_done + call boot_sinv_fn movl %eax, %ecx COS_ASM_RET_STACK diff --git a/src/components/implementation/no_interface/llbooter/llbooter.c b/src/components/implementation/no_interface/llbooter/llbooter.c index 0100f576e4..4cd80738d0 100644 --- a/src/components/implementation/no_interface/llbooter/llbooter.c +++ b/src/components/implementation/no_interface/llbooter/llbooter.c @@ -93,6 +93,7 @@ boot_comp_map_memory(struct cobj_header *h, spdid_t spdid, pgtblcap_t pt) left -= PAGE_SIZE; } } + boot_deps_map_sect(spdid, dest_daddr); return 0; } @@ -107,7 +108,7 @@ boot_spd_end(struct cobj_header *h) max_sect = h->nsect - 1; sect = cobj_sect_get(h, max_sect); - return sect->vaddr + round_up_to_page(sect->bytes); + return sect->vaddr + round_up_to_page(sect->bytes) + PAGE_SIZE; } int diff --git a/src/components/implementation/no_interface/sample_app/Makefile b/src/components/implementation/no_interface/sample_app/Makefile index f7e8bd608d..1171638148 100644 --- a/src/components/implementation/no_interface/sample_app/Makefile +++ b/src/components/implementation/no_interface/sample_app/Makefile @@ -4,7 +4,7 @@ COMPONENT=sample_app.o INTERFACES= DEPENDENCIES=cFE IF_LIB:=./cFE_sample_app.o -ADDITIONAL_LIBS=-lcos_kernel_api +ADDITIONAL_LIBS=-lcos_kernel_api -lcFE_emu include ../../Makefile.subsubdir MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/sample_app/init.c b/src/components/implementation/no_interface/sample_app/init.c new file mode 100644 index 0000000000..2e25625b00 --- /dev/null +++ b/src/components/implementation/no_interface/sample_app/init.c @@ -0,0 +1,14 @@ +#include +#include +#include + +extern void SAMPLE_AppMain(); +extern void OS_IdleLoop(); + +void cos_init(void) +{ + printc("Starting app main\n"); + SAMPLE_AppMain(); + printc("Ending app main\n"); + while(1) OS_IdleLoop(); +} diff --git a/src/components/implementation/no_interface/sample_lib/Makefile b/src/components/implementation/no_interface/sample_lib/Makefile index 6febbae950..e76b850ca0 100644 --- a/src/components/implementation/no_interface/sample_lib/Makefile +++ b/src/components/implementation/no_interface/sample_lib/Makefile @@ -4,7 +4,7 @@ COMPONENT=sample_lib.o INTERFACES= DEPENDENCIES=cFE IF_LIB:=./cFE_sample_lib.o -ADDITIONAL_LIBS=-lcos_kernel_api +ADDITIONAL_LIBS=-lcos_kernel_api -lcFE_emu include ../../Makefile.subsubdir MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/sample_lib/init.c b/src/components/implementation/no_interface/sample_lib/init.c new file mode 100644 index 0000000000..c1265a43e1 --- /dev/null +++ b/src/components/implementation/no_interface/sample_lib/init.c @@ -0,0 +1,14 @@ +#include +#include +#include + +extern void SAMPLE_LibInit(); +extern void OS_IdleLoop(); + +void cos_init(void) +{ + printc("Starting lib init\n"); + SAMPLE_LibInit(); + printc("Ending lib init\n"); + while(1) OS_IdleLoop(); +} diff --git a/src/components/implementation/no_interface/sch_lab/Makefile b/src/components/implementation/no_interface/sch_lab/Makefile index d844c1c02c..e7c35096d1 100644 --- a/src/components/implementation/no_interface/sch_lab/Makefile +++ b/src/components/implementation/no_interface/sch_lab/Makefile @@ -4,7 +4,7 @@ COMPONENT=sch_lab.o INTERFACES= DEPENDENCIES=cFE IF_LIB:=./cFE_sch_lab_app.o -ADDITIONAL_LIBS=-lcos_kernel_api +ADDITIONAL_LIBS=-lcos_kernel_api -lcFE_emu include ../../Makefile.subsubdir MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/sch_lab/init.c b/src/components/implementation/no_interface/sch_lab/init.c new file mode 100644 index 0000000000..df9be7cac8 --- /dev/null +++ b/src/components/implementation/no_interface/sch_lab/init.c @@ -0,0 +1,14 @@ +#include +#include +#include + +extern void SCH_Lab_AppMain(); +extern void OS_IdleLoop(); + +void cos_init(void) +{ + printc("Starting sch main\n"); + SCH_Lab_AppMain(); + printc("Ending sch main\n"); + while(1) OS_IdleLoop(); +} diff --git a/src/components/include/sl.h b/src/components/include/sl.h index 2ebbf8193d..86bc1303bf 100644 --- a/src/components/include/sl.h +++ b/src/components/include/sl.h @@ -249,6 +249,7 @@ void sl_thd_yield_cs_exit(thdid_t tid); /* The entire thread allocation and free API */ struct sl_thd *sl_thd_alloc(cos_thd_fn_t fn, void *data); +struct sl_thd *sl_thd_init(struct cos_aep_info *a, int own_tcap); struct sl_thd *sl_thd_aep_alloc(cos_aepthd_fn_t fn, void *data, int own_tcap); /* * This API creates a sl_thd object for this child component. @@ -371,7 +372,7 @@ sl_thd_activate(struct sl_thd *t, sched_tok_t tok) return cos_switch(sl_thd_thdcap(t), sl_thd_tcap(t), t->prio, g->timeout_next, g->sched_rcv, tok); } else { - return cos_defswitch(sl_thd_thdcap(t), t->prio, t == g->sched_thd ? + return cos_defswitch(sl_thd_thdcap(t), t->prio, t == g->sched_thd ? TCAP_TIME_NIL : g->timeout_next, tok); } } @@ -447,7 +448,7 @@ sl_cs_exit_schedule_nospin_arg(struct sl_thd *to) if (t->last_replenish == 0 || t->last_replenish + t->period <= now) { tcap_res_t currbudget = 0; - cycles_t replenish = now - ((now - t->last_replenish) % t->period); + cycles_t replenish = now - ((now - t->last_replenish) % t->period); ret = 0; currbudget = (tcap_res_t)cos_introspect(ci, sl_thd_tcap(t), TCAP_GET_BUDGET); @@ -470,7 +471,7 @@ sl_cs_exit_schedule_nospin_arg(struct sl_thd *to) * dispatch failed with -EPERM because tcap associated with thread t does not have budget. * Block the thread until it's next replenishment and return to the scheduler thread. * - * If the thread is not replenished by the scheduler (replenished "only" by + * If the thread is not replenished by the scheduler (replenished "only" by * the inter-component delegations), block till next timeout and try again. */ if (unlikely(ret == -EPERM)) { @@ -522,7 +523,7 @@ sl_cs_exit_switchto(struct sl_thd *to) * library-internal data-structures, and then the ability for the * scheduler thread to start its scheduling loop. * - * sl_init(period); <- using `period` for scheduler periodic timeouts + * sl_init(period); <- using `period` for scheduler periodic timeouts * sl_*; <- use the sl_api here * ... * sl_sched_loop(); <- loop here. or using sl_sched_loop_nonblock(); @@ -538,11 +539,11 @@ void sl_sched_loop(void) __attribute__((noreturn)); * with a RCV_NONBLOCK flag, the kernel returns to the calling thread immediately if * there are no pending events. * - * This is useful for the system scheduler in a hierarchical settings where - * booter (perhaps only doing simple chronos delegations) hands off the + * This is useful for the system scheduler in a hierarchical settings where + * booter (perhaps only doing simple chronos delegations) hands off the * system scheduling responsibility to another component. * - * Note: sl_sched_loop_nonblock has same semantics as sl_sched_loop for + * Note: sl_sched_loop_nonblock has same semantics as sl_sched_loop for * booter receive (INITRCV) end-point at the kernel level. */ void sl_sched_loop_nonblock(void) __attribute__((noreturn)); diff --git a/src/components/interface/cFE/ccsds.h b/src/components/interface/cFE/ccsds.h deleted file mode 100644 index a077d2c9d8..0000000000 --- a/src/components/interface/cFE/ccsds.h +++ /dev/null @@ -1,463 +0,0 @@ -/****************************************************************************** -** File: ccsds.h -** -** Copyright (c) 2004-2012, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** -** Purpose: -** Define typedefs and macros for CCSDS packet headers. -** -** $Log: ccsds.h $ -** Revision 1.6.1.2 2014/12/02 13:48:54GMT-05:00 rmcgraw -** DCR22841:3 Added CFE_MAKE_BIG16 to ccsds.h in branch64 -** Revision 1.6.1.1 2014/12/01 11:18:00EST rmcgraw -** DCR22841:1 Reverted cmd sec hdr struct and RD/WR macros to pre-6.4.0 state -** Revision 1.6 2014/07/10 10:24:07EDT rmcgraw -** DCR9772:1 Changes from C. Monaco & W.M Reid from APL for endianess neutrality -** Revision 1.5 2011/02/03 15:27:48EST lwalling -** Modified telemetry secondary header definition to support CFE_SB_PACKET_TIME_FORMAT selection -** Revision 1.4 2010/10/25 15:01:27EDT jmdagost -** Corrected bad apostrophe in prologue. -** Revision 1.3 2010/10/04 15:25:32EDT jmdagost -** Cleaned up copyright symbol. -** Revision 1.2 2010/09/21 16:15:16EDT jmdagost -** Removed unused function prototypes. -** Revision 1.1 2008/04/17 08:05:18EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.4 2006/06/12 11:18:18EDT rjmcgraw -** Added legal statement -** Revision 1.3 2006/04/28 15:09:44EDT rjmcgraw -** Corrected comments in CCSDS_CmdSecHdr_t definition -** -******************************************************************************/ - -#ifndef _ccsds_ -#define _ccsds_ - -/* -** Include Files -*/ - -#include "common_types.h" -#include "cfe_mission_cfg.h" - - -/* Macro to convert 16 bit word from platform "endianness" to Big Endian */ -#ifdef SOFTWARE_BIG_BIT_ORDER - #define CFE_MAKE_BIG16(n) (n) -#else - #define CFE_MAKE_BIG16(n) ( (((n) << 8) & 0xFF00) | (((n) >> 8) & 0x00FF) ) -#endif - - -/* CCSDS_TIME_SIZE is specific to the selected CFE_SB time format */ -#if (CFE_SB_PACKET_TIME_FORMAT == CFE_SB_TIME_32_16_SUBS) - /* 32 bits seconds + 16 bits subseconds */ - #define CCSDS_TIME_SIZE 6 -#elif (CFE_SB_PACKET_TIME_FORMAT == CFE_SB_TIME_32_32_SUBS) - /* 32 bits seconds + 32 bits subseconds */ - #define CCSDS_TIME_SIZE 8 -#elif (CFE_SB_PACKET_TIME_FORMAT == CFE_SB_TIME_32_32_M_20) - /* 32 bits seconds + 20 bits microsecs + 12 bits reserved */ - #define CCSDS_TIME_SIZE 8 -#else - /* unknown format */ - #error unable to define CCSDS_TIME_SIZE! -#endif - - -/* -** Type Definitions -*/ - -/********************************************************************** -** Structure definitions for CCSDS headers. All items in the structure -** must be aligned on 16-bit words. Bitfields must be avoided since -** some compilers (such as gcc) force them into 32-bit alignment. -**********************************************************************/ - -/*----- CCSDS packet primary header. -----*/ - -typedef struct { - - uint8 StreamId[2]; /* packet identifier word (stream ID) */ - /* bits shift ------------ description ---------------- */ - /* 0x07FF 0 : application ID */ - /* 0x0800 11 : secondary header: 0 = absent, 1 = present */ - /* 0x1000 12 : packet type: 0 = TLM, 1 = CMD */ - /* 0xE000 13 : CCSDS version, always set to 0 */ - - uint8 Sequence[2]; /* packet sequence word */ - /* bits shift ------------ description ---------------- */ - /* 0x3FFF 0 : sequence count */ - /* 0xC000 14 : segmentation flags: 3 = complete packet */ - - uint8 Length[2]; /* packet length word */ - /* bits shift ------------ description ---------------- */ - /* 0xFFFF 0 : (total packet length) - 7 */ - -} CCSDS_PriHdr_t; - -/*----- CCSDS command secondary header. -----*/ - -typedef struct { - - uint16 Command; /* command secondary header */ - /* bits shift ------------ description ---------------- */ - /* 0x00FF 0 : checksum, calculated by ground system */ - /* 0x7F00 8 : command function code */ - /* 0x8000 15 : reserved, set to 0 */ - -} CCSDS_CmdSecHdr_t; - -/*----- CCSDS telemetry secondary header. -----*/ - -typedef struct { - - uint8 Time[CCSDS_TIME_SIZE]; - -} CCSDS_TlmSecHdr_t; - -/*----- Generic combined command header. -----*/ - -typedef struct { - CCSDS_PriHdr_t PriHdr; - CCSDS_CmdSecHdr_t SecHdr; -} CCSDS_CmdPkt_t; - -/*----- Generic combined telemetry header. -----*/ - -typedef struct { - CCSDS_PriHdr_t PriHdr; - CCSDS_TlmSecHdr_t SecHdr; -} CCSDS_TlmPkt_t; - - -/* -** Macro Definitions -*/ - -/********************************************************************** -** Constant values. -**********************************************************************/ - -/* Value of packet type for a telemetry packet. */ -#define CCSDS_TLM 0 -/* Value of packet type for a command packet. */ -#define CCSDS_CMD 1 - -/* Value of secondary header flag if secondary header not present. */ -#define CCSDS_NO_SEC_HDR 0 -/* Value of secondary header flag if secondary header exists. */ -#define CCSDS_HAS_SEC_HDR 1 - -#define NUM_CCSDS_APIDS 2048 -#define NUM_CCSDS_PKT_TYPES 2 - - -/********************************************************************** -** Initial values for CCSDS header fields. -**********************************************************************/ - -/* Initial value of the sequence count. */ -#define CCSDS_INIT_SEQ 0 -/* Initial value of the sequence flags. */ -#define CCSDS_INIT_SEQFLG 3 -/* Initial value of the command function code. */ -#define CCSDS_INIT_FC 0 -/* Initial value of the command checksum. */ -#define CCSDS_INIT_CHECKSUM 0 - -/* Note: the stream ID and length are always explicitly set for a packet, -** so default values are not required. */ - - -/********************************************************************** -** Macros for reading and writing bit fields in a 16-bit integer. -** These are used to implement the read and write macros below. -**********************************************************************/ - -/* Read bits specified by 'mask' from 'word' and shift down by 'shift'. */ -#define CCSDS_RD_BITS(word,mask,shift) \ - (((word) & mask) >> shift) - -/* Shift 'value' up by 'shift' and write to those bits in 'word' that -** are specified by 'mask'. Other bits in 'word' are unchanged. */ -#define CCSDS_WR_BITS(word,mask,shift,value) \ - ((word) = (uint16)(((word) & ~mask) | (((value) & (mask >> shift)) << shift))) - - -/********************************************************************** -** Macros for reading and writing the fields in a CCSDS header. All -** of the macros are used in a similar way: -** -** CCSDS_RD_xxx(header) -- Read field xxx from header. -** CCSDS_WR_xxx(header,value) -- Write value to field xxx of header. -** -** Note that 'header' is a reference to the actual header structure, -** not to a pointer to the structure. If using a pointer, one must -** refer to the structure as *pointer. -** -** The CCSDS_WR_xxx macros may refer to 'header' more than once; thus -** the expression for 'header' must NOT contain any side effects. -**********************************************************************/ - -/* Read entire stream ID from primary header. */ -#define CCSDS_RD_SID(phdr) (((phdr).StreamId[0] << 8) + ((phdr).StreamId[1])) -/* Write entire stream ID to primary header. */ -#define CCSDS_WR_SID(phdr,value) ( ((phdr).StreamId[0] = (value >> 8) ) ,\ - ((phdr).StreamId[1] = (value & 0xff) ) ) - -/* Read application ID from primary header. */ -#define CCSDS_RD_APID(phdr) (CCSDS_RD_SID(phdr) & 0x07FF) -/* Write application ID to primary header. */ -#define CCSDS_WR_APID(phdr,value) ((((phdr).StreamId[0] = ((phdr).StreamId[0] & 0xF8) | ((value >> 8) & 0x07))) ,\ - (((phdr).StreamId[1] = ((value)) & 0xff)) ) - -/* Read secondary header flag from primary header. */ -#define CCSDS_RD_SHDR(phdr) (((phdr).StreamId[0] & 0x08) >> 3) -/* Write secondary header flag to primary header. */ -#define CCSDS_WR_SHDR(phdr,value) ((phdr).StreamId[0] = ((phdr).StreamId[0] & 0xf7) | ((value << 3) & 0x08)) - -/* Read packet type (0=TLM,1=CMD) from primary header. */ -#define CCSDS_RD_TYPE(phdr) (((phdr).StreamId[0] & 0x10) >> 4) -/* Write packet type (0=TLM,1=CMD) to primary header. */ -#define CCSDS_WR_TYPE(phdr,value) ((phdr).StreamId[0] = ((phdr).StreamId[0] & 0xEF) | ((value << 4) & 0x10)) - -/* Read CCSDS version from primary header. */ -#define CCSDS_RD_VERS(phdr) (((phdr).StreamId[0] & 0xE0) >> 5) -/* Write CCSDS version to primary header. */ -#define CCSDS_WR_VERS(phdr,value) ((phdr).StreamId[0] = ((phdr).StreamId[0] & 0x1F) | ((value << 5) & 0xE0)) - -/* Read sequence count from primary header. */ -#define CCSDS_RD_SEQ(phdr) ((((phdr).Sequence[0] & 0x3F) << 8) + ((phdr).Sequence[1])) -/* Write sequence count to primary header. */ -#define CCSDS_WR_SEQ(phdr,value) ((((phdr).Sequence[0] = ((phdr).Sequence[0] & 0xC0) | ((value >> 8) & 0x3f))) ,\ - (((phdr).Sequence[1] = ((value)) & 0xff)) ) - -/* Read sequence flags from primary header. */ -#define CCSDS_RD_SEQFLG(phdr) (((phdr).Sequence[0] & 0xC0) >> 6) -/* Write sequence flags to primary header. */ -#define CCSDS_WR_SEQFLG(phdr,value) ((phdr).Sequence[0] = ((phdr).Sequence[0] & 0x3F) | ((value << 6) & 0xC0) ) - -/* Read total packet length from primary header. */ -#define CCSDS_RD_LEN(phdr) ( ( (phdr).Length[0] << 8) + (phdr).Length[1] + 7) -/* Write total packet length to primary header. */ -#define CCSDS_WR_LEN(phdr,value) ((((phdr).Length[0] = ((value) - 7) >> 8)) ,\ - (((phdr).Length[1] = ((value) - 7) & 0xff)) ) - -/* Read function code from command secondary header. */ -#define CCSDS_RD_FC(shdr) CCSDS_RD_BITS((shdr).Command, 0x7F00, 8) -/* Write function code to command secondary header. */ -#define CCSDS_WR_FC(shdr,value) CCSDS_WR_BITS((shdr).Command, 0x7F00, 8, value) - -/* Read checksum from command secondary header. */ -#define CCSDS_RD_CHECKSUM(shdr) CCSDS_RD_BITS((shdr).Command, 0x00FF, 0) -/* Write checksum to command secondary header. */ -#define CCSDS_WR_CHECKSUM(shdr,val) CCSDS_WR_BITS((shdr).Command, 0x00FF, 0, val) - - -/********************************************************************** -** Macros for clearing a CCSDS header to a standard initial state. All -** of the macros are used in a similar way: -** CCSDS_CLR_xxx_HDR(header) -- Clear header of type xxx. -**********************************************************************/ - -/* Clear primary header. */ -#define CCSDS_CLR_PRI_HDR(phdr) \ - ( (phdr).StreamId[0] = 0,\ - (phdr).StreamId[1] = 0,\ - (phdr).Sequence[0] = (CCSDS_INIT_SEQFLG << 6),\ - (phdr).Sequence[1] = 0,\ - (phdr).Length[0] = 0, \ - (phdr).Length[1] = 0 ) - -/* Clear command secondary header. */ -#define CCSDS_CLR_CMDSEC_HDR(shdr) \ - ( (shdr).Command = (CCSDS_INIT_CHECKSUM << 0) | (CCSDS_INIT_FC << 8) ) - - -#define CCSDS_WR_SEC_HDR_SEC(shdr, value) shdr.Time[0] = ((value>>24) & 0xFF), \ - shdr.Time[1] = ((value>>16) & 0xFF), \ - shdr.Time[2] = ((value>>8) & 0xFF), \ - shdr.Time[3] = ((value) & 0xFF) - -#define CCSDS_RD_SEC_HDR_SEC(shdr) (((uint32)shdr.Time[0]) << 24) | \ - (((uint32)shdr.Time[1]) << 16) | \ - (((uint32)shdr.Time[2]) << 8) | \ - ((uint32)shdr.Time[3]) - -/* Clear telemetry secondary header. */ -#if (CFE_SB_PACKET_TIME_FORMAT == CFE_SB_TIME_32_16_SUBS) - /* 32 bits seconds + 16 bits subseconds */ - #define CCSDS_CLR_TLMSEC_HDR(shdr) \ - ( (shdr).Time[0] = 0,\ - (shdr).Time[1] = 0,\ - (shdr).Time[2] = 0,\ - (shdr).Time[3] = 0,\ - (shdr).Time[4] = 0,\ - (shdr).Time[5] = 0 ) - - -#define CCSDS_WR_SEC_HDR_SUBSEC(shdr, value) shdr.Time[4] = ((value>>8) & 0xFF), \ - shdr.Time[5] = ((value) & 0xFF) - -#define CCSDS_RD_SEC_HDR_SUBSEC(shdr) (((uint32)shdr.Time[4]) << 8) | \ - ((uint32)shdr.Time[5]) -#elif ((CFE_SB_PACKET_TIME_FORMAT == CFE_SB_TIME_32_32_SUBS) ||\ - (CFE_SB_PACKET_TIME_FORMAT == CFE_SB_TIME_32_32_M_20)) - /* 32 bits seconds + 32 bits subseconds */ - #define CCSDS_CLR_TLMSEC_HDR(shdr) \ - ( (shdr).Time[0] = 0,\ - (shdr).Time[1] = 0,\ - (shdr).Time[2] = 0,\ - (shdr).Time[3] = 0,\ - (shdr).Time[4] = 0,\ - (shdr).Time[5] = 0,\ - (shdr).Time[6] = 0,\ - (shdr).Time[7] = 0 ) - -#define CCSDS_WR_SEC_HDR_SUBSEC(shdr, value) shdr.Time[4] = ((value>>24) & 0xFF), \ - shdr.Time[5] = ((value>>16) & 0xFF), \ - shdr.Time[6] = ((value>>8) & 0xFF), \ - shdr.Time[7] = ((value) & 0xFF) - -#define CCSDS_RD_SEC_HDR_SUBSEC(shdr) (((uint32)shdr.Time[4]) << 24) | \ - (((uint32)shdr.Time[5]) << 16) | \ - (((uint32)shdr.Time[6]) << 8) | \ - ((uint32)shdr.Time[7]) -#endif - - - -/********************************************************************** -** Macros for extracting fields from a stream ID. All of the macros -** are used in a similar way: -** -** CCSDS_SID_xxx(sid) -- Extract field xxx from sid. -**********************************************************************/ - -/* Extract application ID from stream ID. */ -#define CCSDS_SID_APID(sid) CCSDS_RD_BITS(sid, 0x07FF, 0) - -/* Extract secondary header flag from stream ID. */ -#define CCSDS_SID_SHDR(sid) CCSDS_RD_BITS(sid, 0x0800, 11) - -/* Extract packet type (0=TLM,1=CMD) from stream ID. */ -#define CCSDS_SID_TYPE(sid) CCSDS_RD_BITS(sid, 0x1000, 12) - -/* Extract CCSDS version from stream ID. */ -#define CCSDS_SID_VERS(sid) CCSDS_RD_BITS(sid, 0xE000, 13) - - -/********************************************************************** -** Macros for frequently used combinations of operations. -** -** CCSDS_INC_SEQ(phdr) -- Increment sequence count. -**********************************************************************/ - -/* Increment sequence count in primary header by 1. */ -#define CCSDS_INC_SEQ(phdr) \ - CCSDS_WR_SEQ(phdr, (CCSDS_RD_SEQ(phdr)+1)) - - -/*********************************************************************/ - -/* -** Exported Functions -*/ - -/****************************************************************************** -** Function: CCSDS_InitPkt() -** -** Purpose: -** Initialize a CCSDS packet. The primary header is initialized with -** specified values, and if the Clear flag is set, the rest of the packet -** is filled with zeros. -** -** Arguments: -** PktPtr : Pointer to primary header of packet. -** StreamId : Stream ID to use for the packet. -** Length : Length of the packet in bytes. -** Clear : Indicates whether to clear the entire packet: -** TRUE = fill sequence count and packet data with zeros -** (used after a cold restart) -** FALSE = leave sequence count and packet data unchanged -** (used after a warm restart if data must be preserved) -** -** Return: -** (none) -*/ - -void CCSDS_InitPkt (CCSDS_PriHdr_t *PktPtr, - uint16 StreamId, - uint16 Length, - boolean Clear ); - - - -/****************************************************************************** -** Function: CCSDS_LoadCheckSum() -** -** Purpose: -** Compute and load a checksum for a CCSDS command packet that has a -** secondary header. -** -** Arguments: -** PktPtr : Pointer to header of command packet. The packet must -** have a secondary header and the length in the primary -** header must be correct. The checksum field in the packet -** will be modified. -** -** Return: -** (none) -*/ - -void CCSDS_LoadCheckSum (CCSDS_CmdPkt_t *PktPtr); - -/****************************************************************************** -** Function: CCSDS_ValidCheckSum() -** -** Purpose: -** Determine whether a checksum in a command packet is valid. -** -** Arguments: -** PktPtr : Pointer to header of command packet. The packet must -** have a secondary header and the length in the primary -** header must be correct. -** -** Return: -** TRUE if checksum of packet is valid; FALSE if not. -** A valid checksum is 0. -*/ - -boolean CCSDS_ValidCheckSum (CCSDS_CmdPkt_t *PktPtr); - -/****************************************************************************** -** Function: CCSDS_ComputeCheckSum() -** -** Purpose: -** Compute the checksum for a command packet. The checksum is the XOR of -** all bytes in the packet; a valid checksum is zero. -** -** Arguments: -** PktPtr : Pointer to header of command packet. The packet must -** have a secondary header and the length in the primary -** header must be correct. -** -** Return: -** TRUE if checksum of packet is valid; FALSE if not. -*/ - -uint8 CCSDS_ComputeCheckSum (CCSDS_CmdPkt_t *PktPtr); - - -#endif /* _ccsds_ */ -/*****************************************************************************/ diff --git a/src/components/interface/cFE/cfe.h b/src/components/interface/cFE/cfe.h deleted file mode 100644 index 3f050d5155..0000000000 --- a/src/components/interface/cFE/cfe.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -** $Id: cfe.h 1.4 2010/10/25 14:01:09GMT-05:00 jmdagost Exp $ -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Purpose: cFE header file -** -** Author: David Kobe, the Hammers Company, Inc. -** -** Notes: This header file centralizes the includes for all cFE -** Applications. It includes all header files necessary -** to completely define the cFE interface. -** -** $Log: cfe.h $ -** Revision 1.4 2010/10/25 14:01:09GMT-05:00 jmdagost -** Corrected bad apostrophe in prologue. -** Revision 1.3 2010/10/04 15:24:39EDT jmdagost -** Cleaned up copyright symbol. -** Revision 1.2 2009/06/10 13:28:30EDT acudmore -** added cfe_psp.h include -** Revision 1.1 2008/04/17 08:05:18EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.4 2006/06/08 14:28:31EDT David Kobe (dlkobe) -** Added NASA Open Source Legal Statement -** Revision 1.3 2005/11/04 15:27:51GMT-05:00 rjmcgraw -** Added cfe_tbl.h -** Revision 1.2 2005/07/05 10:57:21EDT lswalling -** add cfe_error.h to included header files -** Revision 1.1 2005/06/09 10:57:50EDT rperera -** Initial revision -** Member added to project d:/mksdata/MKS-CFE-REPOSITORY/cfe-core/inc/project.pj -** Revision 1.1 2005/04/28 19:30:28 swalling -** initial version -** -*/ - -/*************************************************************************/ - -/* -** Ensure that header is included only once... -*/ -#ifndef _cfe_ -#define _cfe_ - -#include "common_types.h" /* Define basic data types */ - -#include "osapi.h" /* Define OS API function prototypes */ - -#include "cfe_mission_cfg.h" /* Define mission configuration parameters */ - -/* - * Note that the platform configuration is _not_ included with cfe.h anymore. - * - * Most applications should not depend on any of the #defines in that file. - * If an application truly does need a value from the platform config, then - * it can retrieve it from the mission data dictionary using a public API. - */ -#if !defined(_ENHANCED_BUILD_) -#include "cfe_platform_cfg.h" /* Define platform configuration parameters */ -#endif - -#include "cfe_msgids.h" /* Define common cFE Message IDs */ -#include "cfe_error.h" /* Define common cFE error codes */ - -#include "cfe_es.h" /* Define Executive Service API */ -#include "cfe_evs.h" /* Define Event Service API */ -#include "cfe_fs.h" /* Define File Service API */ -#include "cfe_sb.h" /* Define Software Bus API */ -#include "cfe_time.h" /* Define Time Service API */ -#include "cfe_tbl.h" /* Define Table Service API */ - -#include "cfe_psp.h" /* Define Platform Support Package API */ - -#endif /* _cfe_ */ diff --git a/src/components/interface/cFE/cfe_error.h b/src/components/interface/cFE/cfe_error.h deleted file mode 100644 index d1e9b745f1..0000000000 --- a/src/components/interface/cFE/cfe_error.h +++ /dev/null @@ -1,1317 +0,0 @@ -/* -** -** Filename: cfe_error.h -** $Id: cfe_error.h 1.14 2014/05/30 13:23:19GMT-05:00 lwalling Exp $ -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Title: cFE Status Code Definition Header File -** -** Purpose: -** Common source of cFE API return status codes. -** -** Design Notes: -** -** References: -** Flight Software Branch C Coding Standard Version 1.0a -** -** $Date: 2014/05/30 13:23:19GMT-05:00 $ -** $Revision: 1.14 $ -** $Log: cfe_error.h $ -** Revision 1.14 2014/05/30 13:23:19GMT-05:00 lwalling -** Added error code definition for CFE_EVS_EVT_NOT_REGISTERED -** Revision 1.13 2011/12/28 13:59:09EST lwalling -** Add definition for CFE_TBL_ERR_BAD_SPACECRAFT_ID and CFE_TBL_ERR_BAD_PROCESSOR_ID -** Revision 1.12 2011/11/30 15:42:21EST jmdagost -** Added cFE ES Task Delete Error code to list. -** Revision 1.11 2010/10/25 17:49:30EDT jmdagost -** Added FS Filename Length Error code, renumbered subsequent FS codes. -** Revision 1.10 2010/10/04 17:06:28EDT jmdagost -** Cleaned up copyright symbol. -** Revision 1.9 2009/07/29 15:55:18EDT aschoeni -** Added an error code for GetPoolBufInfo when the buffer is not in the pool -** Revision 1.8 2009/07/24 13:51:32EDT aschoeni -** Added SB_BUFFER_INVALID error type to support Zero Copy Mode -** Revision 1.7 2009/05/01 14:34:15EDT dkobe -** Added special note to CFE_TBL_ERR_NEVER_LOADED error code -** Revision 1.6 2009/05/01 14:26:32EDT dkobe -** Modified return code contents to emphasize success vs failure of API calls -** Revision 1.5 2008/12/08 12:06:59EST dkobe -** Updates to correct doxygen errors -** Revision 1.4 2008/08/27 16:58:29EDT apcudmore -** added error code for timer delete error in ES task cleanup -** Revision 1.3 2008/08/06 22:42:36EDT dkobe -** Added CFE_TIME_RegisterSynchCallback, CFE_TIME_UnregisterSynchCallback and CFE_TIME_CleanUpApp -** Revision 1.2 2008/06/20 15:40:32EDT apcudmore -** Added support for OSAL based module loader -** - Removed calls and references to the BSP based module loader -** Revision 1.1 2008/04/17 08:05:18EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.40 2007/05/25 16:24:49EDT David Kobe (dlkobe) -** Continued updating doxygen comments -** Revision 1.39 2007/05/25 11:57:50EDT apcudmore -** Added CFE_ES_APP_CLEANUP_ERR -** Revision 1.38 2007/05/23 11:22:01EDT dlkobe -** Added doxygen formatting -** Revision 1.37 2007/05/14 10:26:03EDT apcudmore -** Preserve the EVS Local event log on a processor restart: -** - moved the EVS Log to the ES reset data structure -** - Added a couple of EVS Log related variables into the EVS_Log_t structure -** - Added a routine to the EVS early init to get a pointer to the EVS Log -** - Added code to the EVS housekeeping service routine to copy Log variables into TLM -** Revision 1.36 2007/05/04 15:53:17EDT dlkobe -** Added error codes returned by CFE_ES_DeleteCDS function -** Revision 1.35 2007/04/28 14:48:59EDT dlkobe -** Baseline Implementation of Critical Tables -** Revision 1.32 2007/04/04 16:06:39EDT dlkobe -** Made numerous changes to correct issues identified during ES code walkthrough -** Revision 1.30 2007/03/23 10:47:22EST apcudmore -** Added CFE_ES_GetTaskInfo call and corresponding CFE_ES_TaskInfo_t data structure. -** -**/ - -/* -** Ensure that header is included only once... -*/ -#ifndef _cfe_error_ -#define _cfe_error_ - -/* Include Files */ -#include "osapi.h" - -/* -** Status Codes are 32 bit values formatted as follows: -** -** 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 -** 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 -** +---+---+-----+-----------------+-------------------------------+ -** |Sev| R | Srv | Mission Defined | Code | -** +---+---+-----+-----------------+-------------------------------+ -** -** where -** -** Sev - is the severity code -** -** 00 - Success -** 01 - Informational -** 11 - Error -** -** R - are reserved bits -** -** Srv - is the cFE Service Identifier -** -** 000 - Not a cFE Service -** 001 - Events Services -** 010 - Executive Services -** 011 - File Services -** 100 - OS API Services -** 101 - Software Bus Services -** 110 - Tables Services -** 111 - Time Services -** -** -** Mission Defined - These bits are available for Mission -** specific coding standards. They can -** be used to classify error codes related -** to mission specific library function calls, etc. -** -** Code - is the status code -*/ - - -/* -** Error Severity -*/ -#define CFE_SEVERITY_BITMASK ((int32)0xc0000000) - -#define CFE_SEVERITY_SUCCESS ((int32)0x00000000) -#define CFE_SEVERITY_INFO ((int32)0x40000000) -#define CFE_SEVERITY_ERROR ((int32)0xc0000000) - -/* -** cFE Service Identifiers -*/ -#define CFE_SERVICE_BITMASK ((int32)0x0e000000) - -#define CFE_EVENTS_SERVICE ((int32)0x02000000) -#define CFE_EXECUTIVE_SERVICE ((int32)0x04000000) -#define CFE_FILE_SERVICE ((int32)0x06000000) -#define CFE_OSAPI_SERVICE ((int32)0x08000000) -#define CFE_SOFTWARE_BUS_SERVICE ((int32)0x0a000000) -#define CFE_TABLE_SERVICE ((int32)0x0c000000) -#define CFE_TIME_SERVICE ((int32)0x0e000000) - -/* -************* COMMON STATUS CODE ************* -*/ - -/** -** Operation was performed successfully -*/ -#define CFE_SUCCESS (0) - -/* -************* EVENTS SERVICES STATUS CODES ************* -*/ - -/** -** #CFE_EVS_Register() FilterScheme parameter was illegal -** -*/ -#define CFE_EVS_UNKNOWN_FILTER ((int32)0xc2000001) - -/** -** Calling application never previously called #CFE_EVS_Register() -** -*/ -#define CFE_EVS_APP_NOT_REGISTERED ((int32)0xc2000002) - -/** -** Application ID returned by #CFE_ES_GetAppIDByName is greater -** than #CFE_ES_MAX_APPLICATIONS -** -*/ -#define CFE_EVS_APP_ILLEGAL_APP_ID ((int32)0xc2000003) - -/** -** Number of Application event filters input upon -** registration is greater than #CFE_EVS_MAX_EVENT_FILTERS -** -*/ -#define CFE_EVS_APP_FILTER_OVERLOAD ((int32)0xc2000004) - -/** -** Could not get pointer to the ES Reset area, so we could -** not get the pointer to the EVS Log. -** -*/ -#define CFE_EVS_RESET_AREA_POINTER ((int32)0xc2000005) - - -/** -** #CFE_EVS_ResetFilter() EventID argument was not found in -** any event filter registered by the calling application. -** -*/ -#define CFE_EVS_EVT_NOT_REGISTERED ((int32)0xc2000006) - - -/** -** Current version of cFE does not have the function or the feature -** of the function implemented. This could be due to either an early -** build of the cFE for this platform or the platform does not support -** the specified feature. -** -*/ -#define CFE_EVS_NOT_IMPLEMENTED ((int32)0xc200ffff) - -/* -************* EXECUTIVE SERVICES STATUS CODES ************* -*/ - -/** -** The given application ID does not reflect a currently active application. -** -*/ -#define CFE_ES_ERR_APPID ((int32)0xc4000001) - -/** -** There is no match for the given application name in the current application list. -** -*/ -#define CFE_ES_ERR_APPNAME ((int32)0xc4000002) - -/** -** Invalid pointer argument (NULL) -** -*/ -#define CFE_ES_ERR_BUFFER ((int32)0xc4000003) - -/** -** There was an error loading or creating the App. -** -*/ -#define CFE_ES_ERR_APP_CREATE ((int32)0xc4000004) - -/** -** There was an error creating a child task. -** -*/ -#define CFE_ES_ERR_CHILD_TASK_CREATE ((int32)0xc4000005) - -/** -** The cFE system Log is full. -** -*/ -#define CFE_ES_ERR_SYS_LOG_FULL ((int32)0xc4000006) - -/** -** The Memory Pool handle is invalid. -** -*/ -#define CFE_ES_ERR_MEM_HANDLE ((int32)0xc4000007) - -/** -** The block size requested is invalid. -** -*/ -#define CFE_ES_ERR_MEM_BLOCK_SIZE ((int32)0xc4000008) - -/** -** Could not load the shared library. -** -*/ -#define CFE_ES_ERR_LOAD_LIB ((int32)0xc4000009) - -/** -** Bad parameter passed into an ES API. -** -*/ -#define CFE_ES_BAD_ARGUMENT ((int32)0xc400000a) - -/** -** Errors occured when trying to register a child task. -** -*/ -#define CFE_ES_ERR_CHILD_TASK_REGISTER ((int32)0xc400000b) - -/** -** Error occured ehen trying to pass a system call to the OS shell -** -*/ -#define CFE_ES_ERR_SHELL_CMD ((int32)0xc400000c) - -/** -** The Application is receiving the pointer to a CDS that was already present. -** -*/ -#define CFE_ES_CDS_ALREADY_EXISTS ((int32)0x4400000d) - - -/** -** The Application is requesting a CDS Block that is larger than the remaining -** CDS memory. -** -*/ -#define CFE_ES_CDS_INSUFFICIENT_MEMORY ((int32)0xc400000e) - - -/** -** The Application is requesting a CDS Block with an invalid ASCII string name. -** Either the name is too long (> #CFE_ES_CDS_MAX_NAME_LENGTH) or was an empty string. -** -*/ -#define CFE_ES_CDS_INVALID_NAME ((int32)0xc400000f) - - -/** -** The Application is requesting a CDS Block with a size of zero. -** -*/ -#define CFE_ES_CDS_INVALID_SIZE ((int32)0xc4000010) - - -/** -** The CDS Registry has as many entries in it as it can hold. The -** CDS Registry size can be adjusted with the #CFE_ES_CDS_MAX_NUM_ENTRIES -** macro defined in the cfe_platform_cfg.h file. -** -*/ -#define CFE_ES_CDS_REGISTRY_FULL ((int32)0xc4000011) - - -/** -** The CDS contents are invalid. -** -*/ -#define CFE_ES_CDS_INVALID ((int32)0xc4000012) - - -/** -** The CDS was inaccessible -** -*/ -#define CFE_ES_CDS_ACCESS_ERROR ((int32)0xc4000013) - - -/** -** Occurs when a file operation fails -** -*/ -#define CFE_ES_FILE_IO_ERR ((int32)0xc4000014) - - -/** -** Occurs when the BSP is not successful in returning the reset area address. -** -*/ -#define CFE_ES_RST_ACCESS_ERR ((int32)0xc4000015) - -/** -** Occurs when the Task ID passed into #CFE_ES_GetTaskInfo is invalid. -** -*/ -#define CFE_ES_ERR_TASKID ((int32)0xc4000016) - -/** -** Occurs when the #CFE_ES_RegisterApp fails. -** -*/ -#define CFE_ES_ERR_APP_REGISTER ((int32)0xc4000017) - -/** -** There was an error deleting a child task. -** -*/ -#define CFE_ES_ERR_CHILD_TASK_DELETE ((int32)0xc4000018) - -/** -** There was an attempt to delete a cFE App Main Task with -** the #CFE_ES_DeleteChildTask API. -** -*/ -#define CFE_ES_ERR_CHILD_TASK_DELETE_MAIN_TASK ((int32)0xc4000019) - -/** -** Occurs when trying to read a CDS Data block and the CRC of the current -** data does not match the stored CRC for the data. Either the contents of -** the CDS Data Block are corrupted or the CDS Control Block is corrupted. -** -*/ -#define CFE_ES_CDS_BLOCK_CRC_ERR ((int32)0xc400001A) - -/** -** Occurs when trying to delete a Mutex that belongs to a task that ES -** is cleaning up. -** -*/ -#define CFE_ES_MUT_SEM_DELETE_ERR ((int32)0xc400001B) - - -/** -** Occurs when trying to delete a Binary Semaphore that belongs to a task that ES -** is cleaning up. -** -*/ -#define CFE_ES_BIN_SEM_DELETE_ERR ((int32)0xc400001C) - -/** -** Occurs when trying to delete a Counting Semaphore that belongs to a task that ES -** is cleaning up. -** -*/ -#define CFE_ES_COUNT_SEM_DELETE_ERR ((int32)0xc400001D) - -/** -** Occurs when trying to delete a Queue that belongs to a task that ES -** is cleaning up. -** -*/ -#define CFE_ES_QUEUE_DELETE_ERR ((int32)0xc400001E) - -/** -** Occurs when trying to close a file that belongs to a task that ES -** is cleaning up. -** -*/ -#define CFE_ES_FILE_CLOSE_ERR ((int32)0xc400001F) - -/** -** Occurs when Table Services is trying to delete a Critical Data Store that -** is not a Critical Table Image or when Executive Services is trying to delete -** a Critical Table Image. -** -*/ -#define CFE_ES_CDS_WRONG_TYPE_ERR ((int32)0xc4000020) - -/** -** Occurs when a search of the Critical Data Store Registry does not find a -** critical data store with the specified name. -** -*/ -#define CFE_ES_CDS_NOT_FOUND_ERR ((int32)0xc4000021) - -/** -** Occurs when an attempt was made to delete a CDS when an application -** with the same name associated with the CDS is still present. CDSs -** can ONLY be deleted when Applications that created them are not present -** in the system. -** -*/ -#define CFE_ES_CDS_OWNER_ACTIVE_ERR ((int32)0xc4000022) - - -/** -** Occurs when an attempt was made to Clean Up an application -** which involves calling Table, EVS, and SB cleanup functions, then -** deleting all ES resources, child tasks, and unloading the -** object module. The approach here is to keep going even though one -** of these steps had an error. There will be syslog messages detailing -** each problem. -** -*/ -#define CFE_ES_APP_CLEANUP_ERR ((int32)0xc4000023) - -/** -** Occurs when trying to delete a Timer that belongs to a task that ES -** is cleaning up. -** -*/ -#define CFE_ES_TIMER_DELETE_ERR ((int32)0xc4000024) - -/** -** The specified address is not in the memory pool. -** -*/ -#define CFE_ES_BUFFER_NOT_IN_POOL ((int32)0xc4000025) - - -/** -** Occurs when trying to delete a task that ES -** is cleaning up. -** -*/ -#define CFE_ES_TASK_DELETE_ERR ((int32)0xc4000026) - -/** -** Occurs if the timeout for a given operation was exceeded -** -*/ -#define CFE_ES_OPERATION_TIMED_OUT ((int32)0xc4000027) - - -/** -** Current version of cFE does not have the function or the feature -** of the function implemented. This could be due to either an early -** build of the cFE for this platform or the platform does not support -** the specified feature. -** -*/ -#define CFE_ES_NOT_IMPLEMENTED ((int32)0xc400ffff) - - -/* -************* FILE SERVICES STATUS CODES ************* -*/ - -/* -** A parameter given by a caller to a File Services API did not pass -** validation checks. -** -*/ -#define CFE_FS_BAD_ARGUMENT ((int32)0xc6000001) - -/* -** FS was unable to extract a filename from a path string -** -*/ -#define CFE_FS_INVALID_PATH ((int32)0xc6000002) - -/* -** FS filename string is too long -** -*/ -#define CFE_FS_FNAME_TOO_LONG ((int32)0xc6000003) - -/* -** The GZIP file contains invalid data and cannot be read -*/ -#define CFE_FS_GZIP_BAD_DATA ((int32)0xc6000004) - -/* -** The GZIP file codeblock is bad, which means the file is -** most likely corrupted -*/ -#define CFE_FS_GZIP_BAD_CODE_BLOCK ((int32)0xc6000005) - -/* -** The memory buffer used by the decompression routine is -** exhausted. -*/ -#define CFE_FS_GZIP_NO_MEMORY ((int32)0xc6000006) - -/* -** There is a CRC error in the GZIP file, which means the -** file is most likely corrupted. -*/ -#define CFE_FS_GZIP_CRC_ERROR ((int32)0xc6000007) - -/* -** There is a length error in the GZIP internal data -** structures, which means the file is most likely corrupted. -*/ -#define CFE_FS_GZIP_LENGTH_ERROR ((int32)0xc6000008) - -/* -** An error occurred trying to write the uncompressed -** file. -*/ -#define CFE_FS_GZIP_WRITE_ERROR ((int32)0xc6000009) - -/* -** An error occurred trying to read the GZIP file -*/ -#define CFE_FS_GZIP_READ_ERROR ((int32)0xc600000A) - -/* -** An error occurred trying to open the DestinationFile -** where the GZIP file will be uncompressed. The -** function must be able to open a new write-only file to -** store the uncompressed file in. -*/ -#define CFE_FS_GZIP_OPEN_OUTPUT ((int32)0xc600000B) - -/* -** An error occurred trying to open the GZIP file -** to be decompressed. The function must be able to open -** the GZIP file as read-only in order to decompress it -** to a new file ( most likely in a RAM disk ) -*/ -#define CFE_FS_GZIP_OPEN_INPUT ((int32)0xc600000C) - -/* -** An error occured trying to read the GZIP file header, -** which means the file is most likely corrupted or -** not a valid GZIP file. -*/ -#define CFE_FS_GZIP_READ_ERROR_HEADER ((int32)0xc600000D) - -/* -** An error occurred trying to read the GZIP index, -** which means the file is most likely corrupted. -*/ -#define CFE_FS_GZIP_INDEX_ERROR ((int32)0xc600000E) - -/* -** The file to be decompressed is not a valid GZIP file -*/ -#define CFE_FS_GZIP_NON_ZIP_FILE ((int32)0xc600000F) - -/** -** Current version of cFE does not have the function or the feature -** of the function implemented. This could be due to either an early -** build of the cFE for this platform or the platform does not support -** the specified feature. -** -*/ -#define CFE_FS_NOT_IMPLEMENTED ((int32)0xc600ffff) - -/* -************* OSAPI STATUS CODES ************* -*/ - -/** -** -** -*/ -#define CFE_OS_ERROR (OS_ERROR) - -/** -** -** -*/ -#define CFE_OS_INVALID_POINTER (OS_INVALID_POINTER) - -/** -** -** -*/ -#define CFE_OS_ERROR_ADDRESS_MISALIGNED (OS_ERROR_ADDRESS_MISALIGNED) - -/** -** -** -*/ -#define CFE_OS_ERROR_TIMEOUT (OS_ERROR_TIMEOUT) - -/** -** -** -*/ -#define CFE_OS_INVALID_INT_NUM (OS_INVALID_INT_NUM) - -/** -** -** -*/ -#define CFE_OS_SEM_FAILURE (OS_SEM_FAILURE) - -/** -** -** -*/ -#define CFE_OS_SEM_TIMEOUT (OS_SEM_TIMEOUT) - -/** -** -** -*/ -#define CFE_OS_QUEUE_EMPTY (OS_QUEUE_EMPTY) - -/** -** -** -*/ -#define CFE_OS_QUEUE_FULL (OS_QUEUE_FULL) - -/** -** -** -*/ -#define CFE_OS_QUEUE_TIMEOUT (OS_QUEUE_TIMEOUT) - -/** -** -** -*/ -#define CFE_OS_QUEUE_INVALID_SIZE (OS_QUEUE_INVALID_SIZE) - -/** -** -** -*/ -#define CFE_OS_QUEUE_ID_ERROR (OS_QUEUE_ID_ERROR) - -/** -** -** -*/ -#define CFE_OS_ERR_NAME_TOO_LONG (OS_ERR_NAME_TOO_LONG) - -/** -** -** -*/ -#define CFE_OS_ERR_NO_FREE_IDS (OS_ERR_NO_FREE_IDS) - -/** -** -** -*/ -#define CFE_OS_ERR_NAME_TAKEN (OS_ERR_NAME_TAKEN) - -/** -** -** -*/ -#define CFE_OS_ERR_INVALID_ID (OS_ERR_INVALID_ID) - -/** -** -** -*/ -#define CFE_OS_ERR_NAME_NOT_FOUND (OS_ERR_NAME_NOT_FOUND) - -/** -** -** -*/ -#define CFE_OS_ERR_SEM_NOT_FULL (OS_ERR_SEM_NOT_FULL) - -/** -** -** -*/ -#define CFE_OS_ERR_INVALID_PRIORITY (OS_ERR_INVALID_PRIORITY) - -/** -** -** -*/ -#define CFE_OS_ERROR_TASK_ID (OS_ERROR_TASK_ID) - -/** -** -** -*/ -#define CFE_OS_SEM_UNAVAILABLE (OS_SEM_UNAVAILABLE) - -/** -** -** -*/ -#define CFE_OS_FS_ERROR (OS_FS_ERROR) - -/** -** -** -*/ -#define CFE_OS_FS_ERR_INVALID_POINTER (OS_FS_ERR_INVALID_POINTER) - -/** -** -** -*/ -#define CFE_OS_FS_ERR_PATH_TOO_LONG (OS_FS_ERR_PATH_TOO_LONG) - -/** -** -** -*/ -#define CFE_OS_FS_ERR_NAME_TOO_LONG (OS_FS_ERR_NAME_TOO_LONG) - -/** -** -** -*/ -#define CFE_OS_FS_ERR_DRIVE_NOT_CREATED (OS_FS_ERR_DRIVE_NOT_CREATED) - -/** -** Current version of cFE does not have the function or the feature -** of the function implemented. This could be due to either an early -** build of the cFE for this platform or the platform does not support -** the specified feature. -** -*/ -#define CFE_OSAPI_NOT_IMPLEMENTED (OS_FS_UNIMPLEMENTED) - -/* -************* SOFTWARE BUS SERVICES STATUS CODES ************* -*/ - -/** -** In #CFE_SB_RcvMsg, this return value indicates that a packet has not -** been received in the time given in the "timeout" parameter. -** -*/ -#define CFE_SB_TIME_OUT ((int32)0xca000001) - - -/** -** When "Polling" a pipe for a message in #CFE_SB_RcvMsg, this return -** value indicates that there was not a message on the pipe. -** -*/ -#define CFE_SB_NO_MESSAGE ((int32)0xca000002) - - -/** -** A parameter given by a caller to a Software Bus API did not pass -** validation checks. -** -*/ -#define CFE_SB_BAD_ARGUMENT ((int32)0xca000003) - - -/** -** This error code will be returned from #CFE_SB_CreatePipe when the -** SB cannot accomodate the request to create a pipe because the maximum -** number of pipes (#CFE_SB_MAX_PIPES) are in use. This configuration -** parameter is defined in the cfe_platform_cfg.h file. -** -*/ -#define CFE_SB_MAX_PIPES_MET ((int32)0xca000004) - - -/** -** The maximum number of queues(#OS_MAX_QUEUES) are in use. Or possibly a -** lower level problem with creating the underlying queue has occurred -** such as a lack of memory. If the latter is the problem, the status -** code displayed in the event must be tracked. -** -*/ -#define CFE_SB_PIPE_CR_ERR ((int32)0xca000005) - - -/** -** This return value indicates an error at the Queue read level. This -** error typically cannot be corrected by the caller. Some possible -** causes are: queue was not properly initialized or created, the number -** of bytes read from the queue was not the number of bytes requested in -** the read. The queue id is invalid. Similar errors regarding the pipe -** will be caught by higher level code in the Software Bus. -** -*/ -#define CFE_SB_PIPE_RD_ERR ((int32)0xca000006) - - -/** -** The size field in the message header indicates the message exceeds the -** max Software Bus message size. The max size is defined by -** configuration parameter #CFE_SB_MAX_SB_MSG_SIZE in cfe_mission_cfg.h -** -*/ -#define CFE_SB_MSG_TOO_BIG ((int32)0xca000007) - - -/** -** This error code will be returned from #CFE_SB_SendMsg when the memory -** in the SB message buffer pool has been depleted. The amount of memory -** in the pool is dictated by the configuration parameter -** #CFE_SB_BUF_MEMORY_BYTES specified in the cfe_platform_cfg.h file. Also -** the memory statistics, including current utilization figures and high -** water marks for the SB Buffer memory pool can be monitored by sending -** a Software Bus command to send the SB statistics packet. -** -*/ -#define CFE_SB_BUF_ALOC_ERR ((int32)0xca000008) - - -/** -** Will be returned when calling one of the SB subscription API's if the -** SB routing table cannot accomodate another unique message ID because -** the platform configuration parameter #CFE_SB_MAX_MSG_IDS has been met. -** -*/ -#define CFE_SB_MAX_MSGS_MET ((int32)0xca000009) - - -/** -** Will be returned when calling one of the SB subscription API's if the -** SB routing table cannot accomodate another destination for a -** particular the given message ID. This occurs when the number of -** destinations in use meets the platform configuration parameter -** #CFE_SB_MAX_DEST_PER_PKT. -** -*/ -#define CFE_SB_MAX_DESTS_MET ((int32)0xca00000a) - - -/** -** This error code is returned by the #CFE_SB_Unsubscribe API if there has -** not been an entry in the routing tables for the MsgId/PipeId given as -** parameters. -*/ -#define CFE_SB_NO_SUBSCRIBERS ((int32)0xca00000b) - - -/** -** This error code will be returned by the #CFE_SB_Subscribe API if the -** code detects an internal index is out of range. The most likely -** cause would be a Single Event Upset. -** -*/ -#define CFE_SB_INTERNAL_ERR ((int32)0xca00000c) - - -/** -** This error code will be returned when a request such as ...SetMsgTime -** is made on a packet that does not include a field for msg time. -** -*/ -#define CFE_SB_WRONG_MSG_TYPE ((int32)0xca00000d) - - -/** -** This error code will be returned when a request to release or send a -** zero copy buffer is invalid, such as if the handle or buffer is not -** correct or the buffer was previously released. -** -*/ -#define CFE_SB_BUFFER_INVALID ((int32)0xca00000e) - - -/** -** Current version of cFE does not have the function or the feature -** of the function implemented. This could be due to either an early -** build of the cFE for this platform or the platform does not support -** the specified feature. -** -*/ -#define CFE_SB_NOT_IMPLEMENTED ((int32)0xca00ffff) - -/* -************* TABLE SERVICES STATUS CODES ************* -*/ - -/** -** The calling Application attempted to pass a -** Table handle that represented too large an index or -** identified a Table Access Descriptor that was not used. -** -*/ -#define CFE_TBL_ERR_INVALID_HANDLE ((int32)0xcc000001) - -/** -** The calling Application attempted to register a table whose -** name length exceeded the platform configuration value of -** #CFE_TBL_MAX_NAME_LENGTH or was zero characters long. -** -*/ -#define CFE_TBL_ERR_INVALID_NAME ((int32)0xcc000002) - -/** -** The calling Application attempted to register a table: -** a) that was a double buffered table with size greater than #CFE_TBL_MAX_DBL_TABLE_SIZE -** b) that was a single buffered table with size greater than #CFE_TBL_MAX_SNGL_TABLE_SIZE -** c) that had a size of zero -** -*/ -#define CFE_TBL_ERR_INVALID_SIZE ((int32)0xcc000003) - -/** -** The calling Application has identified a table that has a load pending. -** -*/ -#define CFE_TBL_INFO_UPDATE_PENDING ((int32)0x4c000004) - -/** -** This is an error indicating that the table has never been loaded from -** either a file or a copy from a block of memory so the contents that the -** returned pointer is pointing to are zeros. -** NOTE: Unlike other most other errors, this error condition still -** returns a valid table pointer. This pointer must be released with the -** #CFE_TBL_ReleaseAddress API before the table can be loaded with data. -** -*/ -#define CFE_TBL_ERR_NEVER_LOADED ((int32)0xcc000005) - -/** -** An application attempted to create a table and the Table -** registry already contained #CFE_TBL_MAX_NUM_TABLES in it. -** -*/ -#define CFE_TBL_ERR_REGISTRY_FULL ((int32)0xcc000006) - -/** -** This is an error that the registration is trying to replace -** an existing table with the same name. The previous table -** stays in place and the new table is rejected. -** -*/ -#define CFE_TBL_WARN_DUPLICATE ((int32)0x4c000007) - -/** -** The calling application either failed when calling #CFE_TBL_Register, -** failed when calling #CFE_TBL_Share or forgot to call either one. -** -*/ -#define CFE_TBL_ERR_NO_ACCESS ((int32)0xcc000008) - -/** -** The calling application is trying to access a table that has -** been unregistered. -** -*/ -#define CFE_TBL_ERR_UNREGISTERED ((int32)0xcc000009) - -/** -** The calling application does not have a legitimate Application ID. -** Most likely cause is a failure to register with the cFE via the -** #CFE_ES_RegisterApp function. -** -*/ -#define CFE_TBL_ERR_BAD_APP_ID ((int32)0xcc00000A) - -/** -** An application attempted to create a table and the Table -** Handle Array already used all CFE_TBL_MAX_NUM_HANDLES in it. -** -*/ -#define CFE_TBL_ERR_HANDLES_FULL ((int32)0xcc00000B) - -/** -** An application attempted to register a table with the same name -** as a table that is already in the registry. The size of the new -** table is different from the size already in the registry. -** -*/ -#define CFE_TBL_ERR_DUPLICATE_DIFF_SIZE ((int32)0xcc00000C) - -/** -** An application attempted to register a table with the same name -** as a table that is already in the registry. The previously registered -** table is owned by a different application. -** -*/ -#define CFE_TBL_ERR_DUPLICATE_NOT_OWNED ((int32)0xcc00000D) - -/** -** The calling Application has identified a table that has been updated.
-** \b NOTE: This is a nominal return code informing the calling application -** that the table identified in the call has had its contents updated since -** the last time the application obtained its address or status. -** -*/ -#define CFE_TBL_INFO_UPDATED ((int32)0x4c00000E) - -/** -** The calling Application has tried to allocate a working buffer but -** none were available. -** -*/ -#define CFE_TBL_ERR_NO_BUFFER_AVAIL ((int32)0xcc00000F) - -/** -** The calling Application has attempted to perform a load on a -** table that was created with "Dump Only" attributes. -** -*/ -#define CFE_TBL_ERR_DUMP_ONLY ((int32)0xcc000010) - -/** -** The calling Application called #CFE_TBL_Load with an illegal -** value for the second parameter. -** -*/ -#define CFE_TBL_ERR_ILLEGAL_SRC_TYPE ((int32)0xcc000011) - -/** -** The calling Application called #CFE_TBL_Load when another Application -** was trying to load the table. -** -*/ -#define CFE_TBL_ERR_LOAD_IN_PROGRESS ((int32)0xcc000012) - -/** -** The calling Application called #CFE_TBL_Load with a bad filename. -** -*/ -#define CFE_TBL_ERR_FILE_NOT_FOUND ((int32)0xcc000013) - -/** -** The calling Application called #CFE_TBL_Load with a filename that specified a file -** that contained more data than the size of the table OR which contained more data -** than specified in the table header. -** -*/ -#define CFE_TBL_ERR_FILE_TOO_LARGE ((int32)0xcc000014) - -/** -** The calling Application called #CFE_TBL_Load with a filename that specified a file -** that started with the first byte of the table but contained less data than the size of the table. -** It should be noted that #CFE_TBL_WARN_PARTIAL_LOAD also indicates a partial load (one that starts -** at a non-zero offset). -** -*/ -#define CFE_TBL_WARN_SHORT_FILE ((int32)0x4c000015) - -/** -** The calling Application called #CFE_TBL_Load with a filename that specified a file -** whose content ID was not that of a table image. -** -*/ -#define CFE_TBL_ERR_BAD_CONTENT_ID ((int32)0xcc000016) - -/** -** The calling Application has attempted to update a table without a pending load. -** -*/ -#define CFE_TBL_INFO_NO_UPDATE_PENDING ((int32)0x4c000017) - -/** -** The calling Application tried to update a table that is locked by another user. -** -*/ -#define CFE_TBL_INFO_TABLE_LOCKED ((int32)0x4c000018) - -/** -** The calling Application should call #CFE_TBL_Validate for the specified table. -** -*/ -#define CFE_TBL_INFO_VALIDATION_PENDING ((int32)0x4c000019) - -/** -** The calling Application tried to validate a table that did not have a validation request pending. -** -*/ -#define CFE_TBL_INFO_NO_VALIDATION_PENDING ((int32)0x4c00001A) - -/** -** The calling Application tried to access a table file whose Subtype identifier indicated it was not -** a table image file. -** -*/ -#define CFE_TBL_ERR_BAD_SUBTYPE_ID ((int32)0xcc00001B) - -/** -** The calling Application tried to access a table file whose Subtype identifier indicated it was not -** a table image file. -** -*/ -#define CFE_TBL_ERR_FILE_SIZE_INCONSISTENT ((int32)0xcc00001C) - -/** -** The calling Application tried to access a table file whose standard cFE File Header was the wrong size, etc. -** -*/ -#define CFE_TBL_ERR_NO_STD_HEADER ((int32)0xcc00001D) - -/** -** The calling Application tried to access a table file whose standard cFE -** Table File Header was the wrong size, etc. -** -*/ -#define CFE_TBL_ERR_NO_TBL_HEADER ((int32)0xcc00001E) - - -/** -** The calling Application tried to load a table using a filename -** that was too long. -** -*/ -#define CFE_TBL_ERR_FILENAME_TOO_LONG ((int32)0xcc00001F) - - -/** -** The calling Application tried to load a table using a file whose -** header indicated that it was for a different table. -** -*/ -#define CFE_TBL_ERR_FILE_FOR_WRONG_TABLE ((int32)0xcc000020) - - -/** -** The calling Application tried to load a table file whose header -** claimed the load was larger than what was actually read from the file. -** -*/ -#define CFE_TBL_ERR_LOAD_INCOMPLETE ((int32)0xcc000021) - - -/** -** The calling Application tried to load a table file whose header -** claimed the load did not start with the first byteIt should be noted -** that #CFE_TBL_WARN_SHORT_FILE also indicates a partial load. -** -*/ -#define CFE_TBL_WARN_PARTIAL_LOAD ((int32)0x4c000022) - - -/** -** The calling Application tried to load a table file whose header -** claimed the load did not start with the first byte and the table -** image had NEVER been loaded before. Partial loads are not allowed -** on uninitialized tables. It should be noted that -** #CFE_TBL_WARN_SHORT_FILE also indicates a partial load. -** -*/ -#define CFE_TBL_ERR_PARTIAL_LOAD ((int32)0xcc000023) - - -/** -** The calling Application should call #CFE_TBL_Manage for the specified table. -** The ground has requested a dump of the Dump-Only table and needs to synchronize -** with the owning application. -** -*/ -#define CFE_TBL_INFO_DUMP_PENDING ((int32)0x4c000024) - - -/** -** The calling Application has used an illegal combination of table options. -** A summary of the illegal combinations are as follows: -** \par #CFE_TBL_OPT_USR_DEF_ADDR cannot be combined with any of the following: -** -# #CFE_TBL_OPT_DBL_BUFFER -** -# #CFE_TBL_OPT_LOAD_DUMP -** -# #CFE_TBL_OPT_CRITICAL -** \par #CFE_TBL_OPT_DBL_BUFFER cannot be combined with the following: -** -# #CFE_TBL_OPT_USR_DEF_ADDR -** -# #CFE_TBL_OPT_DUMP_ONLY -** -*/ -#define CFE_TBL_ERR_INVALID_OPTIONS ((int32)0xcc000025) - - -/** -** The calling Application attempted to register a table as "Critical". -** Table Services failed to create an appropriate Critical Data Store -** (See System Log for reason) to save the table contents. The table -** will be treated as a normal table from now on. -** -*/ -#define CFE_TBL_WARN_NOT_CRITICAL ((int32)0x4c000026) - - -/** -** The calling Application registered a critical table whose previous -** contents were discovered in the Critical Data Store. The discovered -** contents were copied back into the newly registered table as the -** table's initial contents.
-** \b NOTE: In this situation, the contents of the table are \b NOT -** validated using the table's validation function. -** -*/ -#define CFE_TBL_INFO_RECOVERED_TBL ((int32)0x4c000027) - - -/** -** The selected table file failed validation for Spacecraft ID. -** The platform configuration file has verification of table files -** enabled for Spacecraft ID and an attempt was made to load a table -** with an invalid Spacecraft ID in the table file header. -** -*/ -#define CFE_TBL_ERR_BAD_SPACECRAFT_ID (int32)(0xcc000028L) - - -/** -** The selected table file failed validation for Processor ID. -** The platform configuration file has verification of table files -** enabled for Processor ID and an attempt was made to load a table -** with an invalid Processor ID in the table file header. -** -*/ -#define CFE_TBL_ERR_BAD_PROCESSOR_ID (int32)(0xcc000029L) - - -/** -** Current version of cFE does not have the function or the feature -** of the function implemented. This could be due to either an early -** build of the cFE for this platform or the platform does not support -** the specified feature. -** -*/ -#define CFE_TBL_NOT_IMPLEMENTED ((int32)0xcc00ffff) - - -/* -************* TIME SERVICES STATUS CODES ************* -*/ - -/** -** Current version of cFE does not have the function or the feature -** of the function implemented. This could be due to either an early -** build of the cFE for this platform or the platform does not support -** the specified feature. -** -*/ -#define CFE_TIME_NOT_IMPLEMENTED ((int32)0xce00ffff) - -/** -** One of the TIME Services API functions to set the time with data -** from an external time source has been called, but TIME Services -** has been commanded to not accept external time data. However, -** the command is still a signal for the Time Server to generate -** a "time at the tone" command packet using internal data. -** -*/ -#define CFE_TIME_INTERNAL_ONLY ((int32)0xce000001) - -/** -** One of the TIME Services API functions to set the time with data -** from an external time source has been called, but TIME Services -** has determined that the new time data is invalid. However, -** the command is still a signal for the Time Server to generate -** a "time at the tone" command packet using internal data. -** -** Note that the test for invalid time update data only occurs if TIME -** Services has previously been commanded to set the clock state -** to "valid". -*/ -#define CFE_TIME_OUT_OF_RANGE ((int32)0xce000002) - -/** -** An attempt to register too many cFE Time Services Synchronization -** callbacks has been made. Adjust the #CFE_TIME_MAX_NUM_SYNCH_FUNCS -** configuration parameter, recompile and try again. -** -*/ -#define CFE_TIME_TOO_MANY_SYNCH_CALLBACKS ((int32)0xce000003) - -/** -** An attempt to unregister a cFE Time Services Synchronization -** callback has failed because the specified callback function was not -** located in the Synchronization Callback Registry. -** -*/ -#define CFE_TIME_CALLBACK_NOT_REGISTERED ((int32)0xce000004) - -#endif /* _cfe_error_ */ diff --git a/src/components/interface/cFE/cfe_es.h b/src/components/interface/cFE/cfe_es.h deleted file mode 100644 index 83c9ac43f1..0000000000 --- a/src/components/interface/cFE/cfe_es.h +++ /dev/null @@ -1,1604 +0,0 @@ -/* -** -** File: -** cfe_es.h -** $Id: cfe_es.h 1.14 2014/08/19 13:32:01GMT-05:00 sstrege Exp $ -** -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** -** Purpose: -** Unit specification for Executive Services library functions and macros. -** -** References: -** Flight Software Branch C Coding Standard Version 1.0a -** cFE Flight Software Application Developers Guide -** -** Notes: -** -** $Date: 2014/08/19 13:32:01GMT-05:00 $ -** $Revision: 1.14 $ -** $Log: cfe_es.h $ -** Revision 1.14 2014/08/19 13:32:01GMT-05:00 sstrege -** Fixed doxygen warnings -** Revision 1.13 2011/07/15 14:28:34EDT lwalling -** Removed const qualifier from CounterName argument to CFE_ES_RegisterGenCounter() -** Revision 1.12 2010/11/05 15:54:27EDT aschoeni -** Added Generic Counter API to ES -** Revision 1.11 2010/11/01 16:03:10EDT jmdagost -** Removed cfe.h from include list and added cfe_mission_cfg.h -** Revision 1.10 2010/10/20 12:35:43EDT jmdagost -** Major revision to make semaphore use in memory pool creation optional. -** Revision 1.9 2009/07/29 15:54:46EDT aschoeni -** Added GetPoolBufInfo function to return size or invalidity of a buffer in a pool -** Revision 1.8 2008/12/08 16:10:54EST dkobe -** Correcting errors generated during detailed design document generation -** Revision 1.7 2008/12/08 12:07:09EST dkobe -** Updates to correct doxygen errors -** Revision 1.6 2008/07/31 15:41:31EDT apcudmore -** Added execution counter API: -** -- Added execution counter to ES internal task data -** -- Added code to increment counter in RunLoop -** -- Added code to report counter in GetInfo APIs -** -- Added API to increment counter for child tasks -** -- Added code to cFE Core apps to increment counters. -** Revision 1.5 2008/07/30 14:53:57EDT apcudmore -** Added CFE_ES_WaitForStartupSync API -** Revision 1.4 2008/07/08 12:35:28EDT apcudmore -** Added an "AddressesAreValid" flag to the ES App Info structure. -** Revision 1.3 2008/06/26 15:41:51EDT apcudmore -** Added public CFE_ES_GetAppInfo API. -** Moved the old API to CFE_ES_GetAppInfoInternal -** -- May merge these two in the near future. -** Revision 1.2 2008/06/20 15:40:27EDT apcudmore -** Added support for OSAL based module loader -** - Removed calls and references to the BSP based module loader -** Revision 1.1 2008/04/17 08:05:19EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.58 2007/09/27 15:54:56EDT David Kobe (dlkobe) -** Added doxygen comments for commands and telemetry -** Revision 1.57 2007/09/25 10:24:05EDT apcudmore -** Implement Application Restart on Exception: -** - Added logic to Exception Handler -** - Changed Exception Hook to pass host task ID -** - Added App Reset ER Log entry type -** Revision 1.56 2007/09/21 15:40:15EDT David Kobe (dlkobe) -** Modified pointer type definitions to eliminate Linux gcc compile warnings -** Revision 1.55 2007/09/20 10:52:57EDT apcudmore -** Added Query All Tasks command, file definition, events, error codes etc. -** Revision 1.54 2007/09/12 16:06:09EDT David Kobe (dlkobe) -** Moved the definitions of CFE_ES_CRC_xx to the cfe_mission_cfg.h file and deleted TBL Services -** CRC #define statement. -** Revision 1.53 2007/08/31 14:11:05EDT apcudmore -** Updated reset subtypes ( trunk ) -** Revision 1.52 2007/08/07 12:52:40EDT dlkobe -** Modified CFE_ES_GetPoolBuf API's first parameter to be of type uint32** -** Revision 1.51 2007/05/25 16:24:48EDT dlkobe -** Continued updating doxygen comments -** Revision 1.50 2007/05/23 11:21:23EDT dlkobe -** Added doxygen formatting -** Revision 1.49 2007/05/22 14:56:49EDT apcudmore -** cFE Non-Volatile Disk/Startup File changes: -** - cFE startup now passes in startup file path/name -** - cFE startup code does not init non-volatile disk ( BSP does ) -** - BSPs now can map cFE paths without making the OS_initfs/OS_mount calls -** - MCP750 vxWorks6.2 BSP inits/mounts CF disk -** - Desktop ports pass in the same startup file path/name as before -** Revision 1.48 2007/05/14 15:43:45EDT apcudmore -** Cleaned up events and disabled debug code for application restart. -** Revision 1.47 2007/05/09 12:42:13EDT dlkobe -** Added structure for Dump CDS Registry Record format -** Revision 1.46 2007/05/04 20:07:51EDT dlkobe -** Added command to telemeter memory pool statistics -** Revision 1.45 2007/04/12 10:37:18EDT apcudmore -** Added support for ES task to call CFE_ES_ExitApp on initialization and runtime failure. -** Revision 1.44 2007/04/10 11:39:19EDT rjmcgraw -** Added function prototype CFE_ES_PerfLogAdd -** Revision 1.43 2007/04/10 11:29:10EDT rjmcgraw -** Changed perf entry and exit routines to macros -** Revision 1.42 2007/04/09 15:12:03EDT dlkobe -** Modified 'Name' parameter to be a const pointer -** Revision 1.41 2007/04/05 16:16:03EDT apcudmore -** Added CFE_ES_DeleteChildTask and CFE_ES_ExitChildTask along with headers, -** and associated Error codes. -** Revision 1.39 2007/04/03 16:49:24EDT apcudmore -** Moved all command code defines, command , and telemetry definitions to cfe_es_msg.h -** Revision 1.38 2007/04/02 10:57:45EDT rjmcgraw -** Moved BIT macros from perf.h to cfe_es.h -** Revision 1.37 2007/03/29 15:49:08EST rjmcgraw -** Changed name of performance cmd codes -** Revision 1.36 2007/03/29 15:22:34EST rjmcgraw -** Changed #define names for Logic Analyzer Cmd Codes -** -*/ - -#ifndef _cfe_es_ -#define _cfe_es_ - -/* -** Includes -*/ -#include "cfe_mission_cfg.h" -#include "cfe_es_perfids.h" - -/*****************************************************************************/ - -/* -** Macro Definitions -*/ - -/* -** The OS_PRINTF macro may be defined by OSAL to enable -** printf-style argument checking. If using a version of OSAL -** that does not define this then define it as a no-op. -*/ -#ifndef OS_PRINTF -#define OS_PRINTF(m,n) -#endif - -#define CFE_ES_DBIT(x) (1L << (x)) /* Places a one at bit positions 0 thru 31 */ -#define CFE_ES_DTEST(i,x) (((i) & CFE_ES_DBIT(x)) != 0) /* TRUE iff bit x of i is set */ -#define CFE_ES_TEST_LONG_MASK(m,s) (CFE_ES_DTEST(m[(s)/32],(s)%32)) /* Test a bit within an array of 32-bit integers. */ -#define CFE_ES_MAX_MEMPOOL_BLOCK_SIZES 17 /**< Max number of size divisions allowed in a memory pool */ - -/* -** Note about reset type and subtypes: -** -** These values come from the PSP so the actual definition of these enumerations -** was moved to the PSP header file . -** -** In the future the Electronic Data sheets (EDS) for PSP/ES -** will define the exact values to use in telemetry messages. -*/ - -/* -** Reset types -*/ -/** \name Reset Type extensions */ -/** \{ */ -#define CFE_ES_APP_RESTART CFE_PSP_RST_TYPE_MAX /**< Application only was reset (extend the PSP enumeration here) */ -/** \} */ - - -/** \name Critical Data Store Macros */ -/** \{ */ -/** Maximum length allowed for CDS name.
-** NOTE: "+2" is for NULL Character and "." (i.e. - "AppName.CDSName") */ -#define CFE_ES_CDS_MAX_FULL_NAME_LEN (CFE_ES_CDS_MAX_NAME_LENGTH + OS_MAX_API_NAME + 2) - -#define CFE_ES_CDS_BAD_HANDLE (CFE_ES_CDSHandle_t) 0xFFFF -/** \} */ - -/* -** ES Run Status and Exit Status defines -*/ -/** \name Run Status and Exit Status identifiers */ -/** \{ */ -#define CFE_ES_RUNSTATUS_APP_RUN 1 /**< \brief Indicates that the Application should continue to run */ -#define CFE_ES_RUNSTATUS_APP_EXIT 2 /**< \brief Indicates that the Application wants to exit normally */ -#define CFE_ES_RUNSTATUS_APP_ERROR 3 /**< \brief Indicates that the Application is quitting with an error */ -#define CFE_ES_RUNSTATUS_SYS_EXCEPTION 4 /**< \brief The cFE App caused an exception */ -#define CFE_ES_RUNSTATUS_SYS_RESTART 5 /**< \brief The system is requesting a restart of the cFE App */ -#define CFE_ES_RUNSTATUS_SYS_RELOAD 6 /**< \brief The system is requesting a reload of the cFE App */ -#define CFE_ES_RUNSTATUS_SYS_DELETE 7 /**< \brief The system is requesting that the cFE App is stopped */ -#define CFE_ES_RUNSTATUS_CORE_APP_INIT_ERROR 8 /**< \brief Indicates that the Core Application could not Init */ -#define CFE_ES_RUNSTATUS_CORE_APP_RUNTIME_ERROR 9 /**< \brief Indicates that the Core Application had a runtime failure */ -/** \} */ - -#define CFE_ES_APP_KILL_TIMEOUT 5 /**< \brief Number of cycles that ES will wait before killing an app */ - -#define CFE_ES_NO_MUTEX 0 /**< \brief Indicates that the memory pool selection will not use a semaphore */ -#define CFE_ES_USE_MUTEX 1 /**< \brief Indicates that the memory pool selection will use a semaphore */ - -/* -** System Log Defines -*/ -/* "+1" is for the space between the timestamp and the message in the system log */ -#define CFE_ES_MAX_SYSLOG_MSG_SIZE (CFE_EVS_MAX_MESSAGE_LENGTH + CFE_TIME_PRINTED_STRING_SIZE + 1) - - -/* - * To preserve source-code compatibility with existing code, - * this allows the old enum names to still work. This should - * be turned off after the new names are established. - * (sed -i -e 's///g' should take care of it) - * - * Note about why this is a good idea to do -- - * In the list below there are two values with similar names: - * CFE_ES_EXCEPTION, CFE_ES_SYS_EXCEPTION - * - * But these map to different values for two different purposes, - * one is a app status and the other is a reset subtype. Using the - * new names makes it much clearer as to which is which, will - * greatly reduce the chance of getting them mixed up, and make it - * much more obvious to a code reviewer if the ARE mixed up somewhere. - */ -#ifndef CFE_ES_ENABLE_NEW_ENUM_NAMES - -#define CFE_ES_PROCESSOR_RESET CFE_PSP_RST_TYPE_PROCESSOR -#define CFE_ES_POWERON_RESET CFE_PSP_RST_TYPE_POWERON - -#define CFE_ES_POWER_CYCLE CFE_PSP_RST_SUBTYPE_POWER_CYCLE -#define CFE_ES_PUSH_BUTTON CFE_PSP_RST_SUBTYPE_PUSH_BUTTON -#define CFE_ES_HW_SPECIAL_COMMAND CFE_PSP_RST_SUBTYPE_HW_SPECIAL_COMMAND -#define CFE_ES_HW_WATCHDOG CFE_PSP_RST_SUBTYPE_HW_WATCHDOG -#define CFE_ES_RESET_COMMAND CFE_PSP_RST_SUBTYPE_RESET_COMMAND -#define CFE_ES_EXCEPTION CFE_PSP_RST_SUBTYPE_EXCEPTION -#define CFE_ES_UNDEFINED_RESET CFE_PSP_RST_SUBTYPE_UNDEFINED_RESET -#define CFE_ES_HWDEBUG_RESET CFE_PSP_RST_SUBTYPE_HWDEBUG_RESET -#define CFE_ES_BANKSWITCH_RESET CFE_PSP_RST_SUBTYPE_BANKSWITCH_RESET - -#define CFE_ES_APP_RUN CFE_ES_RUNSTATUS_APP_RUN -#define CFE_ES_APP_EXIT CFE_ES_RUNSTATUS_APP_EXIT -#define CFE_ES_APP_ERROR CFE_ES_RUNSTATUS_APP_ERROR -#define CFE_ES_SYS_EXCEPTION CFE_ES_RUNSTATUS_SYS_EXCEPTION -#define CFE_ES_SYS_RESTART CFE_ES_RUNSTATUS_SYS_RESTART -#define CFE_ES_SYS_RELOAD CFE_ES_RUNSTATUS_SYS_RELOAD -#define CFE_ES_SYS_DELETE CFE_ES_RUNSTATUS_SYS_DELETE -#define CFE_ES_CORE_APP_INIT_ERROR CFE_ES_RUNSTATUS_CORE_APP_INIT_ERROR -#define CFE_ES_CORE_APP_RUNTIME_ERROR CFE_ES_RUNSTATUS_CORE_APP_RUNTIME_ERROR - -#endif - -/*****************************************************************************/ -/* -** Type Definitions -*/ - -/* -** Memory Handle type -*/ -typedef cpuaddr CFE_ES_MemHandle_t; /**< \brief Data type used to hold Handles of Memory Pools created via CFE_ES_PoolCreate and CFE_ES_PoolCreateNoSem */ - -/* -** -** CFE_ES_AppInfo_t is a structure that is used to provide -** information about an app. It is primarily used for the QueryOne and -** QueryAll Commands. -** -*/ -typedef struct -{ - uint32 AppId; /**< \cfetlmmnemonic \ES_APP_ID - \brief Application ID for this Application */ - uint32 Type; /**< \cfetlmmnemonic \ES_APPTYPE - \brief The type of App: CORE or EXTERNAL */ - - char Name[OS_MAX_API_NAME]; /**< \cfetlmmnemonic \ES_APPNAME - \brief The Registered Name of the Application */ - char EntryPoint[OS_MAX_API_NAME]; /**< \cfetlmmnemonic \ES_APPENTRYPT - \brief The Entry Point label for the Application */ - char FileName[OS_MAX_PATH_LEN]; /**< \cfetlmmnemonic \ES_APPFILENAME - \brief The Filename of the file containing the Application */ - - uint32 StackSize; /**< \cfetlmmnemonic \ES_STACKSIZE - \brief The Stack Size of the Application */ - uint32 ModuleId; /**< \cfetlmmnemonic \ES_MODULEID - \brief The ID of the Loadable Module for the Application */ - uint32 AddressesAreValid; /**< \cfetlmmnemonic \ES_ADDRVALID - \brief Indicates that the Code, Data, and BSS addresses/sizes are valid */ - uint32 CodeAddress; /**< \cfetlmmnemonic \ES_CODEADDR - \brief The Address of the Application Code Segment*/ - uint32 CodeSize; /**< \cfetlmmnemonic \ES_CODESIZE - \brief The Code Size of the Application */ - uint32 DataAddress; /**< \cfetlmmnemonic \ES_DATAADDR - \brief The Address of the Application Data Segment*/ - uint32 DataSize; /**< \cfetlmmnemonic \ES_DATASIZE - \brief The Data Size of the Application */ - uint32 BSSAddress; /**< \cfetlmmnemonic \ES_BSSADDR - \brief The Address of the Application BSS Segment*/ - uint32 BSSSize; /**< \cfetlmmnemonic \ES_BSSSIZE - \brief The BSS Size of the Application */ - uint32 StartAddress; /**< \cfetlmmnemonic \ES_STARTADDR - \brief The Start Address of the Application */ - uint16 ExceptionAction; /**< \cfetlmmnemonic \ES_EXCEPTNACTN - \brief What should occur if Application has an exception - (Restart Application OR Restart Processor) */ - uint16 Priority; /**< \cfetlmmnemonic \ES_PRIORITY - \brief The Priority of the Application */ - uint32 MainTaskId; /**< \cfetlmmnemonic \ES_MAINTASKID - \brief The Application's Main Task ID */ - uint32 ExecutionCounter; /**< \cfetlmmnemonic \ES_MAINTASKEXECNT - \brief The Application's Main Task Execution Counter */ - char MainTaskName[OS_MAX_API_NAME]; /**< \cfetlmmnemonic \ES_MAINTASKNAME - \brief The Application's Main Task ID */ - uint32 NumOfChildTasks; /**< \cfetlmmnemonic \ES_CHILDTASKS - \brief Number of Child tasks for an App */ - -} CFE_ES_AppInfo_t; - -/* -** Task Info Type -*/ -typedef struct -{ - uint32 TaskId; /**< \brief Task Id */ - uint32 ExecutionCounter; /**K \brief Task Execution Counter */ - uint8 TaskName[OS_MAX_API_NAME]; /**< \brief Task Name */ - uint32 AppId; /**< \brief Parent Application ID */ - uint8 AppName[OS_MAX_API_NAME]; /**< \brief Parent Application Name */ - -} CFE_ES_TaskInfo_t; - -/* -** Memory Pool Statistics data type -*/ -typedef struct -{ - uint32 BlockSize; /**< \brief Number of bytes in each of these blocks */ - uint32 NumCreated; /**< \brief Number of Memory Blocks of this size created */ - uint32 NumFree; /**< \brief Number of Memory Blocks of this size that are free */ -} CFE_ES_BlockStats_t; - -typedef struct -{ - uint32 PoolSize; /**< \cfetlmmnemonic \ES_POOLSIZE - \brief Size of Memory Pool (in bytes) */ - uint32 NumBlocksRequested; /**< \cfetlmmnemonic \ES_BLKSREQ - \brief Number of times a memory block has been allocated */ - uint32 CheckErrCtr; /**< \cfetlmmnemonic \ES_BLKERRCTR - \brief Number of errors detected when freeing a memory block */ - uint32 NumFreeBytes; /**< \cfetlmmnemonic \ES_FREEBYTES - \brief Number of bytes never allocated to a block */ - CFE_ES_BlockStats_t BlockStats[CFE_ES_MAX_MEMPOOL_BLOCK_SIZES]; /**< \cfetlmmnemonic \ES_BLKSTATS - \brief Contains stats on each block size */ -} CFE_ES_MemPoolStats_t; - -/* -** CDS Handle type -*/ -typedef cpuaddr CFE_ES_CDSHandle_t; /**< \brief Data type used to hold Handles of Critical Data Stores. See CFE_ES_RegisterCDS */ - -typedef struct -{ - CFE_ES_CDSHandle_t Handle; /**< \brief Handle of CDS */ - uint32 Size; /**< \brief Size, in bytes, of the CDS memory block */ - boolean Table; /**< \brief Flag that indicates whether CDS contains a Critical Table */ - char Name[CFE_ES_CDS_MAX_FULL_NAME_LEN]; /**< \brief Processor Unique Name of CDS */ - uint8 ByteAlignSpare1; /**< \brief Spare byte to insure structure size is multiple of 4 bytes */ -} CFE_ES_CDSRegDumpRec_t; - -/* -** Child Task Main Function Prototype -*/ -typedef void (*CFE_ES_ChildTaskMainFuncPtr_t)(void); /**< \brief Required Prototype of Child Task Main Functions */ -typedef int32 (*CFE_ES_LibraryEntryFuncPtr_t)(void); /**< \brief Required Prototype of Library Initialization Functions */ - -typedef enum -{ - CFE_ES_STATICENTRYTYPE_INVALID = 0, - CFE_ES_STATICENTRYTYPE_FIRST_VALID = 2000, - CFE_ES_STATICENTRYTYPE_APPLICATION, - CFE_ES_STATICENTRYTYPE_LIBRARY, - CFE_ES_STATICENTRYTYPE_MAX -} CFE_ES_StaticEntryType_t; - -/* -** API Structure for statically linked CFS Applications -*/ -typedef const struct -{ - CFE_ES_StaticEntryType_t EntryType; - union - { - CFE_ES_ChildTaskMainFuncPtr_t AppEntryFunc; /**< \brief Entry point for Application */ - CFE_ES_LibraryEntryFuncPtr_t LibInitFunc; /**< \brief Initialization function for Library */ - cpuaddr EntryFuncAddr; - } Ptrs; - uint32 Priority; - uint32 StackSize; -} CFE_ES_AppStaticModuleApi_t; - -#ifdef CFS_STATIC_MODULE - -#define CFS_MODULE_DECLARE_APP(name,pri,stack) \ - void name##_Main(void); \ - CFE_ES_AppStaticModuleApi_t CFS_##name##_API = \ - { \ - .EntryType = CFE_ES_STATICENTRYTYPE_APPLICATION, \ - .Ptrs.AppEntryFunc = name##_Main, \ - .Priority = pri, \ - .StackSize = stack, \ - } - -#define CFS_MODULE_DECLARE_LIB(name) \ - int32 name##_Init(void); \ - CFE_ES_AppStaticModuleApi_t CFS_##name##_API = \ - { \ - .EntryType = CFE_ES_STATICENTRYTYPE_LIBRARY, \ - .Ptrs.LibInitFunc = name##_Init, \ - } -#else -#define CFS_MODULE_DECLARE_APP(name,pri,stack) -#define CFS_MODULE_DECLARE_LIB(name) -#endif - - -/*****************************************************************************/ -/* -** Exported Functions -*/ - -/*****************************************************************************/ - -#if !defined(OSAL_OPAQUE_OBJECT_IDS) -/* -** \brief Compatibility wrapper for older versions of OSAL -** -** \par Description -** In future versions of OSAL the task/object ID values might not be zero based -** If that is the case then the OSAL must also define a function to convert back -** to zero-based numbers such that the value can be used as an array index. -** -** When using an existing/older version of OSAL, this inline function is defined -** to mimic this call for backward compatibility. It just passes through the same -** value without modification. -** -** \param[in] ObjectId The object ID from OSAL -** \param[out] ArrayIndex A zero-based value suitable for use as an array index -** \returns OS_SUCCESS (a real version might return an error code). -*/ -static inline int32 OS_ConvertToArrayIndex(uint32 ObjectId, uint32 *ArrayIndex) -{ - *ArrayIndex = ObjectId; - return OS_SUCCESS; -} -#endif - - - -/*****************************************************************************/ -/** -** \brief cFE Main Entry Point used by Board Support Package to start cFE -** -** \par Description -** cFE main entry point. This is the entry point into the cFE software. -** It is called only by the Board Support Package software. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] StartType Identifies whether this was a #CFE_PSP_RST_TYPE_POWERON or #CFE_PSP_RST_TYPE_PROCESSOR. -** -** \param[in] StartSubtype Specifies, in more detail, what caused the \c StartType identified above. -** See #CFE_ES_POWER_CYCLE for possible examples. -** -** \param[in] ModeId Identifies the source of the Boot as determined by the BSP. -** -** \param[in] StartFilePath Identifies the startup file to use to initialize the cFE apps. -** -** \sa #CFE_ES_ResetCFE -** -******************************************************************************/ -void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId , const char *StartFilePath ); - -/*****************************************************************************/ -/** -** \brief Return the most recent Reset Type -** -** \par Description -** Provides the caller with codes that identifies the type of Reset -** the processor most recently underwent. The caller can also obtain -** information on what caused the reset by supplying a pointer to a -** variable that will be filled with the Reset Sub-Type. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] ResetSubtypePtr Pointer to \c uint32 type variable in which the Reset Sub-Type will be stored. -** The caller can set this pointer to NULL if the Sub-Type is of no interest. -** -** \param[out] *ResetSubtypePtr If the provided pointer was not \c NULL, the Reset Sub-Type is stored at the given address. -** For a list of possible Sub-Type values, see \link #CFE_ES_POWER_CYCLE "Reset Sub-Types" \endlink. -** -** \returns -** \retcode #CFE_PSP_RST_TYPE_POWERON \retdesc \copydoc CFE_PSP_RST_TYPE_POWERON \endcode -** \retcode #CFE_PSP_RST_TYPE_PROCESSOR \retdesc \copydoc CFE_PSP_RST_TYPE_PROCESSOR \endcode -** \endreturns -** -** \sa #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName, #CFE_ES_GetTaskInfo -** -******************************************************************************/ -int32 CFE_ES_GetResetType(uint32 *ResetSubtypePtr); - -/*****************************************************************************/ -/** -** \brief Reset the cFE Core and all cFE Applications -** -** \par Description -** This API causes an immediate reset of the cFE Kernel and all cFE Applications. -** The caller can specify whether the reset should clear all memory (#CFE_PSP_RST_TYPE_POWERON) -** or try to retain volatile memory areas (#CFE_PSP_RST_TYPE_PROCESSOR). -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] ResetType Identifies the type of reset desired. Allowable settings are: -** \arg #CFE_PSP_RST_TYPE_POWERON - Causes all memory to be cleared -** \arg #CFE_PSP_RST_TYPE_PROCESSOR - Attempts to retain volatile disk, critical data store and user reserved memory. -** -** \returns -** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode -** \retcode #CFE_ES_NOT_IMPLEMENTED \retdesc \copydoc CFE_ES_NOT_IMPLEMENTED \endcode -** \endreturns -** -** \sa #CFE_ES_Main -** -******************************************************************************/ -int32 CFE_ES_ResetCFE(uint32 ResetType); - -/*****************************************************************************/ -/** -** \brief Restart a single cFE Application -** -** \par Description -** This API causes a cFE Application to be stopped and restarted. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] AppID Identifies the application to be reset. -** -** \returns -** \retcode #CFE_ES_NOT_IMPLEMENTED \retdesc \copydoc CFE_ES_NOT_IMPLEMENTED \endcode -** \endreturns -** -** \sa #CFE_ES_ReloadApp, #CFE_ES_DeleteApp -** -******************************************************************************/ -int32 CFE_ES_RestartApp(uint32 AppID); - -/*****************************************************************************/ -/** -** \brief Reload a single cFE Application -** -** \par Description -** This API causes a cFE Application to be stopped and restarted from -** the specified file. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] AppID Identifies the application to be reset. -** -** \param[in] AppFileName Identifies the new file to start. -** -** \returns -** \retcode #CFE_ES_NOT_IMPLEMENTED \retdesc \copydoc CFE_ES_NOT_IMPLEMENTED \endcode -** \endreturns -** -** \sa #CFE_ES_RestartApp, #CFE_ES_DeleteApp -** -******************************************************************************/ -int32 CFE_ES_ReloadApp(uint32 AppID, const char *AppFileName); - -/*****************************************************************************/ -/** -** \brief Delete a cFE Application -** -** \par Description -** This API causes a cFE Application to be stopped deleted. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] AppID Identifies the application to be reset. -** -** \returns -** \retcode #CFE_ES_NOT_IMPLEMENTED \retdesc \copydoc CFE_ES_NOT_IMPLEMENTED \endcode -** \endreturns -** -** \sa #CFE_ES_RestartApp, #CFE_ES_ReloadApp -** -******************************************************************************/ -int32 CFE_ES_DeleteApp(uint32 AppID); - -/*****************************************************************************/ -/** -** \brief Exit a cFE Application -** -** \par Description -** This API is the "Exit Point" for the cFE application -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] ExitStatus . -** -** \returns -** \retcode #CFE_ES_NOT_IMPLEMENTED \retdesc \copydoc CFE_ES_NOT_IMPLEMENTED \endcode -** \endreturns -** -** \sa #CFE_ES_RunLoop, #CFE_ES_RegisterApp -** -******************************************************************************/ -void CFE_ES_ExitApp(uint32 ExitStatus); - - -/*****************************************************************************/ -/** -** \brief Check for Exit, Restart, or Reload commands -** -** \par Description -** This is the API that allows an app to check for exit requests from -** the system. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] ExitStatus A pointer to a variable containing the Application's -** desired run status. Acceptable values are: -** \arg #CFE_ES_APP_RUN - \copydoc CFE_ES_APP_RUN -** \arg #CFE_ES_APP_EXIT - \copydoc CFE_ES_APP_EXIT -** \arg #CFE_ES_APP_ERROR - \copydoc CFE_ES_APP_ERROR -** -** \returns -** \retcode #TRUE \retdesc The application should continue executing \endcode -** \retcode #FALSE \retdesc The application should terminate itself \endcode -** \endreturns -** -** \sa #CFE_ES_ExitApp, #CFE_ES_RegisterApp -** -******************************************************************************/ -int32 CFE_ES_RunLoop(uint32 *ExitStatus); - -/*****************************************************************************/ -/** -** \brief Allow an Application to Wait for others to start up -** -** \par Description -** This is the API that allows an app to wait for the "rest" of the apps -** to finish initializing before continuing. It is most useful for -** applications such as Health and Safety or the Scheduler that need -** to wait until applications exist and are running before sending out -** packets to them. -** -** \par Assumptions, External Events, and Notes: -** This API should only be called as the last item of an Apps initialization. -** In addition, this API should only be called by an App that is started -** from the ES Startup file. It should not be used by an App that is -** started after the system is running. ( Although it will cause no harm ) -** -** \param[in] TimeOutMilliseconds The timeout value in Milliseconds. -** This parameter must be at least 1000. Lower values -** will be rounded up. There is not an option to -** wait indefinitely to avoid hanging a critical -** application because a non-critical app did not start. -** -** -** \sa #CFE_ES_RunLoop -** -******************************************************************************/ -void CFE_ES_WaitForStartupSync(uint32 TimeOutMilliseconds); - - -/* -** Application Management functions -*/ - -/*****************************************************************************/ -/** -** \brief Registers a cFE Application with the Executive Services -** -** \par Description -** This API registers the calling Application with the cFE. -** -** \par Assumptions, External Events, and Notes: -** NOTE: This function \b MUST be called before any other cFE API functions are called. -** -** \returns -** \retstmt Return codes from #OS_TaskRegister \endcode -** \retstmt Return codes from #OS_BinSemTake \endcode -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \endreturns -** -** \sa #CFE_ES_ExitApp, #CFE_ES_RunLoop -** -******************************************************************************/ -int32 CFE_ES_RegisterApp(void); - -/*****************************************************************************/ -/** -** \brief Get an Application ID for the calling Application -** -** \par Description -** This routine retrieves the cFE Application ID for the calling Application. -** -** \par Assumptions, External Events, and Notes: -** NOTE: \b All tasks associated with the Application would return the same Application ID. -** -** \param[in] AppIdPtr Pointer to variable that is to receive the Application's ID. -** -** \param[out] *AppIdPtr Application ID of the calling Application. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_ERR_APPID \retdesc \copydoc CFE_ES_ERR_APPID \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \endreturns -** -** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName, #CFE_ES_GetTaskInfo -** -******************************************************************************/ -int32 CFE_ES_GetAppID(uint32 *AppIdPtr); - -/*****************************************************************************/ -/** -** \brief Get an Application ID associated with a specified Application name -** -** \par Description -** This routine retrieves the cFE Application ID associated with a -** specified Application name. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] AppIdPtr Pointer to variable that is to receive the Application's ID. -** -** \param[in] AppName Pointer to null terminated character string containing an Application name. -** -** \param[out] *AppIdPtr Application ID of the calling Application. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \endreturns -** -** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppID, #CFE_ES_GetAppName, #CFE_ES_GetTaskInfo -** -******************************************************************************/ -int32 CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName); - -/*****************************************************************************/ -/** -** \brief Get an Application name for a specified Application ID -** -** \par Description -** This routine retrieves the cFE Application ID associated with a -** specified Application name. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] AppName Pointer to a character array of at least \c BufferLength in size that will -** be filled with the appropriate Application name. -** -** \param[in] AppId Application ID of Application whose name is being requested. -** -** \param[in] BufferLength The maximum number of characters, including the null terminator, that can be put -** into the \c AppName buffer. This routine will truncate the name to this length, -** if necessary. -** -** \param[out] *AppName Null terminated Application name of the Application associated with the -** specified Application ID. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_ERR_APPID \retdesc \copydoc CFE_ES_ERR_APPID \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \endreturns -** -** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetTaskInfo -** -******************************************************************************/ -int32 CFE_ES_GetAppName(char *AppName, uint32 AppId, uint32 BufferLength); - -/*****************************************************************************/ -/** -** \brief Get Application Information given a specified App ID -** -** \par Description -** This routine retrieves the information about an App associated with a -** specified App ID. The information includes all of the information ES -** maintains for an application ( documented in the CFE_ES_AppInfo_t type ) -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] AppInfo Pointer to a \c CFE_ES_AppInfo_t structure that holds the specific -** Application information. -** -** \param[in] AppId Application ID of Application whose name is being requested. -** -** \param[out] *AppInfo Filled out \c CFE_ES_AppInfo_t structure containing the -** App Name, and application memory addresses among other fields. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_ERR_APPID \retdesc \copydoc CFE_ES_ERR_APPID \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \endreturns -** -** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName -** -******************************************************************************/ -int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, uint32 AppId); - -/*****************************************************************************/ -/** -** \brief Get Task Information given a specified Task ID -** -** \par Description -** This routine retrieves the information about a Task associated with a -** specified Task ID. The information includes Task Name, and Parent/Creator -** Application ID. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] TaskInfo Pointer to a \c CFE_ES_TaskInfo_t structure that holds the specific -** task information. -** -** \param[in] TaskId Application ID of Application whose name is being requested. -** -** \param[out] *TaskInfo Filled out \c CFE_ES_TaskInfo_t structure containing the -** Task Name, Parent App Name, Parent App ID among other fields. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_ERR_TASKID \retdesc \copydoc CFE_ES_ERR_TASKID \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \endreturns -** -** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName -** -******************************************************************************/ -int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, uint32 TaskId); - -/* -** Task management functions -*/ -/*****************************************************************************/ -/** -** \brief Registers a cFE Child task associated with a cFE Application -** -** \par Description -** This routine registers a cFE Child task and associates it with its parent -** cFE Application. -** -** \par Assumptions, External Events, and Notes: -** NOTE: This API \b MUST be called by the Child Task before any other cFE API calls are made. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_ERR_CHILD_TASK_REGISTER \retdesc \copydoc CFE_ES_ERR_CHILD_TASK_REGISTER \endcode -** \endreturns -** -** \sa #CFE_ES_CreateChildTask, #CFE_ES_DeleteChildTask, #CFE_ES_ExitChildTask -** -******************************************************************************/ -int32 CFE_ES_RegisterChildTask(void); - -/*****************************************************************************/ -/** -** \brief Creates a new task under an existing Application -** -** \par Description -** This routine creates a new task (a separate execution thread) owned by the calling Application. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] TaskIdPtr A pointer to a variable that will be filled in with the new task's ID. -** -** \param[in] TaskName A pointer to a string containing the desired name of the new task. -** This can be up to #OS_MAX_API_NAME characters, including the trailing null. -** -** \param[in] FunctionPtr A pointer to the function that will be spawned as a new task. This function -** must have the following signature: uint32 function(void). Input parameters -** for the new task are not supported. -** -** \param[in] StackPtr A pointer to the location where the child task's stack pointer should start. -** NOTE: Not all underlying operating systems support this parameter. -** -** \param[in] StackSize The number of bytes to allocate for the new task's stack. -** -** \param[in] Priority The priority for the new task. Lower numbers are higher priority, with 0 being -** the highest priority. Applications cannot create tasks with a higher priority -** (lower number) than their own priority. -** -** \param[in] Flags Reserved for future expansion. -** -** \param[out] *TaskIdPtr The Task ID of the newly created child task. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_ERR_CHILD_TASK_CREATE \retdesc \copydoc CFE_ES_ERR_CHILD_TASK_CREATE \endcode -** \endreturns -** -** \sa #CFE_ES_RegisterChildTask, #CFE_ES_DeleteChildTask, #CFE_ES_ExitChildTask -** -******************************************************************************/ -int32 CFE_ES_CreateChildTask(uint32 *TaskIdPtr, - const char *TaskName, - CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, - uint32 *StackPtr, - uint32 StackSize, - uint32 Priority, - uint32 Flags); - -/*****************************************************************************/ -/** -** \brief Deletes a task under an existing Application -** -** \par Description -** This routine deletes a task under an Application specified by the \c TaskId obtained -** when the child task was created using the #CFE_ES_CreateChildTask API. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] TaskId The task ID previously obtained when the Child Task was created with the #CFE_ES_CreateChildTask API. -** -** \returns -** \retcode #CFE_ES_NOT_IMPLEMENTED \retdesc \copydoc CFE_ES_NOT_IMPLEMENTED \endcode -** \endreturns -** -** \sa #CFE_ES_RegisterChildTask, #CFE_ES_CreateChildTask, #CFE_ES_ExitChildTask -** -******************************************************************************/ -int32 CFE_ES_DeleteChildTask(uint32 TaskId); - -/*****************************************************************************/ -/** -** \brief Exits a child task -** -** \par Description -** This routine allows the current executing child task to exit and -** be deleted by ES. -** -** \par Assumptions, External Events, and Notes: -** This function cannot be called from an Application's Main Task. -** -** \returns -** \retstmt -** This function does not return a value, but if it does return -** at all, it is assumed that the Task was either unregistered or -** this function was called from a cFE Application's main task. \endcode -** \endreturns -** -** \sa #CFE_ES_RegisterChildTask, #CFE_ES_CreateChildTask, #CFE_ES_DeleteChildTask -** -******************************************************************************/ -void CFE_ES_ExitChildTask(void); - -/*****************************************************************************/ -/** -** \brief Increments the execution counter for the calling task -** -** \par Description -** This routine increments the execution counter that is stored for -** the calling task. It can be called from cFE Application main tasks, child -** tasks, or cFE Core application main tasks. Normally, the call is not -** necessary from a cFE Application, since the CFE_ES_RunLoop call increments -** the counter for the Application. -** -** \par Assumptions, External Events, and Notes: -** NOTE: This API is not needed for Appplications that call the CFE_ES_RunLoop call. -** -** \returns -** \retstmt -** This function does not return a value. \endcode -** \endreturns -** -** \sa #CFE_ES_RunLoop -** -******************************************************************************/ -void CFE_ES_IncrementTaskCounter(void); - -/* -** Log management functions -*/ - -/*****************************************************************************/ -/** -** \brief Write a string to the cFE System Log -** -** \par Description -** This routine writes a formatted string to the cFE system log. This -** can be used to record very low-level errors that can't be reported -** using the Event Services. This function is used in place of printf -** for flight software. It should be used for significant startup events, -** critical errors, and conditionally compiled debug software. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] SpecStringPtr The format string for the log message. -** This is similar to the format string for a printf() call. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_ERR_SYS_LOG_FULL \retdesc \copydoc CFE_ES_ERR_SYS_LOG_FULL \endcode -** \endreturns -** -** \sa -** -******************************************************************************/ -int32 CFE_ES_WriteToSysLog(const char *SpecStringPtr, ...) OS_PRINTF(1,2); - -/*****************************************************************************/ -/** -** \brief Calculate a CRC on a block of memory -** -** \par Description -** This routine calculates a cyclic redundancy check (CRC) on a block of memory. The CRC algorithm -** used is determined by the last parameter. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] DataPtr Pointer to the base of the memory block. -** -** \param[in] DataLength The number of bytes in the memory block. -** -** \param[in] InputCRC A starting value for use in the CRC calculation. This parameter -** allows the user to calculate the CRC of non-contiguous blocks as -** a single value. Nominally, the user should set this value to zero. -** -** \param[in] TypeCRC One of the following CRC algorithm selections: -** -** \arg \c CFE_ES_CRC_8 - (Not currently implemented) -** \arg \c CFE_ES_CRC_16 - a CRC-16 algorithm -** \arg \c CFE_ES_CRC_32 - (not currently implemented) -** -** \returns -** \retstmt The result of the CRC calculation on the specified memory block. \endcode -** \endreturns -** -******************************************************************************/ -uint32 CFE_ES_CalculateCRC(const void *DataPtr, uint32 DataLength, uint32 InputCRC, uint32 TypeCRC); - -/* -** Critical Data Store API -*/ - -/*****************************************************************************/ -/** -** \brief Reserve space (or re-obtain previously reserved space) in the Critical Data Store (CDS) -** -** \par Description -** This routine allocates a block of memory in the Critical Data Store and associates it with -** the calling Application. The memory can survive an Application restart as well as a Processor Reset. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] HandlePtr Pointer Application's variable that will contain the CDS Memory Block Handle. -** -** \param[in] BlockSize The number of bytes needed in the CDS. -** -** \param[in] Name A pointer to a character string containing an application -** unique name of #CFE_ES_CDS_MAX_NAME_LENGTH characters or less. -** -** \param[out] *HandlePtr The handle of the CDS block that can be used in -** #CFE_ES_CopyToCDS and #CFE_ES_RestoreFromCDS. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc The memory block was successfully created in the CDS. \endcode -** \retcode #CFE_ES_NOT_IMPLEMENTED \retdesc The processor does not support a Critical Data Store. \endcode -** \retcode #CFE_ES_CDS_ALREADY_EXISTS \retdesc \copydoc CFE_ES_CDS_ALREADY_EXISTS \endcode -** \retcode #CFE_ES_CDS_INVALID_SIZE \retdesc \copydoc CFE_ES_CDS_INVALID_SIZE \endcode -** \retcode #CFE_ES_CDS_INVALID_NAME \retdesc \copydoc CFE_ES_CDS_INVALID_NAME \endcode -** \retcode #CFE_ES_CDS_REGISTRY_FULL \retdesc \copydoc CFE_ES_CDS_REGISTRY_FULL \endcode -** \endreturns -** -** \sa #CFE_ES_CopyToCDS, #CFE_ES_RestoreFromCDS -** -******************************************************************************/ -int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, int32 BlockSize, const char *Name); - -/*****************************************************************************/ -/** -** \brief Save a block of data in the Critical Data Store (CDS) -** -** \par Description -** This routine copies a specified block of memory into the Critical Data Store that -** had been previously registered via #CFE_ES_RegisterCDS. The block of memory to be -** copied must be at least as big as the size specified when registering the CDS. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] Handle The handle of the CDS block that was previously obtained from #CFE_ES_RegisterCDS. -** -** \param[in] DataToCopy A Pointer to the block of memory to be copied into the CDS. -** -** \returns -** \retcode #OS_SUCCESS \retdesc \copydoc OS_SUCCESS \endcode -** \retcode #CFE_ES_ERR_MEM_HANDLE \retdesc \copydoc CFE_ES_ERR_MEM_HANDLE \endcode -** \retcode #OS_ERROR \retdesc Problem with handle or a size mismatch \endcode -** \endreturns -** -** \sa #CFE_ES_RegisterCDS, #CFE_ES_RestoreFromCDS -** -*/ -int32 CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t Handle, void *DataToCopy); - -/*****************************************************************************/ -/** -** \brief Recover a block of data from the Critical Data Store (CDS) -** -** \par Description -** This routine copies data from the Critical Data Store identified with the \c Handle into -** the area of memory pointed to by the \c RestoreToMemory pointer. The area of memory to -** be copied into must be at least as big as the size specified when registering the CDS. -** The recovery will indicate an error if the data integrity check maintained by the CDS -** indicates the contents of the CDS have changed. However, the contents will still be -** copied into the specified area of memory. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] Handle The handle of the CDS block that was previously obtained from #CFE_ES_RegisterCDS. -** -** \param[in] RestoreToMemory A Pointer to the block of memory that is to be restored with the contents of the CDS. -** -** \param[out] *RestoreToMemory The contents of the specified CDS. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_CDS_BLOCK_CRC_ERR \retdesc \copydoc CFE_ES_CDS_BLOCK_CRC_ERR \endcode -** \retcode #OS_ERROR \retdesc Problem with handle or a size mismatch \endcode -** \endreturns -** -** \sa #CFE_ES_RegisterCDS, #CFE_ES_CopyToCDS -** -*/ -int32 CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t Handle); - -/* -** Memory Allocation/Deallocation API -*/ - -/*****************************************************************************/ -/** -** \brief Initializes a memory pool created by an application without using a semaphore during processing. -** -** \par Description -** This routine initializes a pool of memory supplied by the calling application. When a memory pool -** created by this routine is processed, no mutex handling is performed. -** -** \par Assumptions, External Events, and Notes: -** -# The size of the pool must be an integral number of 32-bit words -** -# The start address of the pool must be 32-bit aligned -** -# 168 bytes are used for internal bookkeeping, therefore, they will not be available for allocation. -** -** \param[in] HandlePtr A pointer to the variable the caller wishes to have the memory pool handle kept in. -** -** \param[in] MemPtr A Pointer to the pool of memory created by the calling application. This address must -** be on a 32-bit boundary. -** -** \param[in] Size The size of the pool of memory. Note that this must be an integral number of 32 bit words. -** -** \param[out] *HandlePtr The memory pool handle. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode -** \endreturns -** -** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats -** -******************************************************************************/ -int32 CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *HandlePtr, uint8 *MemPtr, uint32 Size); - -/*****************************************************************************/ -/** -** \brief Initializes a memory pool created by an application while using a semaphore during processing. -** -** \par Description -** This routine initializes a pool of memory supplied by the calling application. When a memory pool -** created by this routine is processed, mutex handling will be performed. -** -** \par Assumptions, External Events, and Notes: -** -# The size of the pool must be an integral number of 32-bit words -** -# The start address of the pool must be 32-bit aligned -** -# 168 bytes are used for internal bookkeeping, therefore, they will not be available for allocation. -** -** \param[in] HandlePtr A pointer to the variable the caller wishes to have the memory pool handle kept in. -** -** \param[in] MemPtr A Pointer to the pool of memory created by the calling application. This address must -** be on a 32-bit boundary. -** -** \param[in] Size The size of the pool of memory. Note that this must be an integral number of 32 bit words. -** -** \param[out] *HandlePtr The memory pool handle. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode -** \endreturns -** -** \sa #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats -** -******************************************************************************/ -int32 CFE_ES_PoolCreate(CFE_ES_MemHandle_t *HandlePtr, uint8 *MemPtr, uint32 Size); - -/*****************************************************************************/ -/** -** \brief Initializes a memory pool created by an application with application specified block sizes. -** -** \par Description -** This routine initializes a pool of memory supplied by the calling application. -** -** \par Assumptions, External Events, and Notes: -** -# The size of the pool must be an integral number of 32-bit words -** -# The start address of the pool must be 32-bit aligned -** -# 168 bytes are used for internal bookkeeping, therefore, they will not be available for allocation. -** -** \param[in] HandlePtr A pointer to the variable the caller wishes to have the memory pool handle kept in. -** -** \param[in] MemPtr A Pointer to the pool of memory created by the calling application. This address must -** be on a 32-bit boundary. -** -** \param[in] Size The size of the pool of memory. Note that this must be an integral number of 32 bit words. -** -** \param[in] NumBlockSizes The number of different block sizes specified in the \c BlockSizes array. If set equal to -** zero or if greater than 17, then default block sizes are used. -** -** \param[in] BlockSizes Pointer to an array of sizes to be used instead of the default block sizes specified by -** #CFE_ES_MEM_BLOCK_SIZE_01 through #CFE_ES_MAX_BLOCK_SIZE. If the pointer is equal to NULL, -** the default block sizes are used. -** -** \param[in] UseMutex Flag indicating whether the new memory pool will be processing with mutex handling or not. -** Valid parameter values are #CFE_ES_USE_MUTEX and #CFE_ES_NO_MUTEX -** -** \param[out] *HandlePtr The memory pool handle. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode -** \endreturns -** -** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_GetPoolBuf, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats -** -******************************************************************************/ -int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *HandlePtr, uint8 *MemPtr, uint32 Size, uint32 NumBlockSizes, uint32 *BlockSizes, uint16 UseMutex); - -/*****************************************************************************/ -/** -** \brief Gets a buffer from the memory pool created by #CFE_ES_PoolCreate or #CFE_ES_PoolCreateNoSem -** -** \par Description -** This routine obtains a block of memory from the memory pool supplied by the calling application. -** -** \par Assumptions, External Events, and Notes: -** -# The size allocated from the memory pool is, at a minimum, 12 bytes more than requested. -** -** \param[in] BufPtr A pointer to the Application's pointer in which will be stored the address of the allocated memory buffer. -** -** \param[in] HandlePtr The handle to the memory pool as returned by #CFE_ES_PoolCreate or #CFE_ES_PoolCreateNoSem. -** -** \param[in] Size The size of the buffer requested. NOTE: The size allocated may be larger. -** -** \param[out] *BufPtr The address of the requested buffer. -** -** \returns -** \retstmt When successful, the return value is a positive number and is the number of bytes -** actually allocated for the buffer. \endcode -** \retcode #CFE_ES_ERR_MEM_HANDLE \retdesc \copydoc CFE_ES_ERR_MEM_HANDLE \endcode -** \retcode #CFE_ES_ERR_MEM_BLOCK_SIZE \retdesc \copydoc CFE_ES_ERR_MEM_BLOCK_SIZE \endcode -** \endreturns -** -** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats, #CFE_ES_GetPoolBufInfo -** -******************************************************************************/ -int32 CFE_ES_GetPoolBuf(uint32 **BufPtr, CFE_ES_MemHandle_t HandlePtr, uint32 Size); - -/*****************************************************************************/ -/** -** \brief Gets info on a buffer previously allocated via #CFE_ES_GetPoolBuf -** -** \par Description -** This routine gets info on a buffer in the memory pool. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] HandlePtr The handle to the memory pool as returned by #CFE_ES_PoolCreate or #CFE_ES_PoolCreateNoSem. -** -** \param[in] BufPtr A pointer to the memory buffer to provide status for. -** -** \returns -** \retstmt When successful, the return value is a positive number and is the number of bytes actually allocated. \endcode -** \retcode #CFE_ES_ERR_MEM_HANDLE \retdesc \copydoc CFE_ES_ERR_MEM_HANDLE \endcode -** \retcode #CFE_ES_BUFFER_NOT_IN_POOL \retdesc \copydoc CFE_ES_BUFFER_NOT_IN_POOL \endcode -** \endreturns -** -** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_GetMemPoolStats, #CFE_ES_PutPoolBuf -** -******************************************************************************/ -int32 CFE_ES_GetPoolBufInfo(CFE_ES_MemHandle_t HandlePtr, uint32 *BufPtr); - -/*****************************************************************************/ -/** -** \brief Releases a buffer from the memory pool that was previously allocated via #CFE_ES_GetPoolBuf -** -** \par Description -** This routine releases a buffer back into the memory pool. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] HandlePtr The handle to the memory pool as returned by #CFE_ES_PoolCreate or #CFE_ES_PoolCreateNoSem. -** -** \param[in] BufPtr A pointer to the memory buffer to be released. -** -** \returns -** \retstmt When successful, the return value is a positive number and is the number of bytes actually released. \endcode -** \retcode #CFE_ES_ERR_MEM_HANDLE \retdesc \copydoc CFE_ES_ERR_MEM_HANDLE \endcode -** \endreturns -** -** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_GetMemPoolStats, #CFE_ES_GetPoolBufInfo -** -******************************************************************************/ -int32 CFE_ES_PutPoolBuf(CFE_ES_MemHandle_t HandlePtr, uint32 *BufPtr); - -/*****************************************************************************/ -/** -** \brief Extracts the statistics maintained by the memory pool software -** -** \par Description -** This routine fills the #CFE_ES_MemPoolStats_t data structure with the statistics -** maintained by the memory pool software. These statistics can then be telemetered -** by the calling Application. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] BufPtr Pointer to #CFE_ES_MemPoolStats_t data structure to be -** filled with memory statistics. -** -** \param[in] Handle The handle to the memory pool whose statistics are desired. -** -** \param[out] *BufPtr Memory Pool Statistics stored in given data structure. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_ERR_MEM_HANDLE \retdesc \copydoc CFE_ES_ERR_MEM_HANDLE \endcode -** \endreturns -** -** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_PutPoolBuf -** -******************************************************************************/ -int32 CFE_ES_GetMemPoolStats(CFE_ES_MemPoolStats_t *BufPtr, CFE_ES_MemHandle_t Handle); - -/* -** Performance Log API -*/ - -/*****************************************************************************/ -/** -** \brief Entry marker for use with Software Performance Analysis Tool. -** -** \par Description -** This macro logs the entry or start event/marker for the specified -** entry \c id. This macro, in conjunction with the #CFE_ES_PerfLogExit, -** is used by the Software Performance Analysis tool (see section 5.15). -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] id Identifier of the specific event or marker. -** -** \sa #CFE_ES_PerfLogExit, #CFE_ES_PerfLogAdd -** -******************************************************************************/ -#define CFE_ES_PerfLogEntry(id) (CFE_ES_PerfLogAdd(id, 0)) - -/*****************************************************************************/ -/** -** \brief Exit marker for use with Software Performance Analysis Tool. -** -** \par Description -** This macro logs the exit or end event/marker for the specified -** entry \c id. This macro, in conjunction with the #CFE_ES_PerfLogEntry, -** is used by the Software Performance Analysis tool (see section 5.15). -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] id Identifier of the specific event or marker. -** -** \sa #CFE_ES_PerfLogEntry, #CFE_ES_PerfLogAdd -** -******************************************************************************/ -#define CFE_ES_PerfLogExit(id) (CFE_ES_PerfLogAdd(id, 1)) - - -/*****************************************************************************/ -/** -** \brief Function called by CFE_ES_PerfLogEntry and CFE_ES_PerfLogExit macros -** -** \par Description -** This function logs the entry and exit marker for the specified -** \c id. This function is used by the Software Performance Analysis -** tool (see section 5.15). -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] Marker Identifier of the specific event or marker. -** \param[in] EntryExit Used to specify Entry(0) or Exit(1) -** -** \sa #CFE_ES_PerfLogEntry, #CFE_ES_PerfLogExit -** -******************************************************************************/ -void CFE_ES_PerfLogAdd(uint32 Marker, uint32 EntryExit); - -/* -** Generic Counter API -*/ - -/*****************************************************************************/ -/** -** \brief Register a generic counter -** -** \par Description -** This routine registers a generic counter. -** -** \par Assumptions, External Events, and Notes: -** None. -** -** \param[in] *CounterName The Name of the generic counter. -** -** \param[out] *CounterIdPtr The Counter Id of the newly created counter. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode -** \endreturns -** -** \sa #CFE_ES_IncrementGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName -** -******************************************************************************/ -int32 CFE_ES_RegisterGenCounter(uint32 *CounterIdPtr, const char *CounterName); - -/*****************************************************************************/ -/** -** \brief Delete a generic counter -** -** \par Description -** This routine deletes a previously registered generic counter. -** -** \par Assumptions, External Events, and Notes: -** None. -** -** \param[in] CounterId The Counter Id of the newly created counter. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode -** \endreturns -** -** \sa #CFE_ES_IncrementGenCounter, #CFE_ES_RegisterGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName -** -******************************************************************************/ -int32 CFE_ES_DeleteGenCounter(uint32 CounterId); - -/*****************************************************************************/ -/** -** \brief Increments the specified generic counter -** -** \par Description -** This routine increments the specified generic counter. -** -** \par Assumptions, External Events, and Notes: -** None. -** -** \param[in] CounterId The Counter to be incremented. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode -** \endreturns -** -** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName -** -******************************************************************************/ -int32 CFE_ES_IncrementGenCounter(uint32 CounterId); - -/*****************************************************************************/ -/** -** \brief Set the specified generic counter -** -** \par Description -** This routine sets the specified generic counter to the specified value. -** -** \par Assumptions, External Events, and Notes: -** None. -** -** \param[in] CounterId The Counter to be set. -** -** \param[in] Count The new value of the Counter. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode -** \endreturns -** -** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_IncrementGenCounter, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName -** -******************************************************************************/ -int32 CFE_ES_SetGenCount(uint32 CounterId, uint32 Count); - -/*****************************************************************************/ -/** -** \brief Get the specified generic counter count -** -** \par Description -** This routine gets the value of a generic counter. -** -** \par Assumptions, External Events, and Notes: -** None. -** -** \param[in] CounterId The Counter to get the value from. -** -** \param[in] *Count The value of the Counter. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode -** \endreturns -** -** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_IncrementGenCounter, #CFE_ES_GetGenCounterIDByName -** -******************************************************************************/ -int32 CFE_ES_GetGenCount(uint32 CounterId, uint32 *Count); - - -/*****************************************************************************/ -/** -** \brief Get the Id associated with a generic counter name -** -** \par Description -** This routine gets the Counter Id for a generic counter specified by name. -** -** \par Assumptions, External Events, and Notes: -** None. -** -** \param[in] *CounterName The name of the Counter. -** -** \param[out] *CounterIdPtr The Counter Id for the given name. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_ES_BAD_ARGUMENT \retdesc \copydoc CFE_ES_BAD_ARGUMENT \endcode -** \endreturns -** -** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_IncrementGenCounter, #CFE_ES_GetGenCount -******************************************************************************/ -int32 CFE_ES_GetGenCounterIDByName(uint32 *CounterIdPtr, const char *CounterName); - -/*****************************************************************************/ -/** -** \brief Process an exception detected by the underlying OS/PSP -** -** \par Description -** This hook routine is called from the PSP when an exception occurs -** -** \par Assumptions, External Events, and Notes: -** None. -** -** \param[in] HostTaskId The OS (not OSAL) task ID -** \param[in] ReasonString Identifier from PSP -** \param[in] ContextPointer Context data from PSP -** \param[in] ContextSize Size of context data from PSP -** -******************************************************************************/ -void CFE_ES_ProcessCoreException(uint32 HostTaskId, const char *ReasonString, - const uint32 *ContextPointer, uint32 ContextSize); - - - -#endif /* _cfe_es_ */ diff --git a/src/components/interface/cFE/cfe_es_events.h b/src/components/interface/cFE/cfe_es_events.h deleted file mode 100644 index 71b89f5bdc..0000000000 --- a/src/components/interface/cFE/cfe_es_events.h +++ /dev/null @@ -1,1562 +0,0 @@ -/* -** File: -** cfe_es_events.h -** $Id: cfe_es_events.h 1.6 2014/08/21 15:34:53GMT-05:00 sstrege Exp $ -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** -** -** Purpose: -** cFE Executive Services (ES) Event IDs -** -** References: -** Flight Software Branch C Coding Standard Version 1.0a -** cFE Flight Software Application Developers Guide -** -** Notes: -** -** -** $Log: cfe_es_events.h $ -** Revision 1.6 2014/08/21 15:34:53GMT-05:00 sstrege -** Updated CFE_ES_ERREXIT_APP_ERR_EID from 31 to 33 -** Revision 1.5 2014/08/19 14:40:27EDT sstrege -** Fixed doxygen warnings -** Revision 1.4 2014/05/05 15:56:42EDT acudmore -** Fixed misleading event message text. -** Revision 1.3 2010/11/04 16:17:43GMT-05:00 jmdagost -** Updated Perf Analyzer start message, inserted perf analyzer error msg, updated subsequent event IDs. -** Revision 1.2 2008/12/08 12:07:19EST dkobe -** Updates to correct doxygen errors -** Revision 1.1 2008/04/17 08:05:19EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.32 2007/09/20 10:52:56EDT apcudmore -** Added Query All Tasks command, file definition, events, error codes etc. -** Revision 1.31 2007/09/18 16:39:10EDT apcudmore -** Updated ES invalid command length event message to make it clear. -** Revision 1.30 2007/06/02 10:10:10EDT dlkobe -** Added doxygen comments for User's Guides -** Revision 1.29 2007/05/25 11:51:39EDT dlkobe -** Modified doxygen to improve supporting docs -** Revision 1.28 2007/05/14 15:43:45EDT apcudmore -** Cleaned up events and disabled debug code for application restart. -** Revision 1.27 2007/05/11 11:59:05EDT apcudmore -** Removed Event IDs 33 and 34. -** They were no longer needed with the revised startup sync code. -** Revision 1.26 2007/05/11 10:15:07EDT rjmcgraw -** Added information to comments for CFE_ES_PERF_STOPCMD_EID -** Revision 1.25 2007/05/11 09:32:54EDT rjmcgraw -** DCR3211:2 Added 3 new perf events for 'in progress' checks -** Revision 1.24 2007/05/09 12:41:24EDT dlkobe -** Added event messages associated with Dump CDS Registry command -*/ -/*************************************************************************/ -#ifndef _cfe_es_events_ -#define _cfe_es_events_ - -/* -** ES task event message ID's. -*/ - -/** \brief 'cFE ES Initialized' -** \event 'cFE ES Initialized' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always automatically issued when the Executive Services -** Task completes its Initialization. -**/ -#define CFE_ES_INIT_INF_EID 1 /* start up message "informational" */ - -/** \brief 'cFE Version \%d.\%d.\%d chksm \%d, OSAL Version \%d.\%d' -** \event 'cFE Version \%d.\%d.\%d chksm \%d, OSAL Version \%d.\%d' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always automatically issued when the Executive Services -** Task completes its Initialization. -** -** The \c Version field identifies the tagged version for the cFE Build, the \c chksm field -** provides the 16-bit checksum of the cFE Build and the \c OSAL \c Version field identifies -** the version of the OS Abstraction Layer on which this particular version of the cFE was built. -**/ -#define CFE_ES_INITSTATS_INF_EID 2 - -/** \brief 'No-op command' -** \event 'No-op command' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always automatically issued in response -** to a cFE Executive Services \link #CFE_ES_NOOP_CC NO-OP command \endlink -**/ -#define CFE_ES_NOOP_INF_EID 3 /* processed command "informational" */ - -/** \brief 'Reset Counters command' -** \event 'Reset Counters command' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always automatically issued in response -** to a cFE Executive Services \link #CFE_ES_RESET_CC Reset Counters command \endlink -**/ -#define CFE_ES_RESET_INF_EID 4 - -/** \brief 'Invoked shell command \%s' -** \event 'Invoked shell command \%s' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always automatically issued in response -** to a cFE Executive Services \link #CFE_ES_SHELL_CMD_CC Shell Command \endlink -** -** The \c 's' string contains the actual shell command string issued. -**/ -#define CFE_ES_SHELL_INF_EID 5 - -/** \brief 'Started \%s from \%s, AppID = \%d' -** \event 'Started \%s from \%s, AppID = \%d' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is automatically issued upon successful completion of -** a cFE Executive Services \link #CFE_ES_START_APP_CC Start Application command \endlink -** -** The first \c 's' string identifies the name of the started Application, the -** second \c 's' string identifies the filename from which the Application was -** loaded and the \c AppId field specifies the Application ID assigned to the -** newly started Application by the cFE Executive Services. -**/ -#define CFE_ES_START_INF_EID 6 - -/** \brief 'Stop Application \%s Initiated.' -** \event 'Stop Application \%s Initiated.' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is issued upon successful processing of the -** cFE Executive Services \link #CFE_ES_STOP_APP_CC Stop Application command \endlink -** Note that when this event is displayed, the Application is not deleted. ES has -** accepted the request to delete the application, and it will be deleted after the app exits -** it's main loop, or times out. -** -** The \c 's' field identifies the name of the Application that will be stopped. -**/ -#define CFE_ES_STOP_DBG_EID 7 - -/** \brief 'Stop Application \%s Completed.' -** \event 'Stop Application \%s Completed.' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is issued when the cFE finishes deleting the cFE Application -** That was started when the \link #CFE_ES_STOP_APP_CC Stop Application command \endlink -** was issued. -** -** The \c 's' field identifies the name of the Application that was stopped. -*/ -#define CFE_ES_STOP_INF_EID 8 - -/** \brief 'Restart Application \%s Initiated.' -** \event 'Restart Application \%s Initiated.' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is issued upon successful processing of the -** cFE Executive Services \link #CFE_ES_RESTART_APP_CC Restart Application command \endlink -** Note that when this event is displayed, the Application is not restarted. ES has -** accepted the request to restart the application, and it will be restarted after the app exits -** it's main loop, or times out. -** -** The \c 's' field identifies the name of the Application that will be restarted. -**/ -#define CFE_ES_RESTART_APP_DBG_EID 9 - -/** \brief 'Restart Application \%s Completed.' -** \event 'Restart Application \%s Completed.' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is issued when the cFE finishes Restarting the cFE Application -** That was started when the \link #CFE_ES_RESTART_APP_CC Restart Application command \endlink -** was issued. -** -** The \c 's' field identifies the name of the Application that was reloaded. -*/ -#define CFE_ES_RESTART_APP_INF_EID 10 - - -/** \brief 'Reload Application \%s Initiated.' -** \event 'Reload Application \%s Initiated.' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is issued upon successful processing of the -** cFE Executive Services \link #CFE_ES_RELOAD_APP_CC Reload Application command \endlink -** Note that when this event is displayed, the Application is not reloaded. ES has -** accepted the request to reload the application, and it will be reloaded after the app exits -** it's main loop, or times out. -** -** -** The \c 's' field identifies the name of the Application that will be reloaded. -**/ -#define CFE_ES_RELOAD_APP_DBG_EID 11 - - -/** \brief 'Reload Application \%s Completed.' -** \event 'Reload Application \%s Completed.' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is issued when the cFE finishes Reloading the cFE Application -** That was started when the \link #CFE_ES_RELOAD_APP_CC Restart Application command \endlink -** was issued. -** -** The \c 's' field identifies the name of the Application that was reloaded. -*/ -#define CFE_ES_RELOAD_APP_INF_EID 12 - -/** \brief 'Exit Application \%s Completed.' -** \event 'Exit Application \%s Completed.' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is issued when the cFE finishes exiting/cleaning up an -** application that called the CFE_ES_ExitApp API with the CFE_ES_APP_EXIT parameter. -** When an App calls this API, the request is recorded and the Executive Services App will -** actually delete cFE Application before issuing this event message. -** -** The \c 's' field identifies the name of the Application that was exited. -*/ -#define CFE_ES_EXIT_APP_INF_EID 13 - -/** \brief 'Exit Application \%s Completed.' -** \event 'Exit Application \%s Completed.' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is issued when the cFE finishes exiting/cleaning up an -** application that called the CFE_ES_ExitApp API with an ERROR condition. -** When an App calls this API, with the CFE_ES_APP_ERROR parameter, it indicates -** that the Application exited due to an error condition. The details of the -** error that occurred should be given by the Application through an event message, -** System Log entry, or both. -** The request is recorded and the Executive Services App will actually delete -** cFE Application before issuing this event message. -** -** The \c 's' field identifies the name of the Application that was exited. -*/ -#define CFE_ES_ERREXIT_APP_INF_EID 14 - - -/** \brief 'Sent \%s application data' -** \event 'Sent \%s application data' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is issued upon successful completion of the -** cFE Executive Services \link #CFE_ES_QUERY_ONE_CC Query One Application command \endlink -** -** The \c 's' field identifies the name of the Application whose Executive Services -** Application information has been telemetered. -**/ -#define CFE_ES_ONE_APP_EID 15 - -/** \brief 'App Info file written to \%s, Entries=\%d, FileSize=\%d' -** \event 'App Info file written to \%s, Entries=\%d, FileSize=\%d' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is issued upon successful completion of the cFE Executive -** Services \link #CFE_ES_QUERY_ALL_CC Query All Applications command \endlink -** -** The \c 's' field identifies the name of the file to which all Executive Services Application -** data has been written. The \c Entries field identifies, in decimal, the number of Applications -** whose data was written and the \c FileSize field gives the total number of bytes written to the -** file. -**/ -#define CFE_ES_ALL_APPS_EID 16 - -/** \brief 'Cleared Executive Services log data' -** \event 'Cleared Executive Services log data' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated upon successful completion of the cFE Executive -** Services \link #CFE_ES_CLEAR_SYSLOG_CC Clear System Log command \endlink -**/ -#define CFE_ES_SYSLOG1_INF_EID 17 - -/** \brief '\%s written:Size=\%d,Entries=\%d' -** \event '\%s written:Size=\%d,Entries=\%d' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated when the System Log has been successfully written -** to a file after receiving the cFE Executive Services \link #CFE_ES_CLEAR_SYSLOG_CC Write Executive -** Services System Log command \endlink -** -** The \c 's' field identifies the name of the file written to, the \c Size field specifies, in decimal, -** the number of bytes written to the file and the \c Entries field identifies the number of System Log -** messages that were written. -**/ -#define CFE_ES_SYSLOG2_EID 18 - -/** \brief 'Cleared mode log data' -** \event 'Cleared mode log data' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated upon successful completion of the cFE Executive -** Services \link #CFE_ES_CLEAR_ERLOG_CC Clear Exception Reset Log command \endlink -**/ -#define CFE_ES_ERLOG1_INF_EID 19 - -/** \brief '\%s written:Size=\%d' -** \event '\%s written:Size=\%d' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated when the Exception Reset Log has been successfully written -** to a file after receiving the cFE Executive Services \link #CFE_ES_WRITE_ERLOG_CC Write Executive -** Services Exception Reset Log command \endlink -** -** The \c 's' field identifies the name of the file written to and the \c Size field specifies, in decimal, -** the number of bytes written to the file. -**/ -#define CFE_ES_ERLOG2_EID 20 - -/** \brief 'Invalid command pipe message ID: 0x\%X' -** \event 'Invalid command pipe message ID: 0x\%X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a message has arrived on -** the cFE Executive Services Application's Message Pipe that has a -** Message ID that is neither #CFE_ES_SEND_HK_MID or #CFE_ES_CMD_MID. -** Most likely, the cFE Software Bus routing table has become corrupt -** and is sending messages targeted for other Applications to the cFE -** Executive Services Application. -** -** The \c ID field in the event message identifies -** the message ID (in hex) that was found in the message. -**/ -#define CFE_ES_MID_ERR_EID 21 /* invalid command packet "error" */ - -/** \brief 'Invalid ground command code: ID = 0x\%X, CC = \%d' -** \event 'Invalid ground command code: ID = 0x\%X, CC = \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a message with the #CFE_ES_CMD_MID -** message ID has arrived but whose Command Code is not one of the command -** codes specified in \link #CFE_ES_NOOP_CC cfe_es.h \endlink. This -** problem is most likely to occur when: -** -# A Message ID meant for another Application became corrupted and was -** set equal to #CFE_ES_CMD_MID. -** -# The Command Code field in the Message became corrupted. -** -# The command database at the ground station has been corrupted. -** -** The \c ID field in the event message specifies the Message ID (in hex) and the -** \c CC field specifies the Command Code (in decimal) found in the message. -**/ -#define CFE_ES_CC1_ERR_EID 22 - -/** \brief 'Invalid cmd length: ID = 0x\%X, CC = \%d, Exp Len = \%d, Len = \%d' -** \event 'Invalid cmd length: ID = 0x\%X, CC = \%d, Exp Len = \%d, Len = \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a message with the #CFE_ES_CMD_MID -** message ID has arrived but whose packet length does not match the expected -** length for the specified command code. -** -** The \c ID field in the event message specifies the Message ID (in hex), the \c CC field -** specifies the Command Code (in decimal), the \c Exp Len field specified the Expected -** Length (in decimal ), and \c Len specifies the message Length (in decimal) -** found in the message. -**/ -#define CFE_ES_LEN_ERR_EID 23 - -/** \brief 'Invalid cFE restart type \%d' -** \event 'Invalid cFE restart type \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is issued when the cFE Executive Services receives a -** \link #CFE_ES_RESTART_CC cFE Restart Command \endlink whose parameter -** identifying the restart type is not equal to either #CFE_ES_PROCESSOR_RESET -** or #CFE_ES_POWERON_RESET. -** -** The 'd' field identifies the numeric, in decimal, of the restart type found -** in the received cFE Restart Command Packet. -**/ -#define CFE_ES_BOOT_ERR_EID 24 /* command specific "error" */ - -/** \brief 'Failed to invoke shell command \%s, rc = \%08X' -** \event 'Failed to invoke shell command \%s, rc = \%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever the cFE Executive Services receives an OS Shell -** command, via the \link #CFE_ES_SHELL_CMD_CC Executive Services Shell Command \endlink, and -** the underlying OS returns an error code. -** -** The 's' field in the message identifies the shell command string that was issued -** and the \c rc field displays the shell's return code, in hex. -**/ -#define CFE_ES_SHELL_ERR_EID 25 - -/** \brief 'Failed to start \%s from \%s, RC = \%08X' -** \event 'Failed to start \%s from \%s, RC = \%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated for an error encountered in response -** to an Executive Services \link #CFE_ES_START_APP_CC Start Application Command \endlink. -** -** This message is a general failure when the command passes the parameter validation, but -** fails when a call to CFE_ES_AppCreate is called. -** -** The \c 's' term identifies the name of the Application that was attempted to start. -** The second \c 's' field specifies the file from which the Application was loaded. -** The \c 'X' field is the return code returned by the CFE_ES_AppCreate. -**/ -#define CFE_ES_START_ERR_EID 26 - -/** \brief 'CFE_ES_StartAppCmd: invalid filename: \%s' -** \event 'CFE_ES_StartAppCmd: invalid filename: \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated for an error encountered in response -** to an Executive Services \link #CFE_ES_START_APP_CC Start Application Command \endlink. -** -** This message reports a command failure when the Start Appplication Command is given -** an invalid filename. ( Either NULL or too short to be a valid cFE file name ). -** -** The \c 's' term identifies the invalid filename that was sent with the command. -**/ -#define CFE_ES_START_INVALID_FILENAME_ERR_EID 27 - -/** \brief 'CFE_ES_StartAppCmd: App Entry Point is NULL.' -** \event 'CFE_ES_StartAppCmd: App Entry Point is NULL.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated for an error encountered in response -** to an Executive Services \link #CFE_ES_START_APP_CC Start Application Command \endlink. -** -** This message reports a command failure when the Start Appplication Command is given -** a NULL Application Entry Point parameter. The command must contain an application entry -** point string. ( Example: "SC_AppMain" ). -** -**/ -#define CFE_ES_START_INVALID_ENTRY_POINT_ERR_EID 28 - -/** \brief 'CFE_ES_StartAppCmd: App Name is NULL.' -** \event 'CFE_ES_StartAppCmd: App Name is NULL.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated for an error encountered in response -** to an Executive Services \link #CFE_ES_START_APP_CC Start Application Command \endlink. -** -** This message reports a command failure when the Start Appplication Command is given -** a NULL Application Name parameter. The command must contain an application name string. -**/ -#define CFE_ES_START_NULL_APP_NAME_ERR_EID 29 - -/** \brief 'CFE_ES_StartAppCmd: Stack size is less than system Minimum: \%d.' -** \event 'CFE_ES_StartAppCmd: Stack size is less than system Minimum: \%d.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated for an error encountered in response -** to an Executive Services \link #CFE_ES_START_APP_CC Start Application Command \endlink. -** -** This message reports a command failure when the Application Stack Size parameter is -** less than the default stack size defined in the cfe_platform_cfg.h file: CFE_ES_DEFAULT_STACK_SIZE. -** -** The \c 'd' term identifies the size of the stack that was given in the command. -**/ -#define CFE_ES_START_STACK_ERR_EID 30 - -/** \brief 'CFE_ES_StartAppCmd: Priority is too large: \%d.' -** \event 'CFE_ES_StartAppCmd: Priority is too large: \%d.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated for an error encountered in response -** to an Executive Services \link #CFE_ES_START_APP_CC Start Application Command \endlink. -** -** This message reports a command failure when the Application priority greater than the -** maximum priority for a Task defined by the OS Abstraction Layer ( 256 ). -** -** The \c 'd' term identifies the priority that was given in the command. -**/ -#define CFE_ES_START_PRIORITY_ERR_EID 31 - -/** \brief 'CFE_ES_StartAppCmd: Invalid Exception Action: \%d.' -** \event 'CFE_ES_StartAppCmd: Invalid Exception Action: \%d.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated for an error encountered in response -** to an Executive Services \link #CFE_ES_START_APP_CC Start Application Command \endlink. -** -** This message reports a command failure when the Application Exception Action parameter is -** invalid. The valid options for this parameter are: 0 = Application will restart on an exception -** 1 = Application cause a processor restart on -** exception. -** -** The \c 'd' term identifies the Exception Action parameter that was given in the command. -**/ -#define CFE_ES_START_EXC_ACTION_ERR_EID 32 - -/** \brief 'Exit Application \%s on Error Failed: CleanUpApp Error 0x\%08X.' -** \event 'Exit Application \%s on Error Failed: CleanUpApp Error 0x\%08X.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when ES is completing the processing of the -** CFE_ES_ExitApp API call with the CFE_ES_APP_ERROR parameter and the call to CFE_ES_CleanUpApp fails. -** At this point the Application will likely be stopped or deleted, but it may be in an unknown state. -** -** The \c 's' field identifies the name of the Application which was attempted to be -** reloaded and the \c RC field identifies the error code, in hex, that will identify -** the precise reason for the failure. -**/ -#define CFE_ES_ERREXIT_APP_ERR_EID 33 - -/** \brief 'Stop Application \%s Failed, RC = 0x\%08X' -** \event 'Stop Application \%s Failed, RC = 0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of an Executive Services -** \link #CFE_ES_STOP_APP_CC Stop Application Command \endlink which fails. -** -** The \c 's' field identifies the name of the Application which was attempted to be -** stopped and the \c rc field identifies the error code, in hex, that may identify -** the precise reason for the failure. -**/ -#define CFE_ES_STOP_ERR1_EID 35 - -/** \brief 'Stop Application \%s, GetAppIDByName failed. RC = 0x\%08X.' -** \event 'Stop Application \%s, GetAppIDByName failed. RC = 0x\%08X.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of an Executive Services -** \link #CFE_ES_STOP_APP_CC Stop Application Command \endlink which fails. This message -** is for a specific failure when the call to CFE_ES_GetAppIDByName fails. The application -** will not be deleted at this point. -** -** The \c 's' field identifies the name of the Application which was attempted to be -** stopped and the \c RC field identifies the error code, in hex, that will identify -** the precise reason for the failure. -**/ -#define CFE_ES_STOP_ERR2_EID 36 - -/* -** "Stop Application \%s Failed: CleanUpApp Error 0x\%08X." -*/ - -/** \brief 'Stop Application \%s Failed: CleanUpApp Error 0x\%08X.' -** \event 'Stop Application \%s Failed: CleanUpApp Error 0x\%08X.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of an Executive Services -** \link #CFE_ES_STOP_APP_CC Stop Application Command \endlink which fails. This message -** is for a specific failure when the call to CFE_ES_GetAppIDByName fails. The application -** will not be deleted at this point. -** -** The \c 's' field identifies the name of the Application which was attempted to be -** stopped and the \c RC field identifies the error code, in hex, that will identify -** the precise reason for the failure. -**/ -#define CFE_ES_STOP_ERR3_EID 37 - - -/** \brief 'Restart Application \%s Failed, RC = 0x\%08X' -** \event 'Restart Application \%s Failed, RC = 0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services \link #CFE_ES_RESTART_APP_CC Restart Application -** Command \endlink fails. -** -** The \c 's' field identifies the name of the Application which was attempted to be -** reset and the \c rc field identifies the error code, in hex, that may identify -** the precise reason for the failure. -**/ -#define CFE_ES_RESTART_APP_ERR1_EID 38 - -/** \brief 'Restart Application \%s, GetAppIDByName failed. RC = 0x\%08X.' -** \event 'Restart Application \%s, GetAppIDByName failed. RC = 0x\%08X.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of an Executive Services -** \link #CFE_ES_RESTART_APP_CC Restart Application Command \endlink which fails. This message -** is for a specific failure when the call to CFE_ES_GetAppIDByName fails. The application -** will not be restarted at this point. -** -** The \c 's' field identifies the name of the Application which was attempted to be -** restarted and the \c RC field identifies the error code, in hex, that will identify -** the precise reason for the failure. -**/ -#define CFE_ES_RESTART_APP_ERR2_EID 39 - -/* -** "Restart Application \%s Failed: AppCreate Error 0x\%08X." -*/ - -/** \brief 'Restart Application \%s Failed: AppCreate Error 0x\%08X.' -** \event 'Restart Application \%s Failed: AppCreate Error 0x\%08X.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of an Executive Services -** \link #CFE_ES_RESTART_APP_CC Restart Application Command \endlink which fails. This message -** is for a specific failure when the call to CFE_ES_AppCreate fails. The application -** will not be restarted at this point. -** -** The \c 's' field identifies the name of the Application which was attempted to be -** restarted and the \c RC field identifies the error code, in hex, that will identify -** the precise reason for the failure. -**/ -#define CFE_ES_RESTART_APP_ERR3_EID 40 - - -/** \brief 'Restart Application \%s Failed: CleanUpApp Error 0x\%08X.' -** \event 'Restart Application \%s Failed: CleanUpApp Error 0x\%08X.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of an Executive Services -** \link #CFE_ES_RESTART_APP_CC Restart Application Command \endlink which fails. This message -** is for a specific failure when the call to CFE_ES_CleanUpApp fails. The application -** will not be restarted at this point, but will likely be deleted or in an unknown state. -** -** The \c 's' field identifies the name of the Application which was attempted to be -** restarted and the \c RC field identifies the error code, in hex, that will identify -** the precise reason for the failure. -**/ -#define CFE_ES_RESTART_APP_ERR4_EID 41 - - -/** \brief 'Failed to reload Application \%s, rc = \%08X' -** \event 'Failed to reload Application \%s, rc = \%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services \link #CFE_ES_RELOAD_APP_CC Reload Application -** Command \endlink fails. -** -** The \c 's' field identifies the name of the Application which was attempted to be -** reloaded and the \c rc field identifies the error code, in hex, that may identify -** the precise reason for the failure. -**/ -#define CFE_ES_RELOAD_APP_ERR1_EID 42 - -/** \brief 'Reload Application \%s, GetAppIDByName failed. RC = 0x\%08X.' -** \event 'Reload Application \%s, GetAppIDByName failed. RC = 0x\%08X.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of an Executive Services -** \link #CFE_ES_RELOAD_APP_CC Reload Application Command \endlink which fails. This message -** is for a specific failure when the call to CFE_ES_GetAppIDByName fails. The application -** will not be reloaded at this point. -** -** The \c 's' field identifies the name of the Application which was attempted to be -** reloaded and the \c RC field identifies the error code, in hex, that will identify -** the precise reason for the failure. -**/ -#define CFE_ES_RELOAD_APP_ERR2_EID 43 - - -/** \brief 'Reload Application \%s Failed: AppCreate Error 0x\%08X.' -** \event 'Reload Application \%s Failed: AppCreate Error 0x\%08X.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of an Executive Services -** \link #CFE_ES_RELOAD_APP_CC Reload Application Command \endlink which fails. This message -** is for a specific failure when the call to CFE_ES_AppCreate fails. The application -** will not be reloaded at this point. -** -** The \c 's' field identifies the name of the Application which was attempted to be -** reloaded and the \c RC field identifies the error code, in hex, that will identify -** the precise reason for the failure. -**/ -#define CFE_ES_RELOAD_APP_ERR3_EID 44 - - -/** \brief 'Reload Application \%s Failed: CleanUpApp Error 0x\%08X.' -** \event 'Reload Application \%s Failed: CleanUpApp Error 0x\%08X.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of an Executive Services -** \link #CFE_ES_RELOAD_APP_CC Reload Application Command \endlink which fails. This message -** is for a specific failure when the call to CFE_ES_CleanUpApp fails. The application -** will not be reloaded at this point, and will likely be deleted or in an unknown state. -** -** The \c 's' field identifies the name of the Application which was attempted to be -** reloaded and the \c RC field identifies the error code, in hex, that will identify -** the precise reason for the failure. -**/ -#define CFE_ES_RELOAD_APP_ERR4_EID 45 - - -/** \brief 'Exit Application \%s Failed: CleanUpApp Error 0x\%08X.' -** \event 'Exit Application \%s Failed: CleanUpApp Error 0x\%08X.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when ES is completing the processing of the -** CFE_ES_ExitApp API call and the call to CFE_ES_CleanUpApp fails. At this point the Application will -** likely be stopped or deleted, but it may be in an unknown state. -** -** The \c 's' field identifies the name of the Application which was attempted to be -** reloaded and the \c RC field identifies the error code, in hex, that will identify -** the precise reason for the failure. -**/ -#define CFE_ES_EXIT_APP_ERR_EID 46 - - -/** \brief 'ES_ProcControlReq: Invalid State (EXCEPTION) Application \%s.' -** \event 'ES_ProcControlReq: Invalid State (EXCEPTION) Application \%s.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when ES is processing it's internal Application table and encounters -** an App with the EXCEPTION state. Because exceptions are supposed to be processed immediately, this is -** an invalid state and should not happen. It may indicate some sort of memory corruption or other problem. -**/ -#define CFE_ES_PCR_ERR1_EID 47 - - -/* -** "CFE_ES_CleanUpApp: Unknown State ( \%d ) Application \%s." -*/ -/** \brief 'ES_ProcControlReq: Unknown State ( \%d ) Application \%s.' -** \event 'ES_ProcControlReq: Unknown State ( \%d ) Application \%s.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when ES is processing it's internal Application table and encounters -** an App with an unknown state. If this message occurs, it might be an indication of a memory corruption -** or other problem. -**/ -#define CFE_ES_PCR_ERR2_EID 48 - -/** \brief 'Failed to send \%s application data, RC = \%08X' -** \event 'Failed to send \%s application data, RC = \%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services \link #CFE_ES_QUERY_ONE_CC Request Application -** Data Command \endlink failed. -** -** The \c 's' field identifies the name of the Application whose data was attempted -** to be telemetered and the \c rc field identifies the error code, in hex, that may identify -** the precise reason for the failure. -**/ -#define CFE_ES_ONE_ERR_EID 49 - -/** \brief 'Failed to send \%s application data: GetAppIDByName Failed, RC = 0x\%08X' -** \event 'Failed to send \%s application data: GetAppIDByName Failed, RC = 0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services \link #CFE_ES_QUERY_ONE_CC Request Application -** Data Command \endlink failed. -** -** The \c 's' field identifies the name of the Application whose data was attempted -** to be telemetered and the \c rc field identifies the error code, in hex, that may identify -** the precise reason for the failure. -**/ -#define CFE_ES_ONE_APPID_ERR_EID 50 - - -/** \brief 'Failed to write App Info file, OS_creat returned \%d' -** \event 'Failed to write App Info file, OS_creat returned \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services \link #CFE_ES_QUERY_ALL_CC Dump Application -** Data Command \endlink fails to create the dump file. -** -** The \c 'd' parameter identifies, in decimal, the error code returned by #OS_creat when the attempt was made -** to create the file. -**/ -#define CFE_ES_OSCREATE_ERR_EID 51 - -/** \brief 'Failed to write App Info file, WriteHdr rtnd \%08X, exp \%d' -** \event 'Failed to write App Info file, WriteHdr rtnd \%08X, exp \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services \link #CFE_ES_QUERY_ALL_CC Dump Application -** Data Command \endlink fails while writing the cFE Standard File Header. -** -** The \c rtnd field contains the error code returned by the #CFE_FS_WriteHeader API. Nominally, the -** returned result should have been equal to the \c exp field (i.e. - sizeof(#CFE_FS_Header_t)). -**/ -#define CFE_ES_WRHDR_ERR_EID 52 - - -/** \brief 'Failed to write App Info file, Task write RC = 0x\%08X, exp \%d' -** \event 'Failed to write App Info file, Task write RC = 0x\%08X, exp \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever an Executive Services \link #CFE_ES_QUERY_ALL_CC Dump Application -** Data Command \endlink fails while writing Application data to the specified file. -** -** The \c rtnd field contains, in hex, the error code returned from the #OS_write API. The expected return -** value is identified, in decimal, in the \c exp field. -**/ -#define CFE_ES_TASKWR_ERR_EID 53 - -/** \brief 'Error creating file \%s, stat=0x\%x' -** \event 'Error creating file \%s, stat=0x\%x' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services \link #CFE_ES_WRITE_SYSLOG_CC Dump System Log -** Command \endlink fails while attempting to create the specified file. -** -** The \c 's' field identifies the name of the file that was attempted to be created and the \c stat field -** specifies, in hex, the error code returned by the #OS_creat API. -**/ -#define CFE_ES_SYSLOG2_ERR_EID 55 - -/** \brief 'Error creating file \%s, stat=0x\%x' -** \event 'Error creating file \%s, stat=0x\%x' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services \link #CFE_ES_WRITE_ERLOG_CC Dump Exception Reset Log -** Command \endlink fails while attempting to create the specified file. -** -** The \c 's' field identifies the name of the file that was attempted to be created and the \c stat field -** specifies, in hex, the error code returned by the #OS_creat API. -**/ -#define CFE_ES_ERLOG2_ERR_EID 56 - -/** \brief 'Start collecting performance data command, trigger mode = %d' -** \event 'Start collecting performance data command, trigger mode = %d' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated in response to receiving an Executive Services -** \link #CFE_ES_PERF_STARTDATA_CC Start Performance Analyzer Data Collection Command \endlink -** -** The \c 'd' field identifies the requested trigger mode. Valid values are #CFE_ES_PerfMode_t CFE_ES_PERF_TRIGGER_START (0), -** #CFE_ES_PerfMode_t CFE_ES_PERF_TRIGGER_CENTER (1), and #CFE_ES_PerfMode_t CFE_ES_PERF_TRIGGER_END (2) -**/ -#define CFE_ES_PERF_STARTCMD_EID 57 - -/** \brief 'Cannot start collecting performance data,perf data write in progress' -** \event 'Cannot start collecting performance data,perf data write in progress' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated in response to receiving an Executive Services -** \link #CFE_ES_PERF_STARTDATA_CC Start Performance Analyzer Data Collection Command \endlink -**/ -#define CFE_ES_PERF_STARTCMD_ERR_EID 58 - - -/** \brief 'Cannot start collecting performance data, trigger mode (%d) out of range (%d to %d)' -** \event 'Cannot start collecting performance data, trigger mode (%d) out of range (%d to %d)' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services \link #CFE_ES_PERF_STARTDATA_CC -** Start Performance Analyzer Data Collection Command \endlink command is received with a bad -** value for the requested trigger mode. -** -** The first \c 'd' field identifies the received trigger mode value. -** The second and third \c 'd' fields specify the valid range of values for the trigger mode. Valid values -** are #CFE_ES_PerfMode_t CFE_ES_PERF_TRIGGER_START (0), #CFE_ES_PerfMode_t CFE_ES_PERF_TRIGGER_CENTER (1), and -** #CFE_ES_PerfMode_t CFE_ES_PERF_TRIGGER_END (2). -**/ -#define CFE_ES_PERF_STARTCMD_TRIG_ERR_EID 59 - - -/** \brief 'Perf Stop Cmd Rcvd,\%s will write \%d entries.\%dmS dly every \%d entries' -** \event 'Perf Stop Cmd Rcvd,\%s will write \%d entries.\%dmS dly every \%d entries' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon receipt of a successful Performance Data Stop -** Command after receiving the cFE Executive Services \link #CFE_ES_PERF_STOPDATA_CC Stop -** Performance Analyzer Data Collection Command \endlink -** -** The \c 's' field identifies the name of the file write task that has begun execution. -** The first \c 'd' identifies the total number of performance entries(in decimal) that will be written to the file. -** A performance data entry is defined by an unsigned 32 bit data point and an unsigned 64 bit time stamp. -** The second \c 'd' identifies the millisecond delay between writes and the -** third \c 'd' identifies the number of entries written (in decimal) between delays. -**/ -#define CFE_ES_PERF_STOPCMD_EID 60 - - -/** \brief 'Stop performance data cmd,Error creating child task RC=0x\%08X' -** \event 'Stop performance data cmd,Error creating child task RC=0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of an unsuccessful Performance Data Stop -** Command after receiving the cFE Executive Services \link #CFE_ES_PERF_STOPDATA_CC Stop -** Performance Analyzer Data Collection Command \endlink -** -** The \c 'RC' field specifies, in hex, the error code returned by the #CFE_ES_CreateChildTask API -** -**/ -#define CFE_ES_PERF_STOPCMD_ERR1_EID 61 - - -/** \brief 'Stop performance data cmd ignored,perf data write in progress' -** \event 'Stop performance data cmd ignored,perf data write in progress' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of an unsuccessful Performance Data Stop -** Command after receiving the cFE Executive Services \link #CFE_ES_PERF_STOPDATA_CC Stop -** Performance Analyzer Data Collection Command \endlink -** -**/ -#define CFE_ES_PERF_STOPCMD_ERR2_EID 62 - - -/** \brief 'Set Performance Filter Mask command' -** \event 'Set Performance Filter Mask command' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated in response to receiving an Executive Services -** \link #CFE_ES_PERF_SETFILTERMASK_CC Set Performance Analyzer Filter Mask Command \endlink. -** -**/ -#define CFE_ES_PERF_FILTMSKCMD_EID 63 - -/** \brief 'Error:Performance Filter Mask Index value -** greater than CFE_ES_PERF_32BIT_WORDS_IN_MASK (which is a whole number derived from -** CFE_ES_PERF_MAX_IDS / 32)' -** \event 'Error:Performance Filter Mask Index value -** greater than CFE_ES_PERF_32BIT_WORDS_IN_MASK (which is a whole number derived from -** CFE_ES_PERF_MAX_IDS / 32)' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated in response to receiving an Executive Services -** \link #CFE_ES_PERF_SETFILTERMASK_CC Set Performance Analyzer Filter Mask Command \endlink. -** -**/ -#define CFE_ES_PERF_FILTMSKERR_EID 64 - - -/** \brief 'Set Performance Trigger Mask command' -** \event 'Set Performance Trigger Mask command' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated in response to receiving an Executive Services -** \link #CFE_ES_PERF_SETTRIGMASK_CC Set Performance Analyzer Trigger Mask Command \endlink. -** -**/ -#define CFE_ES_PERF_TRIGMSKCMD_EID 65 - -/** \brief 'Error: Performance Trigger Mask Index value -** greater than CFE_ES_PERF_32BIT_WORDS_IN_MASK (which is a whole number derived from -** CFE_ES_PERF_MAX_IDS / 32)' -** \event 'Error: Performance Trigger Mask Index value -** greater than CFE_ES_PERF_32BIT_WORDS_IN_MASK (which is a whole number derived from -** CFE_ES_PERF_MAX_IDS / 32)' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated in response to receiving an Executive Services -** \link #CFE_ES_PERF_SETTRIGMASK_CC Set Performance Analyzer Trigger Mask Command \endlink. -** -**/ -#define CFE_ES_PERF_TRIGMSKERR_EID 66 - - -/** \brief 'Error creating file \%s, stat=\%d' -** \event 'Error creating file \%s, stat=\%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services -** \link #CFE_ES_PERF_STOPDATA_CC Stop Performance Analyzer Data Collection Command \endlink -** fails to create the associated logic analyzer dump file. -** -** The \c 's' field identifies the name of the file that was attempted to be created and the \c stat field -** specifies, in decimal, the error code returned by the #OS_creat API. -**/ -#define CFE_ES_PERF_LOG_ERR_EID 67 - - -/** \brief '\%s written:Size=\%d,EntryCount=\%d' -** \event '\%s written:Size=\%d,EntryCount=\%d' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated when the Performance Log has been successfully written -** to a file after receiving the cFE Executive Services \link #CFE_ES_PERF_STOPDATA_CC Stop -** Performance Analyzer Data Collection Command \endlink -** -** The \c 's' field identifies the name of the file written to, the \c Size field specifies, in decimal, -** the number of bytes written to the file and the \c EntryCount field identifies the number of data -** entries that were written. -**/ -#define CFE_ES_PERF_DATAWRITTEN_EID 68 - -/** \brief '\%s Failed to Register CDS '\%s', Status=0x\%08X' -** \event '\%s Failed to Register CDS '\%s', Status=0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever an Application calls the #CFE_ES_RegisterCDS API and -** fails to successfully create the desired CDS. -** -** The first \c 's' field identifies the name of the Application which made the API call, the second -** \c 's' field specifies the name of the CDS as requested by the Application and the \c Status field -** provides the error code which identifies in more detail the nature of the failure (See return codes -** for the #CFE_ES_RegisterCDS API). -**/ -#define CFE_ES_CDS_REGISTER_ERR_EID 69 - -/** \brief 'Set OverWriteSysLog Command Received with Mode setting = \%d' -** \event 'Set OverWriteSysLog Command Received with Mode setting = \%d' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon successful completion of an Executive Services \link #CFE_ES_OVERWRITE_SYSLOG_CC -** Set System Log Overwrite Mode Command \endlink. -** -** The \c setting field identifies the newly chosen Overwrite Mode and should be equal to either -** #CFE_ES_LOG_OVERWRITE or #CFE_ES_LOG_DISCARD. -**/ -#define CFE_ES_SYSLOGMODE_EID 70 - -/** \brief 'Set OverWriteSysLog Command: Invalid Mode setting = \%d' -** \event 'Set OverWriteSysLog Command: Invalid Mode setting = \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon unsuccessful completion of an Executive Services \link #CFE_ES_OVERWRITE_SYSLOG_CC -** Set System Log Overwrite Mode Command \endlink. -** -** The \c setting field identifies the illegal Overwrite Mode found in the command message. The mode -** must be either #CFE_ES_LOG_OVERWRITE (0) or #CFE_ES_LOG_DISCARD (1). -**/ -#define CFE_ES_ERR_SYSLOGMODE_EID 71 - -/** \brief 'Reset Processor Reset Count to Zero' -** \event 'Reset Processor Reset Count to Zero' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always generated in response to the Executive Services -** \link #CFE_ES_RESET_PR_COUNT_CC Set Processor Reset Counter to Zero Command \endlink. -**/ -#define CFE_ES_RESET_PR_COUNT_EID 72 - -/** \brief 'Maximum Processor Reset Count set to: \%d' -** \event 'Maximum Processor Reset Count set to: \%d' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always generated in response to the Executive Services -** \link #CFE_ES_RESET_PR_COUNT_CC Set Maximum Processor Reset Limit Command \endlink. -** -** The \c 'd' field identifies, in decimal, the number of Processor Resets that will need -** to occur before a Power-On Reset is automatically performed. -**/ -#define CFE_ES_SET_MAX_PR_COUNT_EID 73 - -/** \brief 'File write,byte cnt err,file \%s,request=\%d,actual=\%d' -** \event 'File write,byte cnt err,file \%s,request=\%d,actual=\%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated in response to any command requesting information to be written -** to a file and whose data is not completely written to the specified file. -** -** The \c file field identifies the filename of the file to which the data failed to write completely, -** the \c request field specifies, in decimal, the number of bytes that were attempted to be written and -** the \c actual field indicates, in decimal, the actual number of bytes written to the file. -**/ -#define CFE_ES_FILEWRITE_ERR_EID 74 - -/** \brief 'Error accessing ER Log,\%s not written.Stat=0x\%08x' -** \event 'Error accessing ER Log,\%s not written.Stat=0x\%08x' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated in response to an Exception Reset Log Dump command and there is -** an error obtaining the contents of the ER Log. -** -** The \c 's' field identifies the filename of the file to which the data failed to write, -** the \c Stat field specifies, in hex, the error status returned from #CFE_PSP_GetResetArea. -**/ -#define CFE_ES_RST_ACCESS_EID 75 - -/** \brief 'Error while deleting '\%s' from CDS, See SysLog.(Err=0x\%08X)' -** \event 'Error while deleting '\%s' from CDS, See SysLog.(Err=0x\%08X)' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services -** \link #CFE_ES_DELETE_CDS_CC Delete CDS Command \endlink -** fails to cleanly remove the specified CDS. -** -** The \c 's' field identifies the name of the CDS that was attempted to be deleted the \c Err field -** specifies, in hex, the error code. -**/ -#define CFE_ES_CDS_DELETE_ERR_EID 76 - -/** \brief 'Unable to locate '\%s' in CDS Registry' -** \event 'Unable to locate '\%s' in CDS Registry' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services -** \link #CFE_ES_DELETE_CDS_CC Delete CDS Command \endlink -** specifies a name for a CDS that cannot be found in the CDS Registry. -** -** The \c 's' field identifies the name of the CDS that was attempted to be deleted. -**/ -#define CFE_ES_CDS_NAME_ERR_EID 77 - -/** \brief 'Successfully removed '\%s' from CDS' -** \event 'Successfully removed '\%s' from CDS' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated when an Executive Services -** \link #CFE_ES_DELETE_CDS_CC Delete CDS Command \endlink -** is successfully completed. -** -** The \c 's' field identifies the name of the CDS that was deleted. -**/ -#define CFE_ES_CDS_DELETED_INFO_EID 78 - -/** \brief 'CDS '\%s' is a Critical Table CDS. Must be deleted via TBL Command' -** \event 'CDS '\%s' is a Critical Table CDS. Must be deleted via TBL Command' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services -** \link #CFE_ES_DELETE_CDS_CC Delete CDS Command \endlink -** specifies a name for a CDS that is a Critical Table image. -** Critical Table images can only be deleted via a Table Services -** command (#CFE_TBL_DELETE_CDS_CC). -** -** The \c 's' field identifies the name of the CDS that was attempted to be deleted. -**/ -#define CFE_ES_CDS_DELETE_TBL_ERR_EID 79 - -/** \brief 'CDS '\%s' not deleted because owning app is active' -** \event 'CDS '\%s' not deleted because owning app is active' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services -** \link #CFE_ES_DELETE_CDS_CC Delete CDS Command \endlink -** specifies a name for a CDS whose prefix name identifies -** an application that is still registered in the system. -** CDSs can only be deleted when their owning applications -** have been removed from the system. -** -** The \c 's' field identifies the name of the CDS that was attempted to be deleted. -**/ -#define CFE_ES_CDS_OWNER_ACTIVE_EID 80 - -/** \brief 'Successfully telemetered memory pool stats for 0x\%08X' -** \event 'Successfully telemetered memory pool stats for 0x\%08X' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated following successful execution of the -** \link #CFE_ES_TLM_POOL_STATS_CC Telemeter Memory Statistics Command \endlink. -**/ -#define CFE_ES_TLM_POOL_STATS_INFO_EID 81 - -/** \brief 'Cannot telemeter memory pool stats. Illegal Handle (0x\%08X)' -** \event 'Cannot telemeter memory pool stats. Illegal Handle (0x\%08X)' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services -** \link #CFE_ES_TLM_POOL_STATS_CC Telemeter Memory Statistics Command \endlink -** specifies a memory pool handle that is invalid. A handle is determined to -** be invalid when any of the following are true: -** -# The handle does not contain a value that is an integral multiple of 4 -** -# The handle does not specify a valid area of memory -** -# The handle does not point to an area of memory that contains the handle itself -** -# The handle does not point to an area of memory whose Size field is an integral multiple of 4 -** -# The handle does not point to an area of memory whose End field is equal to the Start plus the Size -** -** The \c '08X' field identifies the handle that was found in the command. -**/ -#define CFE_ES_INVALID_POOL_HANDLE_ERR_EID 82 - -/** \brief 'Successfully dumped CDS Registry to '\%s':Size=\%d,Entries=\%d' -** \event 'Successfully dumped CDS Registry to '\%s':Size=\%d,Entries=\%d' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated when an Executive Services -** \link #CFE_ES_DUMP_CDS_REG_CC Dump Critical Data Store Registry Command \endlink -** is successfully executed. The specified file should have been created -** and contains the CDS Registry Entries. -** -** The \c 's' field identifies the CDS Registry Dump Filename. -** The first \c 'd' field specifies the size of the file (in bytes) -** The second \c 'd' field specifies the number of CDS Registry Records that were written -**/ -#define CFE_ES_CDS_REG_DUMP_INF_EID 83 - -/** \brief 'Error writing CDS Registry to '\%s', Status=0x\%08X' -** \event 'Error writing CDS Registry to '\%s', Status=0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services -** \link #CFE_ES_DUMP_CDS_REG_CC Dump Critical Data Store Registry Command \endlink -** was being performed and it encountered a filesystem write error while writing -** a CDS Registry record. -** -** The \c 's' field identifies the CDS Registry Dump Filename. -** The \c '08X' field identifies the error code returned from #OS_write that caused the command to abort. -**/ -#define CFE_ES_CDS_DUMP_ERR_EID 84 - -/** \brief 'Error writing cFE File Header to '\%s', Status=0x\%08X' -** \event 'Error writing cFE File Header to '\%s', Status=0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services -** \link #CFE_ES_DUMP_CDS_REG_CC Dump Critical Data Store Registry Command \endlink -** command successfully created the CDS Dump File onboard but encountered an error -** while writing the standard cFE File Header to the file. -** -** The \c 's' field identifies the CDS Registry Dump Filename. -** The \c '08X' field identifies error code returned by the API #CFE_FS_WriteHeader. -**/ -#define CFE_ES_WRITE_CFE_HDR_ERR_EID 85 - -/** \brief 'Error creating CDS dump file '\%s', Status=0x\%08X' -** \event 'Error creating CDS dump file '\%s', Status=0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services -** \link #CFE_ES_DUMP_CDS_REG_CC Dump Critical Data Store Registry Command \endlink -** is unable to create the specified file on the onboard filesystem. -** -** The \c 's' field identifies the CDS Registry Dump Filename. -** The \c '08X' field identifies error code returned by the API #OS_creat. -**/ -#define CFE_ES_CREATING_CDS_DUMP_ERR_EID 86 - - -/** \brief 'Task Info file written to \%s, Entries=\%d, FileSize=\%d' -** \event 'Task Info file written to \%s, Entries=\%d, FileSize=\%d' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is issued upon successful completion of the cFE Executive -** Services \link #CFE_ES_QUERY_ALL_TASKS_CC Query All Tasks command \endlink -** -** The \c 's' field identifies the name of the file to which all Executive Services Task -** data has been written. The \c Entries field identifies, in decimal, the number of Tasks -** whose data was written and the \c FileSize field gives the total number of bytes written to the -** file. -**/ -#define CFE_ES_TASKINFO_EID 87 - - -/** \brief 'Failed to write Task Info file, OS_creat returned \%d' -** \event 'Failed to write Task Info file, OS_creat returned \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services \link #CFE_ES_QUERY_ALL_TASKS_CC Dump Task -** Data Command \endlink fails to create the dump file. -** -** The \c 'd' parameter identifies, in decimal, the error code returned by #OS_creat when the attempt was made -** to create the file. -**/ -#define CFE_ES_TASKINFO_OSCREATE_ERR_EID 88 - -/** \brief 'Failed to write Task Info file, WriteHdr rtnd \%08X, exp \%d' -** \event 'Failed to write Task Info file, WriteHdr rtnd \%08X, exp \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Executive Services \link #CFE_ES_QUERY_ALL_TASKS_CC Dump Task -** Data Command \endlink fails while writing the cFE Standard File Header. -** -** The \c rtnd field contains the error code returned by the #CFE_FS_WriteHeader API. Nominally, the -** returned result should have been equal to the \c exp field (i.e. - sizeof(#CFE_FS_Header_t)). -**/ -#define CFE_ES_TASKINFO_WRHDR_ERR_EID 89 - - -/** \brief 'Failed to write Task Info file, Task write RC = 0x\%08X, exp \%d' -** \event 'Failed to write Task Info file, Task write RC = 0x\%08X, exp \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever an Executive Services \link #CFE_ES_QUERY_ALL_TASKS_CC Dump Tasks -** Data Command \endlink fails while writing Tasks data to the specified file. -** -** The \c rtnd field contains, in hex, the error code returned from the #OS_write API. The expected return -** value is identified, in decimal, in the \c exp field. -**/ -#define CFE_ES_TASKINFO_WR_ERR_EID 90 - - -/** \brief 'Mission %s.%s, %s, %s' -** \event 'Mission %s.%s, %s, %s' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always automatically issued when the Executive Services -** Task completes its Initialization -** -** The \c Mission field identifies the tagged build identifiers and configuration name. -** If available, this will also indicate the revision control identifiers for CFE and OSAL -** that this binary was built with. -**/ -#define CFE_ES_VERSION_INF_EID 91 - -/** \brief 'Build %s %s' -** \event 'Build %s %s' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always automatically issued when the Executive Services -** Task completes its Initialization, and as part of the Noop command. -** -** The \c Build field identifies the build date, time, hostname and user identifier of -** the build host machine for the current running binary. The first string is the -** build date/time, and the second string is formatted as "user@hostname" -** -** By default, if not specified/overridden, the default values of these variables will be: -** BUILDDATE ==> the output of "date +%Y%m%d%H%M" -** HOSTNAME ==> the output of "hostname" -** USER ==> the output of "whoami" -** -** The values can be overridden by setting an environment variable with the names above -** to the value desired for the field when running "make". -**/ -#define CFE_ES_BUILD_INF_EID 92 - - - -#endif /* _cfe_es_events_ */ - -/************************/ -/* End of File Comment */ -/************************/ diff --git a/src/components/interface/cFE/cfe_es_msg.h b/src/components/interface/cFE/cfe_es_msg.h deleted file mode 100644 index 5f912a0cde..0000000000 --- a/src/components/interface/cFE/cfe_es_msg.h +++ /dev/null @@ -1,1666 +0,0 @@ -/* -** File: -** cfe_es_msg.h -** $Id: cfe_es_msg.h 1.13 2014/08/19 13:30:55GMT-05:00 sstrege Exp $ -** -** Copyright (c) 2004-2012, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** -** Purpose: -** cFE Executive Services (ES) Command and Telemetry packet definition file. -** -** References: -** Flight Software Branch C Coding Standard Version 1.0a -** cFE Flight Software Application Developers Guide -** -** Notes: -** -** -** $Log: cfe_es_msg.h $ -** Revision 1.13 2014/08/19 13:30:55GMT-05:00 sstrege -** Fixed doxygen warning - updated reference to OS_MAX_PRIORITY to MAX_PRIORITY -** Revision 1.12 2012/01/18 16:28:56EST jmdagost -** Replaced Padding HK telemetry points with OSAL revision and mission revision. -** Revision 1.11 2012/01/13 12:32:14EST acudmore -** Changed license text to reflect open source -** Revision 1.10 2012/01/10 13:35:13EST lwalling -** Add output filename to shell command packet structure -** Revision 1.9 2011/01/18 13:42:37EST lwalling -** Fix incorrect structure name in Doxygen comment -** Revision 1.8 2010/11/24 09:18:25EST jmdagost -** Removed unneeded padding byte from housekeeping packet. -** Revision 1.7 2010/11/23 15:29:23EST jmdagost -** Added cFE Mission Revision telemetry point in Housekeeping, changed cFE SubMinor Version to cFE Revision. -** Revision 1.6 2010/11/04 17:16:01EDT jmdagost -** Added TriggerMode parameter to Performance Analyzer Start cmd, updated documentation. -** Revision 1.5 2010/11/04 14:20:20EDT acudmore -** Changed comments to reflect RAM disk path configuration option. -** Revision 1.4 2009/08/04 13:34:17EDT aschoeni -** Added heap information to ES telemetry -** Revision 1.3 2008/12/08 12:06:54EST dkobe -** Updates to correct doxygen errors -** Revision 1.2 2008/06/20 15:40:28EDT apcudmore -** Added support for OSAL based module loader -** - Removed calls and references to the BSP based module loader -** Revision 1.1 2008/04/17 08:05:20EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.16 2007/09/27 15:54:57EDT David Kobe (dlkobe) -** Added doxygen comments for commands and telemetry -** Revision 1.15 2007/09/25 14:38:53EDT David Kobe (dlkobe) -** Added Criticality note to Memory Pool Stats command description. -** Revision 1.14 2007/09/20 10:52:57EDT apcudmore -** Added Query All Tasks command, file definition, events, error codes etc. -** Revision 1.13 2007/06/07 16:03:55EDT dlkobe -** Corrected doxygen comment syntax errors -** Revision 1.12 2007/06/07 13:07:48EDT dlkobe -** Added Command and Telemetry doxygen comments to TIME, EVS and SB -** Revision 1.11 2007/06/02 10:10:13EDT dlkobe -** Added doxygen comments for User's Guides -** Revision 1.10 2007/05/09 12:41:44EDT dlkobe -** Added command structure for Dump CDS Registry Command -** Revision 1.8 2007/05/04 20:07:52EDT dlkobe -** Added command to telemeter memory pool statistics -** Revision 1.7 2007/04/25 11:57:04EDT apcudmore -** Implemented "Back End" of Application Restart and Delete. -** Changes include all ES Cleanup code to delete App and Task Resources. -** Revision 1.6 2007/04/20 14:22:42EDT rjmcgraw -** Renamed performance structs for consistency -** -*/ -/*************************************************************************/ -#ifndef _cfe_es_msg_ -#define _cfe_es_msg_ - -/* -** Includes -*/ -#include "cfe.h" -#include "cfe_es.h" - -/* -** ES task command packet command codes -*/ -/** \name Executive Services Command Codes */ -/** \{ */ -/** \cfeescmd Executive Services No-Op -** -** \par Description -** This command performs no other function than to increment the -** command execution counter. The command may be used to verify -** general aliveness of the Executive Services task. -** -** \cfecmdmnemonic \ES_NOOP -** -** \par Command Structure -** #CFE_ES_NoArgsCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_NOOP_INF_EID informational event message will -** be generated -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - the #CFE_ES_LEN_ERR_EID error event message will be generated -** -** \par Criticality -** None -** -** \sa -*/ -#define CFE_ES_NOOP_CC 0 - -/** \cfeescmd Executive Services Reset Counters -** -** \par Description -** This command resets the following counters within the Executive -** Services housekeeping telemetry: -** - Command Execution Counter -** - Command Error Counter -** -** \cfecmdmnemonic \ES_RESETCTRS -** -** \par Command Structure -** #CFE_ES_NoArgsCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_RESET_INF_EID informational event message will be -** generated -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - the #CFE_ES_LEN_ERR_EID error event message will be generated -** -** \par Criticality -** This command is not inherently dangerous. However, it is -** possible for ground systems and on-board safing procedures -** to be designed such that they react to changes in the counter -** values that are reset by this command. -** -** \sa #CFE_ES_RESET_PR_COUNT_CC -*/ -#define CFE_ES_RESET_CC 1 - -/** \cfeescmd Executive Services Processor / Power-On Reset -** -** \par Description -** This command restarts the cFE in one of two modes. The Power-On Reset -** will cause the cFE to restart as though the power were first applied -** to the processor. The Processor Reset will attempt to retain the contents -** of the volatile disk and the contents of the Critical Data Store. -** NOTE: If a requested Processor Reset should cause the -** Processor Reset Counter (\b \c \ES_PROCRESETCNT) -** to exceed OR EQUAL the limit #CFE_ES_MAX_PROCESSOR_RESETS (which is reported in -** housekeeping telemetry as \b \c \ES_MAXPROCRESETS), -** the command is \b AUTOMATICALLY upgraded to a Power-On Reset. -** -** \cfecmdmnemonic \ES_RESET -** -** \par Command Structure -** #CFE_ES_RestartCmd_t -** -** \par Command Verification -** Successful execution of this command (as a Processor Reset) -** may be verified with the following telemetry: -** - \b \c \ES_PROCRESETCNT - processor reset counter will increment -** - New entries in the Exception Reset Log and System Log can be found
-** NOTE: Verification of a Power-On Reset is shown through the loss of -** data nominally retained through a Processor Reset
-** NOTE: Since the reset of the processor resets the command execution -** counter (\b \c \ES_CMDPC), this counter \b CANNOT be used to verify -** command execution. -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - The \link #CFE_ES_RestartCmd_t.RestartType Restart Type \endlink was -** not a recognized value. -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - the #CFE_ES_BOOT_ERR_EID error event message will be generated -** -** \par Criticality -** This command is, by definition, dangerous. Significant loss of -** data will occur. All processes and the cFE itself will be stopped -** and restarted. With the Power-On reset option, all data on the -** volatile disk and the contents of the Critical Data Store will be -** lost. -** -** \sa #CFE_ES_RESET_PR_COUNT_CC, #CFE_ES_SET_MAX_PR_COUNT_CC -*/ -#define CFE_ES_RESTART_CC 2 - -/** \cfeescmd Executive Services O/S Shell Command -** -** \par Description -** This command passes an ASCII string as a command line to the -** underlying realtime operating system shell. Any response to -** the command is both written to the shell command output file -** and sent as a series of shell command output telemetry packets. -** -** If the shell command output filename argument is empty, then -** #CFE_ES_DEFAULT_SHELL_FILENAME will be used as the filename. -** -** \cfecmdmnemonic \ES_SHELL -** -** \par Command Structure -** #CFE_ES_ShellCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_SHELL_INF_EID informational event message will be -** generated -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - Failure to create the shell command output file -** - The shell command started with ES_ but was not one of the -** recognized cFE shell commands -** - There was an error while performing a #OS_lseek on the shell command output file -** - There was an error while redirecting the shell command response to the -** shell command output file -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - the #CFE_ES_SHELL_ERR_EID error event message will be generated -** - Additional information on the error should be found in the System Log -** -** \par Criticality -** This command should be used with caution. Interfering with the -** operation of the underlying realtime operating system can cause -** significant problems. -** -** \sa -*/ -#define CFE_ES_SHELL_CMD_CC 3 - -/** \cfeescmd Load and Start an Application -** -** \par Description -** This command starts the specified application with the -** specified start address, stack size, etc options. -** -** \cfecmdmnemonic \ES_STARTAPP -** -** \par Command Structure -** #CFE_ES_StartAppCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_START_INF_EID informational event message will be -** generated -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - The specified application filename string is either a NULL string -** or less than four characters in length -** - The specified application entry point is a NULL string -** - The specified application name is a NULL string -** - The specified stack size is less than #CFE_ES_DEFAULT_STACK_SIZE -** - The specified priority is greater than MAX_PRIORITY (as defined in osapi.c) -** - The specified exception action is neither #CFE_ES_APP_EXCEPTION_RESTART_APP (0) or -** #CFE_ES_APP_EXCEPTION_PROC_RESTART (1) -** - The Operating System was unable to load the specified application file -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** This command is not inherently dangerous although system resources -** could be taxed beyond their limits with the starting of erroneous -** or invalid applications. -** -** \sa #CFE_ES_STOP_APP_CC, #CFE_ES_RESTART_APP_CC, #CFE_ES_RELOAD_APP_CC -*/ -#define CFE_ES_START_APP_CC 4 - -/** \cfeescmd Stop and Unload Application -** -** \par Description -** This command halts and removes the specified Application -** from the system. \b NOTE: This command should never be used -** on the Command Ingest application. This would prevent further -** commands from entering the system. If Command Ingest needs to -** be stopped and restarted, use #CFE_ES_RESTART_APP_CC or -** #CFE_ES_RELOAD_APP_CC. -** -** \cfecmdmnemonic \ES_STOPAPP -** -** \par Command Structure -** #CFE_ES_AppNameCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_STOP_DBG_EID debug event message will be -** generated. NOTE: This event message only identifies that the -** stop has been started, not that is has completed. -** - Once the stop has successfully completed, the list of Applications -** and Tasks created in response to the \b \c \ES_WRITEAPPINFO2FILE, -** \b \c \ES_WRITETASKINFO2FILE should no longer contain the -** specified application. -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - The specified application name is not recognized as an active application -** - The specified application is one of the cFE's Core applications (ES, EVS, SB, TBL, TIME) -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** - Additional information on the reason for command failure may be found -** in the System Log -** -** \par Criticality -** This command is not inherently dangerous, however the removal of certain -** applications (e.g. - Spacecraft Attitude and Control) may have a detrimental effect -** on the spacecraft. -** -** \sa #CFE_ES_START_APP_CC, #CFE_ES_RESTART_APP_CC, #CFE_ES_RELOAD_APP_CC -*/ -#define CFE_ES_STOP_APP_CC 5 - -/** \cfeescmd Stops and Restarts an Application -** -** \par Description -** This command halts and restarts the specified Application. -** This command does \b NOT reload the application from the onboard -** filesystem. -** -** \cfecmdmnemonic \ES_RESTARTAPP -** -** \par Command Structure -** #CFE_ES_AppNameCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_RESTART_APP_DBG_EID debug event message will be -** generated. NOTE: This event message only identifies that the -** act of stopping the application has begun, not that is has completed. -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - The specified application name is not recognized as an active application -** - The specified application is one of the cFE's Core applications (ES, EVS, SB, TBL, TIME) -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** - Additional information on the reason for command failure may be found -** in the System Log -** -** \par Criticality -** This command is not inherently dangerous, however the restarting of certain -** applications (e.g. - Spacecraft Attitude and Control) may have a detrimental effect -** on the spacecraft. -** -** \sa #CFE_ES_START_APP_CC, #CFE_ES_STOP_APP_CC, #CFE_ES_RELOAD_APP_CC -*/ -#define CFE_ES_RESTART_APP_CC 6 - -/** \cfeescmd Stops, Unloads, Loads from a File and Restarts an Application -** -** \par Description -** This command halts and removes the specified Application -** from the system. Then it immediately loads the Application from -** the command specified file and restarts it. This command is -** especially useful for restarting a Command Ingest Application -** since once it has been stopped, no further commands can come in -** to restart it. -** -** \cfecmdmnemonic \ES_RELOADAPP -** -** \par Command Structure -** #CFE_ES_AppReloadCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_RELOAD_APP_DBG_EID debug event message will be -** generated. NOTE: This event message only identifies that the -** act of stopping the application has begun, not that is has completed. -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - The specified application name is not recognized as an active application -** - The specified application is one of the cFE's Core applications (ES, EVS, SB, TBL, TIME) -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** - Additional information on the reason for command failure may be found -** in the System Log -** -** \par Criticality -** This command is not inherently dangerous, however the restarting of certain -** applications (e.g. - Spacecraft Attitude and Control) may have a detrimental effect -** on the spacecraft. -** -** \sa #CFE_ES_START_APP_CC, #CFE_ES_STOP_APP_CC, #CFE_ES_RESTART_APP_CC -*/ -#define CFE_ES_RELOAD_APP_CC 7 - -/** \cfeescmd Request Executive Services Information on a Specified Application -** -** \par Description -** This command takes the information kept by Executive Services on the -** specified application and telemeters it to the ground. -** -** \cfecmdmnemonic \ES_QUERYAPP -** -** \par Command Structure -** #CFE_ES_AppNameCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_ONE_APP_EID debug event message will be -** generated. NOTE: This event message only identifies that the -** act of stopping the application has begun, not that is has completed. -** - Receipt of the #CFE_ES_OneAppTlm_t telemetry packet -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - The specified application name is not recognized as an active application -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** None -** -** \sa #CFE_ES_QUERY_ALL_CC, #CFE_ES_QUERY_ALL_TASKS_CC -*/ -#define CFE_ES_QUERY_ONE_CC 8 - -/** \cfeescmd Writes all Executive Services Information on All Applications to a File -** -** \par Description -** This command takes the information kept by Executive Services on all of the -** registered applications and writes it to the specified file. -** -** \cfecmdmnemonic \ES_WRITEAPPINFO2FILE -** -** \par Command Structure -** #CFE_ES_QueryAllCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_ALL_APPS_EID debug event message will be -** generated. -** - The file specified in the command (or the default specified -** by the #CFE_ES_DEFAULT_APP_LOG_FILE configuration parameter) will be -** updated with the lastest information. -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - An Error occurs while trying to write to the file -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** This command is not inherently dangerous. It will create a new -** file in the file system (or overwrite an existing one) and could, -** if performed repeatedly without sufficient file management by the -** operator, fill the file system. -** -** \sa #CFE_ES_QUERY_ONE_CC, #CFE_ES_QUERY_ALL_TASKS_CC -*/ -#define CFE_ES_QUERY_ALL_CC 9 - -/** \cfeescmd Clear Executive Services System Log -** -** \par Description -** This command clears the contents of the Executive Services System Log. -** -** \cfecmdmnemonic \ES_CLEARSYSLOG -** -** \par Command Structure -** #CFE_ES_NoArgsCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_SYSLOG1_INF_EID informational event message will be -** generated. -** - \b \c \ES_SYSLOGBYTEUSED - System Log Bytes Used will go to zero -** - \b \c \ES_SYSLOGENTRIES - Number of System Log Entries will go to zero -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** This command is not dangerous. However, any previously logged data -** will be lost. -** -** \sa #CFE_ES_WRITE_SYSLOG_CC, #CFE_ES_CLEAR_ERLOG_CC, #CFE_ES_WRITE_ERLOG_CC, -** #CFE_ES_OVERWRITE_SYSLOG_CC -*/ -#define CFE_ES_CLEAR_SYSLOG_CC 10 - -/** \cfeescmd Writes contents of Executive Services System Log to a File -** -** \par Description -** This command causes the contents of the Executive Services System Log -** to be written to a log file. -** -** \cfecmdmnemonic \ES_WRITESYSLOG2FILE -** -** \par Command Structure -** #CFE_ES_WriteSyslogCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_SYSLOG2_EID debug event message will be -** generated. -** - The file specified in the command (or the default specified -** by the #CFE_ES_DEFAULT_SYSLOG_FILE configuration parameter) will be -** updated with the lastest information. -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - An Error occurs while trying to write to the file -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** This command is not inherently dangerous. It will create a new -** file in the file system (or overwrite an existing one) and could, -** if performed repeatedly without sufficient file management by the -** operator, fill the file system. -** -** \sa #CFE_ES_CLEAR_SYSLOG_CC, #CFE_ES_CLEAR_ERLOG_CC, #CFE_ES_WRITE_ERLOG_CC, -** #CFE_ES_OVERWRITE_SYSLOG_CC -*/ -#define CFE_ES_WRITE_SYSLOG_CC 11 - -/** \cfeescmd Clears the contents of the Exeception and Reset Log -** -** \par Description -** This command causes the contents of the Executive Services Exception -** and Reset Log to be cleared. -** -** \cfecmdmnemonic \ES_CLEARERLOG -** -** \par Command Structure -** #CFE_ES_NoArgsCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_ERLOG1_INF_EID informational event message will be -** generated. -** - \b \c \ES_ERLOGINDEX - Index into Exception Reset Log goes to zero -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** This command is not dangerous. However, any previously logged data -** will be lost. -** -** \sa #CFE_ES_CLEAR_SYSLOG_CC, #CFE_ES_WRITE_SYSLOG_CC, #CFE_ES_WRITE_ERLOG_CC -*/ -#define CFE_ES_CLEAR_ERLOG_CC 12 - -/** \cfeescmd Writes Exeception and Reset Log to a File -** -** \par Description -** This command causes the contents of the Executive Services Exception -** and Reset Log to be written to the specified file. -** -** \cfecmdmnemonic \ES_WRITEERLOG2FILE -** -** \par Command Structure -** #CFE_ES_WriteERlogCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_ERLOG2_EID debug event message will be -** generated. -** - The file specified in the command (or the default specified -** by the #CFE_ES_DEFAULT_ER_LOG_FILE configuration parameter) will be -** updated with the lastest information. -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - An Error occurs while trying to write to the file -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** This command is not inherently dangerous. It will create a new -** file in the file system (or overwrite an existing one) and could, -** if performed repeatedly without sufficient file management by the -** operator, fill the file system. -** -** \sa #CFE_ES_CLEAR_SYSLOG_CC, #CFE_ES_WRITE_SYSLOG_CC, #CFE_ES_CLEAR_ERLOG_CC -*/ -#define CFE_ES_WRITE_ERLOG_CC 13 - -/** \cfeescmd Start Performance Analyzer -** -** \par Description -** This command causes the Performance Analyzer to begin collecting data using the specified trigger mode. -** -** \cfecmdmnemonic \ES_STARTLADATA -** -** \par Command Structure -** #CFE_ES_PerfStartCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - \b \c \ES_PERFSTATE - Current performance analyzer state will change to -** either WAITING FOR TRIGGER or, if conditions are appropriate fast enough, -** TRIGGERED. -** - \b \c \ES_PERFMODE - Performance Analyzer Mode will change to the commanded trigger mode (TRIGGER START, -** TRIGGER CENTER, or TRIGGER END). -** - \b \c \ES_PERFTRIGCNT - Performance Trigger Count will go to zero -** - \b \c \ES_PERFDATASTART - Data Start Index will go to zero -** - \b \c \ES_PERFDATAEND - Data End Index will go to zero -** - \b \c \ES_PERFDATACNT - Performance Data Counter will go to zero -** - The #CFE_ES_PERF_STARTCMD_EID debug event message will be -** generated. -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - A previous #CFE_ES_PERF_STOPDATA_CC command has not completely finished. -** - An invalid trigger mode is requested. -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** This command is not inherently dangerous but may cause a small increase in CPU -** utilization as the performance analyzer data is collected. -** -** \sa #CFE_ES_PERF_STOPDATA_CC, #CFE_ES_PERF_SETFILTERMASK_CC, #CFE_ES_PERF_SETTRIGMASK_CC -*/ -#define CFE_ES_PERF_STARTDATA_CC 14 - -/** \cfeescmd Stop Performance Analyzer -** -** \par Description -** This command stops the Performance Analyzer from collecting any more data. -** -** \cfecmdmnemonic \ES_STOPLADATA -** -** \par Command Structure -** #CFE_ES_PerfStopCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - \b \c \ES_PERFSTATE - Current performance analyzer state will change to -** IDLE. -** - The #CFE_ES_PERF_STOPCMD_EID debug event message will be -** generated. -** - The file specified in the command (or the default specified -** by the #CFE_ES_DEFAULT_PERF_DUMP_FILENAME configuration parameter) will be -** updated with the lastest information. -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - A previous Stop Performance Analyzer command is still in process -** - An error occurred while spawning the child task responsible for -** dumping the Performance Analyzer data to a file -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** This command is not inherently dangerous. An additional low priority child -** task will be spawned, however, to dump the performance analyzer data to a file. -** -** \sa #CFE_ES_PERF_STARTDATA_CC, #CFE_ES_PERF_SETFILTERMASK_CC, #CFE_ES_PERF_SETTRIGMASK_CC -*/ -#define CFE_ES_PERF_STOPDATA_CC 15 - -/** \cfeescmd Set Performance Analyzer's Filter Masks -** -** \par Description -** This command sets the Performance Analyzer's Filter Masks. -** -** \cfecmdmnemonic \ES_LAFILTERMASK -** -** \par Command Structure -** #CFE_ES_PerfSetFilterMaskCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - \B \C \ES_PERFFLTRMASK - the current performance filter mask -** value(s) should reflect the commanded value -** - The #CFE_ES_PERF_FILTMSKCMD_EID debug event message will be -** generated. -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - The Filter Mask ID number is out of range -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** Changing the filter masks may cause a small change in the Performance -** Analyzer's CPU utilization. -** -** \sa #CFE_ES_PERF_STARTDATA_CC, #CFE_ES_PERF_STOPDATA_CC, #CFE_ES_PERF_SETTRIGMASK_CC -*/ -#define CFE_ES_PERF_SETFILTERMASK_CC 16 - -/** \cfeescmd Set Performance Analyzer's Trigger Masks -** -** \par Description -** This command sets the Performance Analyzer's Trigger Masks. -** -** \cfecmdmnemonic \ES_LATRIGGERMASK -** -** \par Command Structure -** #CFE_ES_PerfSetTrigMaskCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - \b \c \ES_PERFTRIGMASK - the current performance trigger mask -** value(s) should reflect the commanded value -** - The #CFE_ES_PERF_TRIGMSKCMD_EID debug event message will be -** generated. -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - The Trigger Mask ID number is out of range -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** Changing the trigger masks may cause a small change in the Performance -** Analyzer's CPU utilization. -** -** \sa #CFE_ES_PERF_STARTDATA_CC, #CFE_ES_PERF_STOPDATA_CC, #CFE_ES_PERF_SETFILTERMASK_CC -*/ -#define CFE_ES_PERF_SETTRIGMASK_CC 17 - -/** \cfeescmd Set Executive Services System Log Mode to Discard/Overwrite -** -** \par Description -** This command allows the user to configure the Executive Services -** to either discard new System Log messages when it is full or to -** overwrite the oldest messages. -** -** \cfecmdmnemonic \ES_OVERWRITESYSLOGMODE -** -** \par Command Structure -** #CFE_ES_OverWriteSysLogCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - \b \c \ES_SYSLOGMODE - Current System Log Mode should reflect -** the commanded value -** - The #CFE_ES_SYSLOGMODE_EID debug event message will be -** generated. -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - The desired mode is neither #CFE_ES_LOG_OVERWRITE or #CFE_ES_LOG_DISCARD -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** None. (It should be noted that "Overwrite" mode would allow a message -** identifying the cause of a problem to be lost by a subsequent flood of -** additional messages). -** -** \sa #CFE_ES_CLEAR_SYSLOG_CC, #CFE_ES_WRITE_SYSLOG_CC -*/ -#define CFE_ES_OVERWRITE_SYSLOG_CC 18 - -/** \cfeescmd Resets the Processor Reset Counter to Zero -** -** \par Description -** This command allows the user to reset the Processor Reset Counter to zero. -** The Processor Reset Counter counts the number of Processor Resets that -** have occurred so as to identify when a Processor Reset should automatically -** be upgraded to a full Power-On Reset. -** -** \cfecmdmnemonic \ES_RESETPRCNT -** -** \par Command Structure -** #CFE_ES_NoArgsCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - \b \c \ES_PROCRESETCNT - Current number of processor resets will go to zero -** - The #CFE_ES_RESET_PR_COUNT_EID informational event message will be -** generated. -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** This command is not critical. The only impact would be that the system -** would have to have more processor resets before an automatic power-on reset -** occurred. -** -** \sa #CFE_ES_SET_MAX_PR_COUNT_CC, #CFE_ES_RESET_CC -*/ -#define CFE_ES_RESET_PR_COUNT_CC 19 - -/** \cfeescmd Configure the Maximum Number of Processor Resets before a Power-On Reset -** -** \par Description -** This command allows the user to specify the number of Processor Resets that -** are allowed before the next Processor Reset is upgraded to a Power-On Reset. -** -** \cfecmdmnemonic \ES_SETMAXPRCNT -** -** \par Command Structure -** #CFE_ES_SetMaxPRCountCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - \b \c \ES_MAXPROCRESETS - Current maximum number of processor resets -** before an automatic power-on reset will go to the command specified value. -** - The #CFE_ES_SET_MAX_PR_COUNT_EID informational event message will be -** generated. -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** If the operator were to set the Maximum Processor Reset Count to too high a value, -** the processor would require an inordinate number of consecutive processor resets -** before an automatic power-on reset would occur. This could potentially leave the -** spacecraft without any control for a significant amount of time if a processor reset -** fails to clear a problem. -** -** \sa #CFE_ES_RESET_PR_COUNT_CC -*/ -#define CFE_ES_SET_MAX_PR_COUNT_CC 20 - -/** \cfeescmd Delete Critical Data Store -** -** \par Description -** This command allows the user to delete a Critical Data Store that was created -** by an Application that is now no longer executing. -** -** \cfecmdmnemonic \ES_DELETECDS -** -** \par Command Structure -** #CFE_ES_DeleteCDSCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_CDS_DELETED_INFO_EID informational event message will be -** generated. -** - The specified CDS should no longer appear in a CDS Registry dump generated -** upon receipt of the #CFE_ES_DUMP_CDS_REG_CC command -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - The specified CDS is the CDS portion of a Critical Table. See #CFE_TBL_DELETE_CDS_CC. -** - The specified CDS is not found in the CDS Registry -** - The specified CDS is associated with an Application that is still active -** - An error occurred while accessing the CDS memory (see the System Log for more details) -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** This command is not critical because it is not possible to delete a CDS that is -** associated with an active application. However, deleting a CDS does eliminate -** any "history" that an application may be wishing to keep. -** -** \sa #CFE_ES_DUMP_CDS_REG_CC, #CFE_TBL_DELETE_CDS_CC -*/ -#define CFE_ES_DELETE_CDS_CC 21 - -/** \cfeescmd Telemeter Memory Pool Statistics -** -** \par Description -** This command allows the user to obtain a snapshot of the statistics maintained -** for a specified memory pool. -** -** \cfecmdmnemonic \ES_TLMPOOLSTATS -** -** \par Command Structure -** #CFE_ES_TlmPoolStatsCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_TLM_POOL_STATS_INFO_EID debug event message will be -** generated. -** - The \link #CFE_ES_PoolStatsTlm_t Memory Pool Statistics Telemetry Packet \endlink -** is produced -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - The specified handle is not associated with a known memory pool -** - The specified handle caused a processor exception because it improperly -** identified a segment of memory -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** An incorrect Memory Pool Handle value can cause a system crash. -** Extreme care should be taken to ensure the memory handle value -** used in the command is correct. -** -** \sa -*/ -#define CFE_ES_TLM_POOL_STATS_CC 22 - -/** \cfeescmd Dump Critical Data Store Registry to a File -** -** \par Description -** This command allows the user to dump the Critical Data Store -** Registry to an onboard file. -** -** \cfecmdmnemonic \ES_DUMPCDSREG -** -** \par Command Structure -** #CFE_ES_DumpCDSRegCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_CDS_REG_DUMP_INF_EID debug event message will be -** generated. -** - The file specified in the command (or the default specified -** by the #CFE_ES_DEFAULT_CDS_REG_DUMP_FILE configuration parameter) will be -** updated with the lastest information. -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Error occurred while trying to create the dump file -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** This command is not inherently dangerous. It will create a new -** file in the file system (or overwrite an existing one) and could, -** if performed repeatedly without sufficient file management by the -** operator, fill the file system. -** -** \sa #CFE_ES_DELETE_CDS_CC, #CFE_TBL_DELETE_CDS_CC -*/ -#define CFE_ES_DUMP_CDS_REG_CC 23 - -/** \cfeescmd Writes a list of All Executive Services Tasks to a File -** -** \par Description -** This command takes the information kept by Executive Services on all of the -** registered tasks and writes it to the specified file. -** -** \cfecmdmnemonic \ES_WRITETASKINFO2FILE -** -** \par Command Structure -** #CFE_ES_QueryAllTasksCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment -** - The #CFE_ES_TASKINFO_EID debug event message will be -** generated. -** - The file specified in the command (or the default specified -** by the #CFE_ES_DEFAULT_TASK_LOG_FILE configuration parameter) will be -** updated with the lastest information. -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - An Error occurs while trying to write to the file -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** This command is not inherently dangerous. It will create a new -** file in the file system (or overwrite an existing one) and could, -** if performed repeatedly without sufficient file management by the -** operator, fill the file system. -** -** \sa #CFE_ES_QUERY_ALL_CC, CFE_ES_QUERY_ONE_CC -*/ -#define CFE_ES_QUERY_ALL_TASKS_CC 24 - - -/** \} */ - - -/*************************************************************************/ -/********************************/ -/* Command Message Data Formats */ -/********************************/ -/** -** \brief Generic "no arguments" command -** -** This command structure is used for commands that do not have any parameters. -** This includes: -** -# The Housekeeping Request Message -** -# The No-Op Command (For details, see #CFE_ES_NOOP_CC) -** -# The Reset Counters Command (For details, see #CFE_ES_RESET_CC) -*/ -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - -} CFE_ES_NoArgsCmd_t; - -/** -** \brief Reset cFE Command -** -** For command details, see #CFE_ES_RESTART_CC -** -**/ -typedef struct -{ - uint16 RestartType; /**< \brief #CFE_ES_PROCESSOR_RESET=Processor Reset - or #CFE_ES_POWERON_RESET=Power-On Reset */ -} CFE_ES_RestartCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_RestartCmd_Payload_t Payload; -} CFE_ES_RestartCmd_t; - -/** -** \brief Shell Command -** -** For command details, see #CFE_ES_SHELL_CMD_CC -** -**/ -typedef struct -{ - char CmdString[CFE_ES_MAX_SHELL_CMD]; /**< \brief ASCII text string containing shell command - to be executed */ - char OutputFilename[OS_MAX_PATH_LEN]; /**< \brief Filename where shell command output is to - be written */ -} CFE_ES_ShellCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_ShellCmd_Payload_t Payload; -} CFE_ES_ShellCmd_t; - -/** -** \brief Write All ES Application Info for All Applications to File Command -** -** For command details, see #CFE_ES_QUERY_ALL_CC -** -**/ -typedef struct -{ - char QueryAllFileName[OS_MAX_PATH_LEN]; /**< \brief ASCII text string containing full path and - filename of file in which Application data is to be dumped */ -} CFE_ES_QueryAllCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_QueryAllCmd_Payload_t Payload; -} CFE_ES_QueryAllCmd_t; - -/** -** \brief Write All ES Application Info for All Tasks to File Command -** -** For command details, see #CFE_ES_QUERY_ALL_TASKS_CC -** -**/ -typedef struct -{ - char QueryAllFileName[OS_MAX_PATH_LEN]; /**< \brief ASCII text string containing full path and - filename of file in which Application data is to be dumped */ - -} CFE_ES_QueryAllTasksCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_QueryAllTasksCmd_Payload_t Payload; -} CFE_ES_QueryAllTasksCmd_t; - - -/** -** \brief Dump System Log to File Command -** -** For command details, see #CFE_ES_WRITE_SYSLOG_CC -** -**/ -typedef struct -{ - char SysLogFileName[OS_MAX_PATH_LEN]; /**< \brief ASCII text string containing full path and - filename of file in which System Log is to be dumped */ -} CFE_ES_WriteSyslogCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_WriteSyslogCmd_Payload_t Payload; -} CFE_ES_WriteSyslogCmd_t; - -/** -** \brief Dump Exception and Reset Log to File Command -** -** For command details, see #CFE_ES_WRITE_ERLOG_CC -** -**/ -typedef struct -{ - char ERLogFileName[OS_MAX_PATH_LEN]; /**< \brief ASCII text string containing full path and - filename of file in which ER Log is to be dumped */ -} CFE_ES_WriteERlogCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_WriteERlogCmd_Payload_t Payload; -} CFE_ES_WriteERlogCmd_t; - -/** -** \brief Overwrite/Discard System Log Configuration Command -** -** For command details, see #CFE_ES_OVERWRITE_SYSLOG_CC -** -**/ -typedef struct -{ - uint32 Mode; /**< \brief #CFE_ES_LOG_DISCARD=Throw away most recent messages, - #CFE_ES_LOG_OVERWRITE=Overwrite oldest with most recent */ - -} CFE_ES_OverWriteSysLogCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_OverWriteSysLogCmd_Payload_t Payload; -} CFE_ES_OverWriteSysLogCmd_t; - -/** -** \brief Start Application Command -** -** For command details, see #CFE_ES_START_APP_CC -** -**/ -typedef struct -{ - char Application[OS_MAX_API_NAME]; /**< \brief Name of Application to be started */ - char AppEntryPoint[OS_MAX_API_NAME]; /**< \brief Symbolic name of Application's entry point */ - char AppFileName[OS_MAX_PATH_LEN]; /**< \brief Full path and filename of Application's - executable image */ - - uint32 StackSize; /**< \brief Desired stack size for the new application */ - - uint16 ExceptionAction; /**< \brief #CFE_ES_APP_EXCEPTION_RESTART_APP=On exception, - restart Application, - #CFE_ES_APP_EXCEPTION_PROC_RESTART=On exception, - perform a Processor Reset */ - uint16 Priority; /**< \brief The new Applications runtime priority. */ - -} CFE_ES_StartAppCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_StartAppCmd_Payload_t Payload; -} CFE_ES_StartAppCmd_t; - -/** -** \brief Command Structure for Commands requiring just an Application Name -** -** For command details, see #CFE_ES_STOP_APP_CC, #CFE_ES_RESTART_APP_CC, #CFE_ES_QUERY_ONE_CC -** -**/ -typedef struct -{ - char Application[OS_MAX_API_NAME]; /**< \brief ASCII text string containing Application Name */ -} CFE_ES_AppNameCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_AppNameCmd_Payload_t Payload; -} CFE_ES_AppNameCmd_t; - -/** -** \brief Reload Application Command -** -** For command details, see #CFE_ES_RELOAD_APP_CC -** -**/ -typedef struct -{ - char Application[OS_MAX_API_NAME]; /**< \brief ASCII text string containing Application Name */ - char AppFileName[OS_MAX_PATH_LEN]; /**< \brief Full path and filename of Application's - executable image */ -} CFE_ES_AppReloadCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_AppReloadCmd_Payload_t Payload; -} CFE_ES_AppReloadCmd_t; - -/** -** \brief Set Maximum Processor Reset Count Command -** -** For command details, see #CFE_ES_SET_MAX_PR_COUNT_CC -** -**/ -typedef struct -{ - uint16 MaxPRCount; /**< \brief New maximum number of Processor Resets before - an automatic Power-On Reset is performed */ -} CFE_ES_SetMaxPRCountCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_SetMaxPRCountCmd_Payload_t Payload; -} CFE_ES_SetMaxPRCountCmd_t; - -/** -** \brief Delete Critical Data Store Command -** -** For command details, see #CFE_ES_DELETE_CDS_CC -** -**/ -typedef struct -{ - char CdsName[CFE_ES_CDS_MAX_FULL_NAME_LEN]; /**< \brief ASCII text string containing name of CDS to delete */ - -} CFE_ES_DeleteCDSCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_DeleteCDSCmd_Payload_t Payload; -} CFE_ES_DeleteCDSCmd_t; - -/** -** \brief Start Performance Analyzer Command -** -** For command details, see #CFE_ES_PERF_STARTDATA_CC -** -**/ -typedef struct -{ - uint32 TriggerMode; /**< \brief Desired trigger position (Start, Center, End) */ -} CFE_ES_PerfStartCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_PerfStartCmd_Payload_t Payload; -} CFE_ES_PerfStartCmd_t; - -/** -** \brief Stop Performance Analyzer Command -** -** For command details, see #CFE_ES_PERF_STOPDATA_CC -** -**/ -typedef struct -{ - char DataFileName[OS_MAX_PATH_LEN]; /**< \brief ASCII text string of full path and filename - of file Performance Analyzer data is to be written */ -} CFE_ES_PerfStopCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_PerfStopCmd_Payload_t Payload; -} CFE_ES_PerfStopCmd_t; - - -/** -** \brief Set Performance Analyzer Filter Mask Command -** -** For command details, see #CFE_ES_PERF_SETFILTERMASK_CC -** -**/ -typedef struct -{ - uint32 FilterMaskNum; /**< \brief Index into array of Filter Masks */ - uint32 FilterMask; /**< \brief New Mask for specified entry in array of Filter Masks */ - -} CFE_ES_PerfSetFilterMaskCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_PerfSetFilterMaskCmd_Payload_t Payload; -} CFE_ES_PerfSetFilterMaskCmd_t; - -/** -** \brief Set Performance Analyzer Trigger Mask Command -** -** For command details, see #CFE_ES_PERF_SETTRIGMASK_CC -** -**/ -typedef struct -{ - uint32 TriggerMaskNum; /**< \brief Index into array of Trigger Masks */ - uint32 TriggerMask; /**< \brief New Mask for specified entry in array of Trigger Masks */ - -} CFE_ES_PerfSetTrigMaskCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_PerfSetTrigMaskCmd_Payload_t Payload; -} CFE_ES_PerfSetTrigMaskCmd_t; - -/** -** \brief Telemeter Memory Pool Statistics Command -** -** For command details, see #CFE_ES_TLM_POOL_STATS_CC -** -**/ -typedef struct -{ - char Application[OS_MAX_API_NAME]; /**< \brief - RESERVED - should be all zeroes */ - CFE_ES_MemHandle_t PoolHandle; /**< \brief Handle of Pool whose statistics are to be telemetered */ - -} CFE_ES_TlmPoolStatsCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_TlmPoolStatsCmd_Payload_t Payload; -} CFE_ES_TlmPoolStatsCmd_t; - -/** -** \brief Dump CDS Registry Command -** -** For command details, see #CFE_ES_DUMP_CDS_REG_CC -** -**/ -typedef struct -{ - char DumpFilename[OS_MAX_PATH_LEN]; /**< \brief ASCII text string of full path and filename - of file CDS Registry is to be written */ -} CFE_ES_DumpCDSRegCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_ES_DumpCDSRegCmd_Payload_t Payload; - -} CFE_ES_DumpCDSRegCmd_t; - -/*************************************************************************/ -/**********************************/ -/* Telemetry Message Data Formats */ -/**********************************/ -/** -** \cfeestlm Single Application Information Packet -**/ -typedef struct -{ - CFE_ES_AppInfo_t AppInfo; /**< \brief For more information, see #CFE_ES_AppInfo_t */ - -} CFE_ES_OneAppTlm_Payload_t; - -typedef struct -{ - uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; /**< \brief cFE Software Bus Telemetry Message Header */ - CFE_ES_OneAppTlm_Payload_t Payload; -} CFE_ES_OneAppTlm_t; - -/** -** \cfeestlm Memory Pool Statistics Packet -**/ -typedef struct -{ - CFE_ES_MemHandle_t PoolHandle; /**< \cfetlmmnemonic \ES_POOLHANDLE - \brief Handle of memory pool whose stats are being telemetered */ - CFE_ES_MemPoolStats_t PoolStats; /**< \brief For more info, see #CFE_ES_MemPoolStats_t */ -} CFE_ES_PoolStatsTlm_Payload_t; - -typedef struct -{ - uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; /**< \brief cFE Software Bus Telemetry Message Header */ - CFE_ES_PoolStatsTlm_Payload_t Payload; -} CFE_ES_PoolStatsTlm_t; - -/*************************************************************************/ - -/** -** \cfeestlm Executive Services Housekeeping Packet -**/ -typedef struct -{ - uint8 CmdCounter; /**< \cfetlmmnemonic \ES_CMDPC - \brief The ES Application Command Counter */ - uint8 ErrCounter; /**< \cfetlmmnemonic \ES_CMDEC - \brief The ES Application Command Error Counter */ - - uint16 CFECoreChecksum; /**< \cfetlmmnemonic \ES_CKSUM - \brief Checksum of cFE Core Code */ - uint8 CFEMajorVersion; /**< \cfetlmmnemonic \ES_CFEMAJORVER - \brief Major Version Number of cFE */ - uint8 CFEMinorVersion; /**< \cfetlmmnemonic \ES_CFEMINORVER - \brief Minor Version Number of cFE */ - uint8 CFERevision; /**< \cfetlmmnemonic \ES_CFEREVISION - \brief Sub-Minor Version Number of cFE */ - uint8 CFEMissionRevision; /**< \cfetlmmnemonic \ES_CFEMISSIONREV - \brief Mission Version Number of cFE */ - uint8 OSALMajorVersion; /**< \cfetlmmnemonic \ES_OSMAJORVER - \brief OS Abstraction Layer Major Version Number */ - uint8 OSALMinorVersion; /**< \cfetlmmnemonic \ES_OSMINORVER - \brief OS Abstraction Layer Minor Version Number */ - uint8 OSALRevision; /**< \cfetlmmnemonic \ES_OSREVISION - \brief OS Abstraction Layer Revision Number */ - uint8 OSALMissionRevision;/**< \cfetlmmnemonic \ES_OSMISSIONREV - \brief OS Abstraction Layer MissionRevision Number */ - - uint32 SysLogBytesUsed; /**< \cfetlmmnemonic \ES_SYSLOGBYTEUSED - \brief Total number of bytes used in system log */ - uint32 SysLogSize; /**< \cfetlmmnemonic \ES_SYSLOGSIZE - \brief Total size of the system log */ - uint32 SysLogEntries; /**< \cfetlmmnemonic \ES_SYSLOGENTRIES - \brief Number of entries in the system log */ - uint32 SysLogMode; /**< \cfetlmmnemonic \ES_SYSLOGMODE - \brief Write/Overwrite Mode */ - - uint32 ERLogIndex; /**< \cfetlmmnemonic \ES_ERLOGINDEX - \brief Current index of the ER Log (wraps around) */ - uint32 ERLogEntries; /**< \cfetlmmnemonic \ES_ERLOGENTRIES - \brief Number of entries made in the ER Log since the power on */ - - uint32 RegisteredCoreApps; /**< \cfetlmmnemonic \ES_REGCOREAPPS - \brief Number of Applications registered with ES */ - uint32 RegisteredExternalApps; /**< \cfetlmmnemonic \ES_REGEXTAPPS - \brief Number of Applications registered with ES */ - uint32 RegisteredTasks; /**< \cfetlmmnemonic \ES_REGTASKS - \brief Number of Tasks ( main AND child tasks ) registered with ES */ - uint32 RegisteredLibs; /**< \cfetlmmnemonic \ES_REGLIBS - \brief Number of Libraries registered with ES */ - - uint32 ResetType; /**< \cfetlmmnemonic \ES_RESETTYPE - \brief Reset type ( PROCESSOR or POWERON ) */ - uint32 ResetSubtype; /**< \cfetlmmnemonic \ES_RESETSUBTYPE - \brief Reset Sub Type */ - uint32 ProcessorResets; /**< \cfetlmmnemonic \ES_PROCRESETCNT - \brief Number of processor resets since last power on */ - uint32 MaxProcessorResets; /**< \cfetlmmnemonic \ES_MAXPROCRESETS - \brief Max processor resets before a power on is done */ - uint32 BootSource; /**< \cfetlmmnemonic \ES_BOOTSOURCE - \brief Boot source ( as provided from BSP ) */ - - uint32 PerfState; /**< \cfetlmmnemonic \ES_PERFSTATE - \brief Current state of Performance Analyzer */ - uint32 PerfMode; /**< \cfetlmmnemonic \ES_PERFMODE - \brief Current mode of Performance Analyzer */ - uint32 PerfTriggerCount; /**< \cfetlmmnemonic \ES_PERFTRIGCNT - \brief Number of Times Perfomance Analyzer has Triggered */ - uint32 PerfFilterMask[CFE_ES_PERF_MAX_IDS / 32]; /**< \cfetlmmnemonic \ES_PERFFLTRMASK - \brief Current Setting of Performance Analyzer Filter Masks */ - uint32 PerfTriggerMask[CFE_ES_PERF_MAX_IDS / 32]; /**< \cfetlmmnemonic \ES_PERFTRIGMASK - \brief Current Setting of Performance Analyzer Trigger Masks */ - uint32 PerfDataStart; /**< \cfetlmmnemonic \ES_PERFDATASTART - \brief Identifies First Stored Entry in Performance Analyzer Log */ - uint32 PerfDataEnd; /**< \cfetlmmnemonic \ES_PERFDATAEND - \brief Identifies Last Stored Entry in Performance Analyzer Log */ - uint32 PerfDataCount; /**< \cfetlmmnemonic \ES_PERFDATACNT - \brief Number of Entries Put Into the Performance Analyzer Log */ - uint32 PerfDataToWrite; /**< \cfetlmmnemonic \ES_PERFDATA2WRITE - \brief Number of Performance Analyzer Log Entries Left to be Written to Log Dump File */ - uint32 HeapBytesFree; /**< \cfetlmmnemonic \ES_HEAPBYTESFREE - \brief Number of free bytes remaining in the OS heap */ - uint32 HeapBlocksFree; /**< \cfetlmmnemonic \ES_HEAPBLKSFREE - \brief Number of free blocks remaining in the OS heap */ - uint32 HeapMaxBlockSize; /**< \cfetlmmnemonic \ES_HEAPMAXBLK - \brief Number of bytes in the largest free block */ -} CFE_ES_HkPacket_Payload_t; - -typedef struct -{ - uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; /**< \brief cFE Software Bus Telemetry Message Header */ - CFE_ES_HkPacket_Payload_t Payload; - -} CFE_ES_HkPacket_t; - -/** -** \cfeestlm OS Shell Output Packet -**/ -typedef struct -{ - char ShellOutput[CFE_ES_MAX_SHELL_PKT]; /**< \brief ASCII text string containing output from OS Shell - that was received in response to an OS Shell Command */ -} CFE_ES_ShellPacket_Payload_t; - -typedef struct -{ - uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; /**< \brief cFE Software Bus Telemetry Message Header */ - CFE_ES_ShellPacket_Payload_t Payload; -}CFE_ES_ShellPacket_t; - -/*************************************************************************/ - -#endif /* _cfe_es_msg_ */ - -/************************/ -/* End of File Comment */ -/************************/ - diff --git a/src/components/interface/cFE/cfe_es_perfids.h b/src/components/interface/cFE/cfe_es_perfids.h deleted file mode 100644 index 7964453f11..0000000000 --- a/src/components/interface/cFE/cfe_es_perfids.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -** File: cfe_es_perfids.h -** -** Purpose: This file contains the perf_ids -** -** Copyright (c) 2004-2012, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Design Notes: -** Each performance id is used to identify something that needs to be -** measured. Performance ids are limited to the range of 0 to -** CFE_ES_PERF_MAX_IDS - 1. Any performance ids outside of this range -** will be ignored and will be flagged as an error. Note that -** performance ids 0-31 are reserved for the cFE Core. -** -** References: -** -** $Log: cfe_es_perfids.h $ -** Revision 1.6 2012/01/13 12:32:23GMT-05:00 acudmore -** Changed license text to reflect open source -** Revision 1.5 2012/01/06 14:06:54EST rmcgraw -** DCR16100:2 changed pipe overflow id from 12 to 27 -** Revision 1.4 2012/01/06 09:27:19GMT-05:00 rmcgraw -** DCR16100:1 Added perf markers for msg lim and pipe overflow errors -** Revision 1.3 2010/09/21 15:04:06GMT-05:00 jmdagost -** Make copyright symbol readable. -** Revision 1.2 2010/09/21 16:02:42EDT jmdagost -** Change performance IDs from hexadecimal to decimal. -** Revision 1.1 2008/04/17 08:05:20EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.9 2007/09/24 11:13:39EDT rjmcgraw -** DCR5039 Updated comments -** Revision 1.8 2007/08/31 10:57:18EDT rjmcgraw -** Changes to eliminate perl script -** Revision 1.7 2007/04/24 08:59:04EDT njyanchik -** I added the changes tha LRO requested. They are specified in the DCR text. -** Revision 1.6 2007/04/09 14:43:30EDT rjmcgraw -** Changed names of performance ids to include CFE_ -** Revision 1.5 2006/12/26 15:23:29EST rjmcgraw -** removed SBP performance id -** Revision 1.4 2006/11/20 15:17:00EST dlkobe -** Updated comments to make use of Doxygen utility -** Revision 1.3 2006/06/21 12:13:27GMT-05:00 kkaudra -** Added Markers for TIME ISRs -** Revision 1.2 2006/06/14 09:53:21EDT kkaudra -** moved perf config information to cfe_platform_cfg.h -** Revision 1.1 2006/06/13 15:39:08EDT rjmcgraw -** Initial revision -** -*/ - -#ifndef _cfe_es_perfids_ -#define _cfe_es_perfids_ - - -#define CFE_ES_PERF_EXIT_BIT 31 /**< \brief bit (31) is reserved by the perf utilities */ - -/** \name cFE Performance Monitor IDs (Reserved IDs 0-31) */ -/** \{ */ -#define CFE_ES_MAIN_PERF_ID 1 /**< \brief Performance ID for Executive Services Task */ -#define CFE_EVS_MAIN_PERF_ID 2 /**< \brief Performance ID for Events Services Task */ -#define CFE_TBL_MAIN_PERF_ID 3 /**< \brief Performance ID for Table Services Task */ -#define CFE_SB_MAIN_PERF_ID 4 /**< \brief Performance ID for Software Bus Services Task */ -#define CFE_SB_MSG_LIM_PERF_ID 5 /**< \brief Performance ID for Software Bus Msg Limit Errors */ -#define CFE_SB_PIPE_OFLOW_PERF_ID 27 /**< \brief Performance ID for Software Bus Pipe Overflow Errors */ - - -#define CFE_TIME_MAIN_PERF_ID 6 /**< \brief Performance ID for Time Services Task */ -#define CFE_TIME_TONE1HZISR_PERF_ID 7 /**< \brief Performance ID for 1 Hz Tone ISR */ -#define CFE_TIME_LOCAL1HZISR_PERF_ID 8 /**< \brief Performance ID for 1 Hz Local ISR */ - -#define CFE_TIME_SENDMET_PERF_ID 9 /**< \brief Performance ID for Time ToneSendMET */ -#define CFE_TIME_LOCAL1HZTASK_PERF_ID 10 /**< \brief Performance ID for 1 Hz Local Task */ -#define CFE_TIME_TONE1HZTASK_PERF_ID 11 /**< \brief Performance ID for 1 Hz Tone Task */ - - -/** \} */ - - -#endif /* _cfe_es_perfids_ */ diff --git a/src/components/interface/cFE/cfe_evs.h b/src/components/interface/cFE/cfe_evs.h deleted file mode 100644 index 22b0d2bef7..0000000000 --- a/src/components/interface/cFE/cfe_evs.h +++ /dev/null @@ -1,427 +0,0 @@ -/* -** -** Filename: cfe_evs.h -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -* -** $Id: cfe_evs.h 1.4 2010/10/26 16:01:08GMT-05:00 jmdagost Exp $ -** -** Title: Event Services API Application Library Header File -** -** Purpose: -** Unit specification for Event services library functions and macros. -** -** Design Notes: -** -** References: -** Flight Software Branch C Coding Standard Version 1.0a -** -** $Date: 2010/10/26 16:01:08GMT-05:00 $ -** $Revision: 1.4 $ -** $Log: cfe_evs.h $ -** Revision 1.4 2010/10/26 16:01:08GMT-05:00 jmdagost -** Made CFE_EVS_ResetFilter() argument a signed int. -** Revision 1.3 2010/10/04 17:06:06EDT jmdagost -** Cleaned up copyright symbol. -** Revision 1.2 2008/12/08 12:07:11EST dkobe -** Updates to correct doxygen errors -** Revision 1.1 2008/04/17 08:05:21EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.19 2007/09/20 08:37:52EDT njyanchik -** I added the doxygen comments to CFE_EVS_Log_t -** Revision 1.18 2007/07/18 11:53:06EDT njyanchik -** The two structures specified in DCR 4407 were moved to cfe_evs_msg.h -** Revision 1.17 2007/07/12 16:45:13EDT rjmcgraw -** DCR4680:1 Added #defines for more filtering options -** Revision 1.16 2007/06/07 16:03:55EDT dlkobe -** Corrected doxygen comment syntax errors -** Revision 1.15 2007/06/07 13:07:49EDT dlkobe -** Added Command and Telemetry doxygen comments to TIME, EVS and SB -** Revision 1.14 2007/05/23 11:21:58EDT dlkobe -** Added doxygen formatting -** Revision 1.13 2007/05/14 10:26:04EDT apcudmore -** Preserve the EVS Local event log on a processor restart: -** - moved the EVS Log to the ES reset data structure -** - Added a couple of EVS Log related variables into the EVS_Log_t structure -** - Added a routine to the EVS early init to get a pointer to the EVS Log -** - Added code to the EVS housekeeping service routine to copy Log variables into TLM -** Revision 1.12 2007/03/01 11:54:34EST njyanchik -** This cp handles issues 1,6,7,8 as described in the DCR -** Revision 1.11 2006/11/17 16:46:10EST dlkobe -** Updated with Doxygen formatted comments -** Revision 1.10 2006/06/08 13:14:53GMT-05:00 njyanchik -** I added the appropriate legal headers to all of the evs files -** Revision 1.9 2005/11/01 15:27:35EST njyanchik -** Added header for CFE_EVS_SendEventWithAppID function in /evs/cfe_evs.c -** Revision 1.8 2005/10/21 16:02:04EDT kkaudra -** Exposure of the EVS event packet types -** Revision 1.7 2005/09/08 17:47:51EDT sstrege -** Added Event Mask CFE_EVS_EVERY_FOURTH_ONE -** Revision 1.6 2005/08/23 14:10:07EDT kkaudra -** Make Command Code definitions public -**/ - -#ifndef _cfe_evs_ -#define _cfe_evs_ - -/********************************** Include Files ************************************/ -#include "common_types.h" /* Basic data types */ -#include "cfe_time.h" /* Time library function definitions */ -#include "cfe_evs_msg.h" /* EVS command codes and data structures*/ -#include "osapi.h" -#include "cfe_sb.h" - - - - - - -/******************* Macro Definitions ***********************/ - -/* -** The OS_PRINTF macro may be defined by OSAL to enable -** printf-style argument checking. If using a version of OSAL -** that does not define this then define it as a no-op. -*/ -#ifndef OS_PRINTF -#define OS_PRINTF(m,n) -#endif - -/** \name Event Filter Schemes */ -/** \{ */ -#define CFE_EVS_BINARY_FILTER 0 -/** \} */ - -/** \name Common Event Filter Mask Values */ -/** \{ */ -#define CFE_EVS_NO_FILTER 0x0000 /**< \brief Stops any filtering. All messages are sent. */ -#define CFE_EVS_FIRST_ONE_STOP 0xFFFF /**< \brief Sends the first event. All remaining messages are filtered. */ -#define CFE_EVS_FIRST_TWO_STOP 0xFFFE /**< \brief Sends the first 2 events. All remaining messages are filtered. */ -#define CFE_EVS_FIRST_4_STOP 0xFFFC /**< \brief Sends the first 4 events. All remaining messages are filtered. */ -#define CFE_EVS_FIRST_8_STOP 0xFFF8 /**< \brief Sends the first 8 events. All remaining messages are filtered. */ -#define CFE_EVS_FIRST_16_STOP 0xFFF0 /**< \brief Sends the first 16 events. All remaining messages are filtered. */ -#define CFE_EVS_FIRST_32_STOP 0xFFE0 /**< \brief Sends the first 32 events. All remaining messages are filtered. */ -#define CFE_EVS_FIRST_64_STOP 0xFFC0 /**< \brief Sends the first 64 events. All remaining messages are filtered. */ -#define CFE_EVS_EVERY_OTHER_ONE 0x0001 /**< \brief Sends every other event. */ -#define CFE_EVS_EVERY_OTHER_TWO 0x0002 /**< \brief Sends two, filters one, sends two, filters one, etc */ -#define CFE_EVS_EVERY_FOURTH_ONE 0x0003 /**< \brief Sends every fourth event message. All others are filtered. */ -/** \} */ - -/** \name Event Types */ -/** \{ */ -#define CFE_EVS_DEBUG 0x01 /**< \brief Events that are intended only for debugging, not nominal operations */ -#define CFE_EVS_INFORMATION 0x02 /**< \brief Events that identify a state change or action that is not an error */ -#define CFE_EVS_ERROR 0x03 /**< \brief Events that identify an error but are not catastrophic (e.g. - bad command */ -#define CFE_EVS_CRITICAL 0x04 /**< \brief Events that identify errors that are unrecoverable autonomously. */ -/** \} */ - -/** \name Output Ports */ -/** \{ */ -#define CFE_EVS_PORT1 0x01 -#define CFE_EVS_PORT2 0x02 -#define CFE_EVS_PORT3 0x03 -#define CFE_EVS_PORT4 0x04 -/** \} */ - -/****************** Structure Definitions *********************/ - -/** Event message filter defintion structure */ -typedef struct { - uint16 EventID; /**< \brief Numerical event identifier */ - uint16 Mask; /**< \brief Binary filter mask value */ - -} CFE_EVS_BinFilter_t; - -/* Command packet structures */ - - -/****************** Function Prototypes **********************/ - -/** -** \brief Register an application for receiving event services -** -** \par Description -** This routine registers an application with event services and allocates/initializes -** the internal data structures used to support this application's events. An application -** may not send events unless it has called this routine. The routine also accepts a filter -** array structure for applications requiring event filtering. In the current implementation -** of the EVS, only the binary filtering scheme is supported. See section TBD of the cFE -** Application Programmer's Guide for a description of the behavior of binary filters. -** Applications may call #CFE_EVS_Register more than once, but each call will wipe out all -** filters registered by previous calls (filter registration is NOT cumulative). -** -** \par Assumptions, External Events, and Notes: -** Note: Event filters can be added, deleted or modified by ground commands. All filtering -** schemes include a default setting that results in no filtering (such as #CFE_EVS_NO_FILTER -** for binary filters). -** -** Filter Scheme: Binary
-** Code: CFE_EVS_BINARY_FILTER
-** Filter Structure: -** \code -** typedef struct { -** uint16 EventID, -** uint16 Mask ; -** } CFE_EVS_BinFilter_t; -** \endcode -** -** \param[in] Filters Pointer to an array of event message filters, or NULL if no filtering is desired. -** The structure of an event message filter depends on the FilterScheme selected. -** (see Filter Schemes mentioned above) -** -** \param[in] NumFilteredEvents The number of event message filters included in this call. This must be less than -** or equal to the maximum number of events allowed per application (#CFE_EVS_MAX_EVENT_FILTERS). -** -** \param[in] FilterScheme The event filtering scheme that this application will use. For the first implementation of -** the event services, only filter type #CFE_EVS_BINARY_FILTER will be supported. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_EVS_APP_FILTER_OVERLOAD \retdesc \copydoc CFE_EVS_APP_FILTER_OVERLOAD \endcode -** \retcode #CFE_EVS_UNKNOWN_FILTER \retdesc \copydoc CFE_EVS_UNKNOWN_FILTER \endcode -** \retcode #CFE_EVS_APP_ILLEGAL_APP_ID \retdesc \copydoc CFE_EVS_APP_ILLEGAL_APP_ID \endcode -** \retstmt Any of the error codes from #CFE_ES_GetAppID \endstmt -** \endreturns -** -** \sa #CFE_EVS_Unregister -** -**/ -int32 CFE_EVS_Register (void *Filters, /* Pointer to an array of filters */ - uint16 NumFilteredEvents, /* How many elements in the array? */ - uint16 FilterScheme); /* Filtering Algorithm to be implemented */ - -/** -** \brief Cleanup internal structures used by the event manager for the calling Application. -** -** \par Description -** This routine un-registers the calling application from receiving event services -** and removes and deletes the calling applications filters and counters from the -** internal event service filter and counter tables if registered. Applications -** must call this routine as part of their orderly shutdown process. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_EVS_APP_NOT_REGISTERED \retdesc \copydoc CFE_EVS_APP_NOT_REGISTERED \endcode -** \retcode #CFE_EVS_APP_ILLEGAL_APP_ID \retdesc \copydoc CFE_EVS_APP_ILLEGAL_APP_ID \endcode -** \retstmt Any of the error codes from #CFE_ES_GetAppID \endstmt -** \retstmt Any of the error codes from #CFE_ES_PutPoolBuf \endstmt -** \endreturns -** -** \sa #CFE_EVS_Register -** -**/ -int32 CFE_EVS_Unregister( void ); - -/** -** \brief Generate a software event. -** -** \par Description -** This routine generates a software event message. If the EventID is not filtered, -** the event will be sent as a software bus message, optionally logged in the local -** event log, and optionally sent as an ASCII text string out the enabled output port(s). -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] EventID A numeric literal used to uniquely identify an application event. -** The \c EventID is defined and supplied by the application sending the event. -** -** \param[in] EventType A numeric literal used to classify an event, one of: -** \arg #CFE_EVS_DEBUG -** \arg #CFE_EVS_INFORMATION -** \arg #CFE_EVS_ERROR -** \arg #CFE_EVS_CRITICAL -** -** \param[in] Spec A pointer to a null terminated text string describing the output format -** for the event. This is the same type of format string used for the ANSI -** \c printf function. Nominally the post-conversion string is limited to 80 -** characters, but this limit is configurable through the parameter -** #CFE_EVS_MAX_MESSAGE_LENGTH. Characters beyond the limit will be truncated. -** Do not use floating point conversions (%f, %e, %E, %g, and %G) in the format -** string unless your application will be running in a system that supports -** floating point arithmetic. Do not use non-printable characters (\\t, \\n, etc.) -** in the format string; they will mess up the formatting when the events are -** displayed on the ground system. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_EVS_APP_NOT_REGISTERED \retdesc \copydoc CFE_EVS_APP_NOT_REGISTERED \endcode -** \retcode #CFE_EVS_APP_ILLEGAL_APP_ID \retdesc \copydoc CFE_EVS_APP_ILLEGAL_APP_ID \endcode -** \retstmt Any of the error codes from #CFE_ES_GetAppID \endstmt -** \retstmt Any of the error codes from #CFE_SB_SendMsg \endstmt -** \endreturns -** -** \sa #CFE_EVS_SendEventWithAppID, #CFE_EVS_SendTimedEvent -** -**/ -int32 CFE_EVS_SendEvent (uint16 EventID, - uint16 EventType, - const char *Spec, ... ) OS_PRINTF(3,4); - - -/** -** \brief Generate a software event given the specified Application ID. -** -** \par Description -** This routine generates a software event message. If the EventID is not filtered, -** the event will be sent as a software bus message, optionally logged in the local -** event log, and optionally sent as an ASCII text string out the enabled output port(s). -** Note that this function should really only be used from within an API in order to -** preserve the context of an Application's event. In general, #CFE_EVS_SendEvent should be used. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] EventID A numeric literal used to uniquely identify an application event. -** The \c EventID is defined and supplied by the application sending the event. -** -** \param[in] EventType A numeric literal used to classify an event, one of: -** \arg #CFE_EVS_DEBUG -** \arg #CFE_EVS_INFORMATION -** \arg #CFE_EVS_ERROR -** \arg #CFE_EVS_CRITICAL -** -** \param[in] AppID The Application ID from which the event message should appear. -** -** \param[in] Spec A pointer to a null terminated text string describing the output format -** for the event. This is the same type of format string used for the ANSI -** \c printf function. Nominally the post-conversion string is limited to 80 -** characters, but this limit is configurable through the parameter -** #CFE_EVS_MAX_MESSAGE_LENGTH. Characters beyond the limit will be truncated. -** Do not use floating point conversions (%f, %e, %E, %g, and %G) in the format -** string unless your application will be running in a system that supports -** floating point arithmetic. Do not use non-printable characters (\\t, \\n, etc.) -** in the format string; they will mess up the formatting when the events are -** displayed on the ground system. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_EVS_APP_NOT_REGISTERED \retdesc \copydoc CFE_EVS_APP_NOT_REGISTERED \endcode -** \retcode #CFE_EVS_APP_ILLEGAL_APP_ID \retdesc \copydoc CFE_EVS_APP_ILLEGAL_APP_ID \endcode -** \retstmt Any of the error codes from #CFE_ES_GetAppID \endstmt -** \retstmt Any of the error codes from #CFE_SB_SendMsg \endstmt -** \endreturns -** -** \sa #CFE_EVS_SendEvent, #CFE_EVS_SendTimedEvent -** -**/ -int32 CFE_EVS_SendEventWithAppID (uint16 EventID, - uint16 EventType, - uint32 AppID, - const char *Spec, ... ) OS_PRINTF(4,5); - - -/** -** \brief Generate a software event with a specific time tag. -** -** \par Description -** This routine is the same as CFE_EVS_SendEvent except that the caller specifies the event time -** instead of having the EVS use the current spacecraft time. This routine should be used in -** situations where an error condition is detected at one time, but the event message is reported -** at a later time. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] Time The time to include in the event. This will usually be a time returned -** by the function #CFE_TIME_GetTime(). -** -** \param[in] EventID A numeric literal used to uniquely identify an application event. -** The \c EventID is defined and supplied by the application sending the event. -** -** \param[in] EventType A numeric literal used to classify an event, one of: -** \arg #CFE_EVS_DEBUG -** \arg #CFE_EVS_INFORMATION -** \arg #CFE_EVS_ERROR -** \arg #CFE_EVS_CRITICAL -** -** \param[in] Spec A pointer to a null terminated text string describing the output format -** for the event. This is the same type of format string used for the ANSI -** \c printf function. Nominally the post-conversion string is limited to 80 -** characters, but this limit is configurable through the parameter -** #CFE_EVS_MAX_MESSAGE_LENGTH. Characters beyond the limit will be truncated. -** Do not use floating point conversions (%f, %e, %E, %g, and %G) in the format -** string unless your application will be running in a system that supports -** floating point arithmetic. Do not use non-printable characters (\\t, \\n, etc.) -** in the format string; they will mess up the formatting when the events are -** displayed on the ground system. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_EVS_APP_NOT_REGISTERED \retdesc \copydoc CFE_EVS_APP_NOT_REGISTERED \endcode -** \retcode #CFE_EVS_APP_ILLEGAL_APP_ID \retdesc \copydoc CFE_EVS_APP_ILLEGAL_APP_ID \endcode -** \retstmt Any of the error codes from #CFE_ES_GetAppID \endstmt -** \retstmt Any of the error codes from #CFE_SB_SendMsg \endstmt -** \endreturns -** -** \sa #CFE_EVS_SendEvent, #CFE_EVS_SendEventWithAppID -** -**/ -int32 CFE_EVS_SendTimedEvent (CFE_TIME_SysTime_t Time, - uint16 EventID, - uint16 EventType, - const char *Spec, ... ) OS_PRINTF(4,5); - - -/** -** \brief Resets the calling application's event filter for a single event ID. -** -** \par Description -** The effect of resetting an event filter depends on the filter scheme. -** The #CFE_EVS_BINARY_FILTER scheme resets the filter counter for the specified Event ID. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] EventID A numeric literal used to uniquely identify an application event. -** The \c EventID is defined and supplied by the application sending the event. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_EVS_APP_NOT_REGISTERED \retdesc \copydoc CFE_EVS_APP_NOT_REGISTERED \endcode -** \retcode #CFE_EVS_APP_ILLEGAL_APP_ID \retdesc \copydoc CFE_EVS_APP_ILLEGAL_APP_ID \endcode -** \retstmt Any of the error codes from #CFE_ES_GetAppID \endstmt -** \endreturns -** -** \sa #CFE_EVS_ResetAllFilters -** -**/ -int32 CFE_EVS_ResetFilter (int16 EventID); - - -/** -** \brief Resets all of the calling application's event filters. -** -** \par Description -** This routine resets all the calling application's event filter counters to zero, providing a -** quick and convenient method for resetting event filters. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_EVS_APP_NOT_REGISTERED \retdesc \copydoc CFE_EVS_APP_NOT_REGISTERED \endcode -** \retcode #CFE_EVS_APP_ILLEGAL_APP_ID \retdesc \copydoc CFE_EVS_APP_ILLEGAL_APP_ID \endcode -** \retstmt Any of the error codes from #CFE_ES_GetAppID \endstmt -** \endreturns -** -** \sa #CFE_EVS_ResetFilter -** -**/ -int32 CFE_EVS_ResetAllFilters ( void ); - - - -#endif /* _cfe_evs_ */ diff --git a/src/components/interface/cFE/cfe_evs_events.h b/src/components/interface/cFE/cfe_evs_events.h deleted file mode 100644 index 383c870e5f..0000000000 --- a/src/components/interface/cFE/cfe_evs_events.h +++ /dev/null @@ -1,704 +0,0 @@ -/* -** -** Filename: cfe_evs_events.h -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA’s Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** -** $Id: cfe_evs_events.h 1.7 2011/06/02 17:06:44GMT-05:00 lwalling Exp $ -** -** Purpose: -** cFE Event Services (EVS) Event IDs -** -** Design Notes: -** -** References: -** Flight Software Branch C Coding Standard Version 1.0a -** $Date: 2011/06/02 17:06:44GMT-05:00 $ -** $Revision: 1.7 $ -** $Log: cfe_evs_events.h $ -** Revision 1.7 2011/06/02 17:06:44GMT-05:00 lwalling -** Updated text and descriptions for Write Application Data to File command events -** Revision 1.6 2011/06/01 17:38:43EDT lwalling -** Update Write Log File and Set Log Mode command events -** Revision 1.5 2011/05/23 15:40:20EDT lwalling -** Update descriptions for event log command events when event log is disabled -** Revision 1.4 2010/10/04 15:25:17EDT jmdagost -** Cleaned up copyright symbol. -** Revision 1.3 2009/07/31 19:54:05EDT aschoeni -** added length check error message and changed reported bitmask lengths -** Revision 1.2 2009/07/28 17:16:33EDT aschoeni -** Added event message when filtering limit is reached. -** Revision 1.1 2008/04/17 08:05:21EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.13 2007/07/18 15:48:00EDT njyanchik -** Jonathan added text into each error event in the two functions that write files (WriteLog and WriteAppData), as well as updated the doxygen comments in the header file -** Revision 1.11 2007/06/02 10:10:12EDT dlkobe -** Added doxygen comments for User's Guides -** Revision 1.10 2007/05/23 11:21:59EDT dlkobe -** Added doxygen formatting -** Revision 1.9 2007/05/07 10:42:03EDT njyanchik -** I added a sending of an Event message from EVS on the first time an EVS-unregistered -** application tries to send an event message. A system log message is also written -** Revision 1.8 2007/03/05 14:08:43EST njyanchik -** This CP fixes the fact that there were multiple event messages using the same event ID, but -** using different (but similar) event text. The issue was fixed by making all the text generic, and -** providing a command code parameter that specified what command the message was comming -** from. -*/ - -#ifndef _cfe_evs_events_ -#define _cfe_evs_events_ - -/* Event Service event ID's */ - -/** \brief 'No-op command' -** \event 'No-op command' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always automatically issued in response -** to a cFE Event Services \link #CFE_EVS_NO_OPERATION_CC NO-OP command \endlink -**/ -#define CFE_EVS_NOOP_EID 0 /* Noop event identifier */ - -/** \brief 'cFE EVS Initialized' -** \event 'cFE EVS Initialized' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always automatically issued when the Event Services -** Task completes its Initialization. -**/ -#define CFE_EVS_STARTUP_EID 1 - -/** \brief 'Write Log File Command Error: OS_write = 0x\%08X, filename = \%s' -** \event 'Write Log File Command Error: OS_write = 0x\%08X, filename = \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a filesystem error occurred while writing the contents of the -** event message log to a file. -** -** The message text identifies the event log filename and specifies the return value, in hex, -** from the system function call. The expected return value is the number of bytes written, -** which in this case should be equal to the size of a #CFE_EVS_Packet_t structure. Error -** codes are negative. -**/ -#define CFE_EVS_ERR_WRLOGFILE_EID 2 - -/** \brief 'Write Log File Command Error: OS_creat = 0x\%08X, filename = \%s' -** \event 'Write Log File Command Error: OS_creat = 0x\%08X, filename = \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a filesystem error occurred when attempting to create the file -** that is to hold the event message log. -** -** The message text identifies the event log filename and specifies the return value, in hex, -** from the system function call. The expected return value is a file handle, which in this case -** should be a relatively small positive number. Error codes are negative. -**/ -#define CFE_EVS_ERR_CRLOGFILE_EID 3 - -/** \brief 'Invalid command packet, Message ID = 0x\%08X' -** \event 'Invalid command packet, Message ID = 0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a message has arrived on -** the cFE Event Services Application's Message Pipe that has a -** Message ID that is neither #CFE_EVS_CMD_MID or #CFE_EVS_SEND_HK_MID. -** Most likely, the cFE Software Bus routing table has become corrupt -** and is sending messages targeted for other Applications to the cFE -** Event Services Application. -** -** The \c ID field in the event message identifies -** the message ID (in hex) that was found in the message. -**/ -#define CFE_EVS_ERR_MSGID_EID 5 - -/** \brief '\%s Event ID \%d not registered for filtering: CC = \%lu' -** \event '\%s Event ID \%d not registered for filtering: CC = \%lu' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when the specified command identifies an Application and Event ID combination -** that is not found in the Events Registry. -** -** The \c \%s string contains the command specified Application Name the \c Event \c ID field -** identifies the command specified EventID (in decimal) that was not found in the Events Registry. -** The \c CC field specifies the Command Code whose processing generated the event message. It can -** be equal to either #CFE_EVS_SET_FILTER_CC, #CFE_EVS_RESET_FILTER_CC, or #CFE_EVS_DELETE_EVENT_FILTER_CC. -**/ -#define CFE_EVS_ERR_EVTIDNOREGS_EID 6 - -/** \brief '\%s not registered with EVS: CC = \%lu' -** \event '\%s not registered with EVS: CC = \%lu' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when the specified command identifies an Application that has not been -** registered with the cFE Event Services. -** -** The \c CC field contains the Command Code whose processing resulted in the generation of the event message. -** Possible values are #CFE_EVS_SET_FILTER_CC, #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC, #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC, -** #CFE_EVS_ENABLE_APP_EVENTS_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC, #CFE_EVS_RESET_APP_COUNTER_CC, #CFE_EVS_RESET_FILTER_CC, -** #CFE_EVS_RESET_ALL_FILTERS_CC, #CFE_EVS_ADD_EVENT_FILTER_CC, or #CFE_EVS_DELETE_EVENT_FILTER_CC. -**/ -#define CFE_EVS_ERR_APPNOREGS_EID 7 - -/** \brief 'Illegal application ID \%d retrieved for \%s: CC = \%lu' -** \event 'Illegal application ID \%d retrieved for \%s: CC = \%lu' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when the specified command identifies an Application whose name is -** found in the Events Registry but does not appear to be properly registered with the cFE Executive Services. -** -** The \c CC field contains the Command Code whose processing resulted in the generation of the event message. -** Possible values are #CFE_EVS_SET_FILTER_CC, #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC, #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC, -** #CFE_EVS_ENABLE_APP_EVENTS_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC, #CFE_EVS_RESET_APP_COUNTER_CC, #CFE_EVS_RESET_FILTER_CC, -** #CFE_EVS_RESET_ALL_FILTERS_CC, #CFE_EVS_ADD_EVENT_FILTER_CC, or #CFE_EVS_DELETE_EVENT_FILTER_CC. -**/ -#define CFE_EVS_ERR_ILLAPPIDRANGE_EID 8 - -/** \brief 'Unable to retrieve application ID for \%s: CC = \%lu' -** \event 'Unable to retrieve application ID for \%s: CC = \%lu' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when the specified command contains an Application name that is -** apparently found in the Events Registry but does not appear to be registered with the cFE Executive Services. -** -** The \c CC field contains the Command Code whose processing resulted in the generation of the event message. -** Possible values are #CFE_EVS_SET_FILTER_CC, #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC, #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC, -** #CFE_EVS_ENABLE_APP_EVENTS_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC, #CFE_EVS_RESET_APP_COUNTER_CC, #CFE_EVS_RESET_FILTER_CC, -** #CFE_EVS_RESET_ALL_FILTERS_CC, #CFE_EVS_ADD_EVENT_FILTER_CC, or #CFE_EVS_DELETE_EVENT_FILTER_CC. -**/ -#define CFE_EVS_ERR_NOAPPIDFOUND_EID 9 - -/** \brief 'Set Event Format Mode Command: Invalid Event Format Mode = 0x\%02x' -** \event 'Set Event Format Mode Command: Invalid Event Format Mode = 0x\%02x' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a "Set Event Format Mode" command -** message has arrived and the #CFE_EVS_ModeCmd_t::Mode field is equal to -** neither #CFE_EVS_SHORT_FORMAT or #CFE_EVS_LONG_FORMAT. These are the -** only allowed values for the mode field. -** -** The \c Mode field in the event message identifies -** the Mode value (in hex) that was found in the message. -**/ -#define CFE_EVS_ERR_ILLEGALFMTMOD_EID 10 - -/** \brief 'Add Filter Command: number of registered filters has reached max = \%d' -** \event 'Add Filter Command: number of registered filters has reached max = \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of an "Add Filter" command -** and the specified Application has already reached the maximum number of -** filters allowed (#CFE_EVS_MAX_EVENT_FILTERS). -** -** The \c max field in the event message identifies the maximum number of -** event filters allowed per Application. This value should be equal to -** the configuration parameter #CFE_EVS_MAX_EVENT_FILTERS. -**/ -#define CFE_EVS_ERR_MAXREGSFILTER_EID 11 - -/** \brief 'Write App Data Command Error: OS_write = 0x\%08X, filename = \%s' -** \event 'Write App Data Command Error: OS_write = 0x\%08X, filename = \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a filesystem error occurred while writing the contents of the -** event registry to a file. -** -** The message text identifies the registry filename and specifies the return value, in hex, -** from the system function call. The expected return value is the number of bytes written, -** which in this case should be equal to the size of a #CFE_EVS_AppDataFile_t structure. Error -** codes are negative. -**/ -#define CFE_EVS_ERR_WRDATFILE_EID 12 - -/** \brief 'Write App Data Command Error: OS_creat = 0x\%08X, filename = \%s' -** \event 'Write App Data Command Error: OS_creat = 0x\%08X, filename = \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a filesystem error occurred when attempting to create the file -** that is to hold the event registry data. -** -** The message text identifies the registry filename and specifies the return value, in hex, -** from the system function call. The expected return value is a file handle, which in this case -** should be a relatively small positive number. Error codes are negative. -**/ -#define CFE_EVS_ERR_CRDATFILE_EID 13 - -/** \brief 'Invalid command code -- ID = 0x\%08x, CC = \%d' -** \event 'Invalid command code -- ID = 0x\%08x, CC = \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a message with the #CFE_EVS_CMD_MID -** message ID has arrived but whose Command Code is not one of the specified -** accepted command codes specified. This problem is most likely to occur when: -** -# A Message ID meant for another Application became corrupted and was -** set equal to #CFE_EVS_CMD_MID. -** -# The Command Code field in the Message became corrupted. -** -# The command database at the ground station has been corrupted. -** -** The \c ID field in the event message specifies the Message ID (in hex) and the -** \c CC field specifies the Command Code (in decimal) found in the message. -**/ -#define CFE_EVS_ERR_CC_EID 15 - -/** \brief 'Reset Counters Command Received' -** \event 'Reset Counters Command Received' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is always automatically issued in response -** to a cFE Event Services Reset Counters command -**/ -#define CFE_EVS_RSTCNT_EID 16 - -/** \brief 'Set Filter Mask Command Received with AppName=\%s, EventID=0x\%08x, Mask=0x\%04x' -** \event 'Set Filter Mask Command Received with AppName=\%s, EventID=0x\%08x, Mask=0x\%04x' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is issued upon successful processing of a Set Filter Mask command. -** -** The \c AppName field identifies the Application whose Filter Mask has been changed. -** The \c EventID field identifies the Event whose Filter Mask has been changed. -** The \c Mask field identifies the new Mask value associated with the specified event. -**/ -#define CFE_EVS_SETFILTERMSK_EID 17 - -/** \brief 'Enable Ports Command Received with Port Bit Mask = 0x\%02x' -** \event 'Enable Ports Command Received with Port Bit Mask = 0x\%02x' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is issued upon successful processing of the "Enable Ports" command. -** -** The \c Mask field identifies the ports that are enabled. -** Mask bits are defined by #CFE_EVS_PORT1_BIT, #CFE_EVS_PORT2_BIT, #CFE_EVS_PORT3_BIT and #CFE_EVS_PORT4_BIT. -**/ -#define CFE_EVS_ENAPORT_EID 18 - -/** \brief 'Disable Ports Command Received with Port Bit Mask = 0x\%02x' -** \event 'Disable Ports Command Received with Port Bit Mask = 0x\%02x' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is issued upon successful processing of the "Disable Ports" command. -** -** The \c Mask field identifies (in hex) the ports are to be disabled. -** Mask bits are defined by #CFE_EVS_PORT1_BIT, #CFE_EVS_PORT2_BIT, #CFE_EVS_PORT3_BIT and #CFE_EVS_PORT4_BIT. -**/ -#define CFE_EVS_DISPORT_EID 19 - -/** \brief 'Enable Event Type Command Received with Event Type Bit Mask = 0x\%02x' -** \event 'Enable Event Type Command Received with Event Type Bit Mask = 0x\%02x' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is issued upon successful processing of the "Enable Event Type" command. -** -** The \c Mask field identifies the Event Types that are enabled. -** Mask bits are defined by #CFE_EVS_DEBUG_BIT, #CFE_EVS_INFORMATION_BIT, -** #CFE_EVS_ERROR_BIT and #CFE_EVS_CRITICAL_BIT. -**/ -#define CFE_EVS_ENAEVTTYPE_EID 20 - -/** \brief 'Disable Event Type Command Received with Event Type Bit Mask = 0x\%02x' -** \event 'Disable Event Type Command Received with Event Type Bit Mask = 0x\%02x' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is issued upon successful processing of the "Disable Event Type" command. -** -** The \c Mask field identifies the Event Types that are disabled. -** Mask bits are defined by #CFE_EVS_DEBUG_BIT, #CFE_EVS_INFORMATION_BIT, -** #CFE_EVS_ERROR_BIT and #CFE_EVS_CRITICAL_BIT. -**/ -#define CFE_EVS_DISEVTTYPE_EID 21 - -/** \brief 'Set Event Format Mode Command Received with Mode = 0x\%02x' -** \event 'Set Event Format Mode Command Received with Mode = 0x\%02x' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon successful completion of the "Set Event Format Mode" command. -** -** The \c Mode field contains the newly chosen Event Format Mode (specified in hex). Acceptable values -** for this parameter are: #CFE_EVS_SHORT_FORMAT or #CFE_EVS_LONG_FORMAT -**/ -#define CFE_EVS_SETEVTFMTMOD_EID 22 - -/** \brief 'Enable App Event Type Command Received with AppName = \%s, EventType Bit Mask = 0x\%02x' -** \event 'Enable App Event Type Command Received with AppName = \%s, EventType Bit Mask = 0x\%02x' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon successful completion of the "Enable Application Event Types" command. -** -** The \c AppName field identifies the Application whose Event Type Enable status has changed and the -** \c Mask field specifies (in hex) the Event Types that have been enabled. -** Mask bits are defined by #CFE_EVS_DEBUG_BIT, #CFE_EVS_INFORMATION_BIT, -** #CFE_EVS_ERROR_BIT and #CFE_EVS_CRITICAL_BIT. -**/ -#define CFE_EVS_ENAAPPEVTTYPE_EID 23 - -/** \brief 'Disable App Event Type Command Received with AppName = \%s, EventType Bit Mask = 0x\%02x' -** \event 'Disable App Event Type Command Received with AppName = \%s, EventType Bit Mask = 0x\%02x' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon successful completion of the "Disable Application Event Types" command. -** -** The \c AppName field identifies the Application whose Event Type Disable status has changed and the -** \c Mask field specifies (in hex) the Event Types that have been disabled. -** Mask bits are defined by #CFE_EVS_DEBUG_BIT, #CFE_EVS_INFORMATION_BIT, -** #CFE_EVS_ERROR_BIT and #CFE_EVS_CRITICAL_BIT. -**/ -#define CFE_EVS_DISAPPENTTYPE_EID 24 - -/** \brief 'Enable App Events Command Received with AppName = \%s' -** \event 'Enable App Events Command Received with AppName = \%s' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon successful completion of the "Enable Application Events" command. -** -** The \c AppName field identifies the Application whose Events have been Enabled. -**/ -#define CFE_EVS_ENAAPPEVT_EID 25 - -/** \brief 'Disable App Events Command Received with AppName = \%s' -** \event 'Disable App Events Command Received with AppName = \%s' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon successful completion of the "Disable Application Events" command. -** -** The \c AppName field identifies the Application whose Events have been Disabled. -**/ -#define CFE_EVS_DISAPPEVT_EID 26 - -/** \brief 'Reset Event Counter Command Received with AppName = \%s' -** \event 'Reset Event Counter Command Received with AppName = \%s' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon successful completion of the "Reset Application Event Counter" command. -** -** The \c AppName field identifies the Application whose Event Counter has been reset. -**/ -#define CFE_EVS_RSTEVTCNT_EID 27 - -/** \brief 'Reset Filter Command Received with AppName = \%s, EventID = 0x\%08x' -** \event 'Reset Filter Command Received with AppName = \%s, EventID = 0x\%08x' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon successful completion of the "Reset Application Event Message Filter" command. -** -** The \c AppName field identifies the Application whose Event Message Filter has been reset and -** the \c EventID field identifies the specific event message whose filter has been reset. -**/ -#define CFE_EVS_RSTFILTER_EID 28 - -/** \brief 'Reset All Filters Command Received with AppName = \%s' -** \event 'Reset All Filters Command Received with AppName = \%s' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon successful completion of the "Reset Application Event Message Filters" command. -** -** The \c AppName field identifies the Application whose entire set of Event Filters has been reset. -**/ -#define CFE_EVS_RSTALLFILTER_EID 29 - -/** \brief 'Add Filter Command Received with AppName = \%s, EventID = 0x\%08x, Mask = 0x\%04x' -** \event 'Add Filter Command Received with AppName = \%s, EventID = 0x\%08x, Mask = 0x\%04x' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon successful completion of the "Add Filter" command. -** -** The \c AppName field identifies the Application who is getting the new filter, the \c EventID field -** identifies the Event Identifier, in hex, that is getting the filter, and the \c Mask field specifies, in hex, -** what the binary filter mask has been set to. -**/ -#define CFE_EVS_ADDFILTER_EID 30 - -/** \brief 'Delete Filter Command Received with AppName = \%s, EventID = 0x\%08x' -** \event 'Delete Filter Command Received with AppName = \%s, EventID = 0x\%08x' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon successful completion of the "Delete Filter" command. -** -** The \c AppName field identifies the Application who is getting the filter removed, the \c EventID field -** identifies the Event Identifier, in hex, whose filter is being deleted. -**/ -#define CFE_EVS_DELFILTER_EID 31 - -/** \brief 'Write App Data Command: \%d application data entries written to \%s' -** \event 'Write App Data Command: \%d application data entries written to \%s' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon successful completion of the -** \link #CFE_EVS_FILE_WRITE_APP_DATA_CC "Write Event Services Application Information to File" \endlink command. -** -** The message text identifies the event log filename and specifies the number, in decimal, -** of events written to the file. -**/ -#define CFE_EVS_WRDAT_EID 32 - -/** \brief 'Write Log File Command: \%d event log entries written to \%s' -** \event 'Write Log File Command: \%d event log entries written to \%s' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon successful completion of the -** \link #CFE_EVS_FILE_WRITE_LOG_DATA_CC "Write Event Log to File" \endlink command. -** -** The message text identifies the event log filename and specifies the number, in decimal, -** of events written to the file. -**/ -#define CFE_EVS_WRLOG_EID 33 - -/** \brief 'Set Log Mode Command: Event Log is Disabled' -** \event 'Set Log Mode Command: Event Log is Disabled' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of a "Set Log Mode" -** command when the use of the Event Log has been disabled. To enable -** the Event Log, the cFE code must be compiled for the target with -** the \b CFE_EVS_LOG_ON macro defined. The EVS task must also succeed -** during task initialization in acquiring a pointer to the cFE reset -** area and in the creation of a serializing semaphore to control -** access to the Event Log. -**/ -#define CFE_EVS_NO_LOGSET_EID 34 - -/** \brief 'Clear Log Command: Event Log is Disabled' -** \event 'Clear Log Command: Event Log is Disabled' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of a "Clear Log" -** command when the use of the Event Log has been disabled. To enable -** the Event Log, the cFE code must be compiled for the target with -** the \b CFE_EVS_LOG_ON macro defined. The EVS task must also succeed -** during task initialization in acquiring a pointer to the cFE reset -** area and in the creation of a serializing semaphore to control -** access to the Event Log. -**/ -#define CFE_EVS_NO_LOGCLR_EID 35 - -/** \brief 'Write Log Command: Event Log is Disabled' -** \event 'Write Log Command: Event Log is Disabled' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of a "Write Log" -** command when the use of the Event Log has been disabled. To enable -** the Event Log, the cFE code must be compiled for the target with -** the \b CFE_EVS_LOG_ON macro defined. The EVS task must also succeed -** during task initialization in acquiring a pointer to the cFE reset -** area and in the creation of a serializing semaphore to control -** access to the Event Log. -**/ -#define CFE_EVS_NO_LOGWR_EID 36 - -/** \brief 'Add Filter Command:AppName = \%s, EventID = 0x\%08x is already registered for filtering' -** \event 'Add Filter Command:AppName = \%s, EventID = 0x\%08x is already registered for filtering' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an "Add Filter" command was received specifying an Event ID that has already -** had a filter added. -** -** The \c AppName field identifies the Application whose filter was to be added and the \c EventID field identifies, -** in hex, the Event ID that the command was trying to add a filter for. -**/ -#define CFE_EVS_EVT_FILTERED_EID 37 - -/** \brief 'Set Log Mode Command Error: Log Mode = \%d' -** \event 'Set Log Mode Command Error: Log Mode = \%d' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated when a "Set Log Mode" command is completed successfully. -** -** The event text identifies the Log Mode command argument. Valid Log Mode command -** arguments are: #CFE_EVS_LOG_OVERWRITE or #CFE_EVS_LOG_DISCARD. -**/ -#define CFE_EVS_LOGMODE_EID 38 - -/** \brief 'Set Log Mode Command Error: Log Mode = \%d' -** \event 'Set Log Mode Command Error: Log Mode = \%d -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a "Set Log Mode" command is received that specifies -** an invalid Log Mode command argument. -** -** The event text identifies the invalid Log Mode command argument. Valid Log Mode command -** arguments are: #CFE_EVS_LOG_OVERWRITE or #CFE_EVS_LOG_DISCARD. -**/ -#define CFE_EVS_ERR_LOGMODE_EID 39 - -/** \brief 'Bit Mask = 0x\%X out of range: CC = \%lu' -** \event 'Bit Mask = 0x\%X out of range: CC = \%lu' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when the bit mask passed in is equal to zero or greater than 0x0F, because a -** bit mask of zero does nothing, and a bitmask of greater than 0x0F is invalid. -**/ -#define CFE_EVS_ERR_INVALID_BITMASK_EID 40 - -/** \brief 'App \%s not registered with Event Services. Unable to send event' -** \event 'App \%s not registered with Event Services. Unable to send event' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an event message has been requested to be sent by an Application that -** has not registered itself with cFE Event Services. -**/ -#define CFE_EVS_ERR_UNREGISTERED_EVS_APP 41 - -/** \brief 'Max filter count reached, AppName = \%s, EventID = 0x\%08x: Filter locked until reset' -** \event 'Max filter count reached, AppName = \%s, EventID = 0x\%08x: Filter locked until reset' -** -** \par Type: INFORMATIONAL -** -** \par Cause: -** -** This event message is generated when the filtering count for a specific App and Event ID reaches #CFE_EVS_MAX_FILTER_COUNT -** The filtered event will no longer be received until the reset counter is reset via a -** \link #CFE_EVS_RESET_FILTER_CC "Reset an Event Filter for an Application" \endlink or a -** \link #CFE_EVS_RESET_ALL_FILTERS_CC "Reset All Event Filters for an Application" \endlink -** -** The \c AppName field identifies the Application and the \c EventID field identifies, in hex, the Event ID -** for the filter whose maxium was reached. -**/ -#define CFE_EVS_FILTER_MAX_EID 42 - -/** \brief 'Invalid cmd length: ID = 0x\%X, CC = \%d, Exp Len = \%d, Len = \%d' -** \event 'Invalid cmd length: ID = 0x\%X, CC = \%d, Exp Len = \%d, Len = \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a message with the #CFE_EVS_CMD_MID -** message ID has arrived but whose packet length does not match the expected -** length for the specified command code. -** -** The \c ID field in the event message specifies the Message ID (in hex), the \c CC field -** specifies the Command Code (in decimal), the \c Exp Len field specified the Expected -** Length (in decimal ), and \c Len specifies the message Length (in decimal) -** found in the message. -**/ -#define CFE_EVS_LEN_ERR_EID 43 - -#endif /* _cfe_evs_events_ */ - diff --git a/src/components/interface/cFE/cfe_evs_msg.h b/src/components/interface/cFE/cfe_evs_msg.h deleted file mode 100644 index cdbeab9601..0000000000 --- a/src/components/interface/cFE/cfe_evs_msg.h +++ /dev/null @@ -1,1188 +0,0 @@ -/* -** -** Filename: cfe_evs_msg.h -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA’s Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -* -** $Id: cfe_evs_msg.h 1.6 2012/01/10 15:26:15GMT-05:00 jmdagost Exp $ -** -** Title: Event Services Message definition header file Header File -** -** Purpose: -** Unit specification for Event services command codes and data structures. -** -** Design Notes: -** -** References: -** Flight Software Branch C Coding Standard Version 1.0a -** -** $Date: 2012/01/10 15:26:15GMT-05:00 $ -** $Revision: 1.6 $ -** $Log: cfe_evs_msg.h $ -** Revision 1.6 2012/01/10 15:26:15GMT-05:00 jmdagost -** Changed command codes to start at zero for no-op (consistent with other apps). -** Revision 1.5 2011/05/23 15:42:27EDT lwalling -** Change unused 32 bit MemPoolHandle to 8 bit LogEnabled and three 8 bit spares -** Revision 1.4 2010/10/04 15:25:19EDT jmdagost -** Cleaned up copyright symbol. -** Revision 1.3 2009/07/31 19:52:03EDT aschoeni -** padded commands to be even number of bytes -** Revision 1.2 2009/03/04 12:12:38EST rmcgraw -** DCR4715:1 Added bit information to event type cmds and port cmds -** Revision 1.1 2008/04/17 08:05:21EDT ruperera -** Member moved from tlserver to tlserver3 -** Revision 1.10 2007/09/18 14:46:46EDT njyanchik -** Check in the telemetry comments -** Revision 1.9 2007/09/18 14:02:18EDT njyanchik -** add command doxygen comments -** Revision 1.8 2007/07/18 14:09:56EDT njyanchik -** moved 12 #defines to cfe_evs_msg.h because they are needed for commands -** Revision 1.7 2007/07/18 11:53:05EDT njyanchik -** The two structures specified in DCR 4407 were moved to cfe_evs_msg.h -** Revision 1.6 2007/06/07 13:07:45EDT dlkobe -** Added Command and Telemetry doxygen comments to TIME, EVS and SB -** Revision 1.5 2007/05/16 15:32:23EDT dlkobe -** Corrected circular data type dependency -** Revision 1.4 2007/05/16 15:13:38EDT dlkobe -** Added MemPoolHandle members to HK packet -** Revision 1.3 2007/04/27 12:31:05EDT njyanchik -** I changed EVS and TIME to not have a telemetry counter for SB pipe reads in -** the main loop. Instead, I have added a syslog message to state the problem -** Revision 1.2 2007/04/11 10:59:55EDT njyanchik -** Remove the TaskDelay in the main loop for EVS. I also added a counter in -** telemtry that will notify the ground of an error in reading the command pipe. -** Revision 1.1 2007/03/01 11:53:54EST njyanchik -** Initial revision -** Member added to cfe project on tlserver -*/ -#ifndef _cfe_evs_msg_ -#define _cfe_evs_msg_ - -/********************************** Include Files ************************************/ -#include "common_types.h" /* Basic data types */ -#include "cfe_time.h" /* Time library function definitions */ -#include "osapi.h" -#include "cfe_sb.h" -#include "cfe_es.h" - - -/** \name Event Services Command Codes */ -/** \{ */ - -/** \cfeevscmd Event Services No-Op -** -** \par Description -** This command performs no other function than to increment the -** command execution counter. The command may be used to verify -** general aliveness of the Event Services task. -** -** \cfecmdmnemonic \EVS_NOOP -** -** \par Command Structure -** #CFE_TBL_NoArgsCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The #CFE_EVS_NOOP_EID informational event message will -** be generated -** -** \par Error Conditions -** There are no error conditions for this command. If the Event -** Services receives the command, the event is sent (although it -** may be filtered by EVS itself) and the counter is incremented -** unconditionally. -** -** \par Criticality -** None -** -** \sa -*/ -#define CFE_EVS_NO_OPERATION_CC 0 - -/** \cfeevscmd Event Services Reset Counters -** -** \par Description -** This command resets the following counters within the Event -** Services housekeeping telemetry: -** - Command Execution Counter (\EVS_CMDPC) -** - Command Error Counter (\EVS_CMDEC) -** -** \cfecmdmnemonic \EVS_RESETCTRS -** -** \par Command Structure -** #CFE_TBL_NoArgsCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The #CFE_EVS_RSTCNT_EID debug event message will be -** generated -** -** \par Error Conditions -** There are no error conditions for this command. If the Event -** Services receives the command, the event is sent (although it -** may be filtered by EVS) and the counter is incremented -** unconditionally. -** -** \par Criticality -** This command is not inherently dangerous. However, it is -** possible for ground systems and on-board safing procedures -** to be designed such that they react to changes in the counter -** values that are reset by this command. -** -** \sa #CFE_EVS_RESET_APP_COUNTER_CC -*/ -#define CFE_EVS_RESET_COUNTERS_CC 1 - -/** \cfeevscmd Enable Event Type -** -** \par Description -** This command enables the command specified Event Type allowing event -** messages of this type to be sent through Event Service. An Event Type -** is defined to be a classification of an Event Message such as debug, -** informational, error and critical. This command is a global enable of a -** particular event type, it applies to all applications. -** -** \cfecmdmnemonic \EVS_ENAEVENTTYPE -** -** \par Command Structure -** #CFE_EVS_BitMaskCmd_t -** The following bit positions apply to structure member named 'BitMask'. -** Bit 0 - Debug -** Bit 1 - Informational -** Bit 2 - Error -** Bit 3 - Critical -** A one in a bit position means the event type will be enabled (or unfiltered). -** A zero in a bit position means the filtering state is unchanged. -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_ENAEVTTYPE_EID debug message -** -** \par Error Conditions -** This command may fail for the following reason(s): -** -** Invalid Event Type selection -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** Enabling an event type is not particularly hazardous, as the result may -** be turning on necessary event messages and communication to the ground -** system. However, inappropriately enabling an event type could result -** in flooding of the system. -** -** \sa #CFE_EVS_DISABLE_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC, -** #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENTS_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC -*/ -#define CFE_EVS_ENABLE_EVENT_TYPE_CC 2 - -/** \cfeevscmd Disable Event Type -** -** \par Description -** This command disables the command specified Event Type preventing event -** messages of this type to be sent through Event Service. An Event Type -** is defined to be a classification of an Event Message such as debug, -** informational, error and critical. This command is a global disable of a -** particular event type, it applies to all applications. -** -** \cfecmdmnemonic \EVS_DISEVENTTYPE -** -** \par Command Structure -** #CFE_EVS_BitMaskCmd_t -** The following bit positions apply to structure member named 'BitMask'. -** Bit 0 - Debug -** Bit 1 - Informational -** Bit 2 - Error -** Bit 3 - Critical -** A one in a bit position means the event type will be disabled (or filtered). -** A zero in a bit position means the filtering state is unchanged. -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** -** - \b \c \EVS_CMDPC - command execution counter will -** increment - - The generation of #CFE_EVS_DISEVTTYPE_EID debug message -** -** \par Error Conditions -** This command may fail for the following reason(s): -** -** - Invalid Event Type selection - -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** Disabling an event type is not particularly hazardous, as the result -** may be shutting off unnecessary event messages and possible event -** flooding of the system. However, inappropriately disabling an event -** type could result in a loss of critical information and missed -** behavior for the ground system. -** -** \sa #CFE_EVS_ENABLE_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC, -** #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENTS_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC -*/ -#define CFE_EVS_DISABLE_EVENT_TYPE_CC 3 - -/** \cfeevscmd Set Event Format Mode -** -** \par Description -** This command sets the event format mode to the command specified value. -** The event format mode may be either short or long. A short event format -** detaches the Event Data from the event message and only includes the -** following information in the event packet: Processor ID, Application ID, -** Event ID, and Event Type. Refer to section 5.3.3.4 for a description of -** the Event Service event packet contents. Event Data is defined to be data -** describing an Event that is supplied to the cFE Event Service. ASCII text -** strings are used as the primary format for Event Data because heritage -** ground systems use string compares as the basis for their automated alert -** systems. Two systems, ANSR and SERS were looked at for interface -** definitions. The short event format is used to accommodate experiences -** with limited telemetry bandwidth. The long event format includes all event -** information included within the short format along with the Event Data. -** -** \cfecmdmnemonic \EVS_SETEVTFMT -** -** \par Command Structure -** #CFE_EVS_ModeCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_SETEVTFMTMOD_EID debug message -** -** \par Error Conditions -** This command may fail for the following reason(s): -** Invalid SB message (command) length -** Invalid MODE selection -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** -** \par Criticality -** Setting the event format mode is not particularly hazardous, as the -** result may be saving necessary bandwidth. However, inappropriately -** setting the event format mode could result in a loss of information -** and missed behavior for the ground system -** \sa -*/ -#define CFE_EVS_SET_EVENT_FORMAT_MODE_CC 4 - -/** \cfeevscmd Enable Application Event Type -** -** \par Description -** This command enables the command specified event type for the command -** specified application, allowing the application to send event messages -** of the command specified event type through Event Service. An Event -** Type is defined to be a classification of an Event Message such as -** debug, informational, critical, and error. -** Note: In order for this command to take effect, applications must be -** registered for Event Service. -** -** \cfecmdmnemonic \EVS_ENAAPPEVTTYPE -** -** \par Command Structure -** #CFE_EVS_AppNameBitMaskCmd_t -** The following bit positions apply to structure member named 'BitMask'. -** Bit 0 - Debug -** Bit 1 - Informational -** Bit 2 - Error -** Bit 3 - Critical -** A one in a bit position means the event type will be enabled (or -** unfiltered) for the specified application. -** A zero in a bit position means the filtering state is unchanged for -** the specified application. -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_ENAAPPEVTTYPE_EID debug event message -** -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid Event Type Selection -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** -** \par Criticality -** Enabling an application¿s event type is not particularly hazardous, as -** the result may be turning on necessary event messages and -** communication to the ground system. However, inappropriately enabling -** an application's event type could result in flooding of the ground system. -** -** \sa #CFE_EVS_ENABLE_EVENT_TYPE_CC, #CFE_EVS_DISABLE_EVENT_TYPE_CC, -** #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENTS_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC -*/ -#define CFE_EVS_ENABLE_APP_EVENT_TYPE_CC 5 - -/** \cfeevscmd Disable Application Event Type -** -** \par Description -** This command disables the command specified event type for the command -** specified application, preventing the application from sending event -** messages of the command specified event type through Event Service. -** An Event Type is defined to be a classification of an Event Message such -** as debug, informational, critical, and error. Note: In order for this -** command to take effect, applications must be registered for Event Service. -** -** \cfecmdmnemonic \EVS_DISAPPEVTTYPE -** -** \par Command Structure -** #CFE_EVS_AppNameBitMaskCmd_t -** The following bit positions apply to structure member named 'BitMask'. -** Bit 0 - Debug -** Bit 1 - Informational -** Bit 2 - Error -** Bit 3 - Critical -** A one in a bit position means the event type will be disabled (or -** filtered) for the specified application. -** A zero in a bit position means the filtering state is unchanged for -** the specified application. -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_DISAPPENTTYPE_EID debug event message -** - The clearing of the Active Flag in \link #CFE_EVS_AppDataFile_t::ActiveFlag The Active Flag in EVS App Data File \endlink -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid Event Type Selection -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** Disabling an application's event type is not particularly hazardous, -** as the result may be shutting off unnecessary event messages and -** possible event flooding of the system. However, inappropriately -** disabling an application's event type could result in a loss of critical -** information and missed behavior for the ground system. -** -** \sa #CFE_EVS_ENABLE_EVENT_TYPE_CC, #CFE_EVS_DISABLE_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC, -** #CFE_EVS_ENABLE_APP_EVENTS_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC -*/ -#define CFE_EVS_DISABLE_APP_EVENT_TYPE_CC 6 - -/** \cfeevscmd Enable Event Services for an Application -** -** \par Description -** This command enables the command specified application to send events -** through the Event Service. Note: In order for this command to take -** effect, applications must be registered for Event Service. -** -** \cfecmdmnemonic \EVS_ENAAPPEVGEN -** -** \par Command Structure -** #CFE_EVS_AppNameCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_ENAAPPEVT_EID debug event message -** - The setting of the Active Flag in \link #CFE_EVS_AppDataFile_t::ActiveFlag The Active Flag in EVS App Data File \endlink -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Application selected is not registered to receive Event Service -** - Application ID is out of range -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** Enabling an application¿s events is not particularly hazardous, -** as the result may be turning on necessary event messages and -** communication to the ground system. However, inappropriately enabling -** an application's events could result in flooding of the ground system. -** -** \sa #CFE_EVS_ENABLE_EVENT_TYPE_CC, #CFE_EVS_DISABLE_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC, -** #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC -*/ -#define CFE_EVS_ENABLE_APP_EVENTS_CC 7 - -/** \cfeevscmd Disable Event Services for an Application -** -** \par Description -** This command disables the command specified application from sending -** events through Event Service. Note: In order for this command to take -** effect, applications must be registered for Event Service. -** -** \cfecmdmnemonic \EVS_DISAPPEVGEN -** -** \par Command Structure -** #CFE_EVS_AppNameCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_DISAPPEVT_EID debug event message -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Application selected is not registered to receive Event Service -** - Application ID is out of range -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** Disabling an application's events is not particularly hazardous, as the -** result may be shutting off unnecessary event messages and possible event -** flooding of the system. However, inappropriately disabling an -** application's events could result in a loss of critical information and -** missed behavior for the ground system. -** -** \sa #CFE_EVS_ENABLE_EVENT_TYPE_CC, #CFE_EVS_DISABLE_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC, -** #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC, #CFE_EVS_ENABLE_APP_EVENTS_CC -*/ -#define CFE_EVS_DISABLE_APP_EVENTS_CC 8 - -/** \cfeevscmd Reset Application Event Counters -** -** \par Description -** This command sets the command specified application's event counter to zero. -** Note: In order for this command to take effect, applications must be registered -** for Event Service. -** -** \cfecmdmnemonic \EVS_RSTAPPCTRS -** -** \par Command Structure -** #CFE_EVS_AppNameCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_RSTEVTCNT_EID debug event message -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Application selected is not registered to receive Event Service -** - Application ID is out of range -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** This command is not inherently dangerous. However, it is possible for -** ground systems and on-board safing procedures to be designed such that -** they react to changes in the counter value that is reset by this command. -** -** \sa #CFE_EVS_RESET_COUNTERS_CC -*/ -#define CFE_EVS_RESET_APP_COUNTER_CC 9 - -/** \cfeevscmd Set Application Event Filter -** -** \par Description -** This command sets the command specified application's event filter mask -** to the command specified value for the command specified event. Note: -** In order for this command to take effect, applications must be -** registered for Event Service. -** -** \cfecmdmnemonic \EVS_SETBINFLTRMASK -** -** \par Command Structure -** #CFE_EVS_AppNameEventIDMaskCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_SETFILTERMSK_EID debug event message -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Application selected is not registered to receive Event Service -** - Application ID is out of range -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** Setting an application¿s event filter mask is not particularly hazardous, -** as the result may be shutting off unnecessary event messages and possible -** event flooding of the system. However, inappropriately setting an -** application's event filter mask could result in a loss of critical -** information and missed behavior for the ground system or flooding of the -** ground system. -** -** \sa #CFE_EVS_RESET_FILTER_CC, #CFE_EVS_RESET_ALL_FILTERS_CC, #CFE_EVS_ADD_EVENT_FILTER_CC, #CFE_EVS_DELETE_EVENT_FILTER_CC -*/ -#define CFE_EVS_SET_FILTER_CC 10 - -/** \cfeevscmd Enable Event Services Output Ports -** -** \par Description -** This command enables the command specified port to output event messages -** -** \cfecmdmnemonic \EVS_ENAPORT -** -** \par Command Structure -** #CFE_EVS_BitMaskCmd_t -** The following bit positions apply to structure member named 'BitMask'. -** Bit 0 - Port 1 -** Bit 1 - Port 2 -** Bit 2 - Port 3 -** Bit 3 - Port 4 -** A one in a bit position means the port will be enabled. -** A zero in a bit position means the port state is unchanged. -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_ENAPORT_EID debug event message -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Invalid PORT selection -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** None. -** -** \sa #CFE_EVS_DISABLE_PORTS_CC -*/ -#define CFE_EVS_ENABLE_PORTS_CC 11 - -/** \cfeevscmd Disable Event Services Output Ports -** -** \par Description -** This command disables the specified port from outputting event messages. -** -** \cfecmdmnemonic \EVS_DISPORT -** -** \par Command Structure -** #CFE_EVS_BitMaskCmd_t -** The following bit positions apply to structure member named 'BitMask'. -** Bit 0 - Port 1 -** Bit 1 - Port 2 -** Bit 2 - Port 3 -** Bit 3 - Port 4 -** A one in a bit position means the port will be disabled. -** A zero in a bit position means the port state is unchanged. -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_DISPORT_EID debug event message -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Invalid PORT selection -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** None. -** -** \sa #CFE_EVS_ENABLE_PORTS_CC -*/ -#define CFE_EVS_DISABLE_PORTS_CC 12 - -/** \cfeevscmd Reset an Event Filter for an Application -** -** \par Description -** This command resets the command specified application's event filter for -** the command specified event ID. Note: In order for this command to take -** effect, applications must be registered for Event Service. -** -** \cfecmdmnemonic \EVS_RSTBINFLTRCTR -** -** \par Command Structure -** #CFE_EVS_AppNameEventIDCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_RSTFILTER_EID debug event message -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Application selected is not registered to receive Event Service -** - Application ID is out of range -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** None. -** -** \sa #CFE_EVS_SET_FILTER_CC, #CFE_EVS_RESET_ALL_FILTERS_CC, #CFE_EVS_ADD_EVENT_FILTER_CC, #CFE_EVS_DELETE_EVENT_FILTER_CC -*/ -#define CFE_EVS_RESET_FILTER_CC 13 - -/** \cfeevscmd Reset All Event Filters for an Application -** -** \par Description -** This command resets all of the command specified applications event -** filters. Note: In order for this command to take effect, applications -** must be registered for Event Service. -** -** \cfecmdmnemonic \EVS_RSTALLFLTRS -** -** \par Command Structure -** #CFE_EVS_AppNameCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_RSTALLFILTER_EID debug event message -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Application selected is not registered to receive Event Service -** - Application ID is out of range -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** None. -** -** \sa #CFE_EVS_SET_FILTER_CC, #CFE_EVS_RESET_FILTER_CC, #CFE_EVS_ADD_EVENT_FILTER_CC, #CFE_EVS_DELETE_EVENT_FILTER_CC -*/ -#define CFE_EVS_RESET_ALL_FILTERS_CC 14 - -/** \cfeevscmd Add Application Event Filter -** -** \par Description -** This command adds the given filter for the given application identifier and event identifier. -** Note: In order for this command to take effect, applications -** must be registered for Event Service. -** -** \cfecmdmnemonic \EVS_ADDEVTFLTR -** -** \par Command Structure -** #CFE_EVS_AppNameEventIDMaskCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_ADDFILTER_EID debug event message -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Application selected is not registered to receive Event Service -** - Application ID is out of range -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** None. -** -** \sa #CFE_EVS_SET_FILTER_CC, #CFE_EVS_RESET_FILTER_CC, #CFE_EVS_RESET_ALL_FILTERS_CC, #CFE_EVS_DELETE_EVENT_FILTER_CC -*/ -#define CFE_EVS_ADD_EVENT_FILTER_CC 15 - -/** \cfeevscmd Delete Application Event Filter -** -** \par Description -** This command removes the given filter for the given application identifier and event identifier. -** Note: In order for this command to take effect, applications -** must be registered for Event Service. -** -** \cfecmdmnemonic \EVS_DELEVTFLTR -** -** \par Command Structure -** #CFE_EVS_AppNameEventIDMaskCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_DELFILTER_EID debug event message -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Application selected is not registered to receive Event Service -** - Application ID is out of range -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** None. -** -** \sa #CFE_EVS_SET_FILTER_CC, #CFE_EVS_RESET_FILTER_CC, #CFE_EVS_RESET_ALL_FILTERS_CC, #CFE_EVS_ADD_EVENT_FILTER_CC -*/ -#define CFE_EVS_DELETE_EVENT_FILTER_CC 16 - -/** \cfeevscmd Write Event Services Application Information to File -** -** \par Description -** This command writes all application data to a file for all applications that -** have registered with the EVS. The application data includes the Application ID, -** Active Flag, Event Count, Event Types Active Flag, and Filter Data. -** -** \cfecmdmnemonic \EVS_WRITEAPPDATA2FILE -** -** \par Command Structure -** #CFE_EVS_AppDataCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_WRDAT_EID debug event message -** - The generation of the file written to -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** Writing a file is not particularly hazardous, but if proper file management is not -** taken, then the file system can fill up if this command is used repeatedly. -** -** \sa #CFE_EVS_FILE_WRITE_LOG_DATA_CC, #CFE_EVS_SET_LOG_MODE_CC -*/ -#define CFE_EVS_FILE_WRITE_APP_DATA_CC 17 - -/** \cfeevscmd Write Event Log to File -** -** \par Description -** This command requests the Event Service to generate a file containing -** the contents of the local event log. -** -** \cfecmdmnemonic \EVS_WRITELOG2FILE -** -** \par Command Structure -** #CFE_EVS_LogFileCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_WRLOG_EID debug event message -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** Writing a file is not particularly hazardous, but if proper file management is not -** taken, then the file system can fill up if this command is used repeatedly. -** -** \sa #CFE_EVS_FILE_WRITE_APP_DATA_CC, #CFE_EVS_SET_LOG_MODE_CC, #CFE_EVS_CLEAR_LOG_CC -*/ -#define CFE_EVS_FILE_WRITE_LOG_DATA_CC 18 - -/** \cfeevscmd Set Logging Mode -** -** \par Description -** This command sets the logging mode to the command specified value. -** -** \cfecmdmnemonic \EVS_SETLOGMODE -** -** \par Command Structure -** #CFE_EVS_ModeCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** - The generation of #CFE_EVS_LOGMODE_EID debug event message -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Invalid MODE selected -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** Setting the event logging mode is not particularly hazardous, as the -** result may be saving valuable event data. However, inappropriately -** setting the log mode could result in a loss of critical information. -** Note: the event log is a back-up log to the on-board recorder. -** -** \sa #CFE_EVS_FILE_WRITE_LOG_DATA_CC, #CFE_EVS_CLEAR_LOG_CC -*/ -#define CFE_EVS_SET_LOG_MODE_CC 19 - -/** \cfeevscmd Clear Event Log -** -** \par Description -** This command clears the contents of the local event log. -** -** \cfecmdmnemonic \EVS_CLRLOG -** -** \par Command Structure -** #CFE_TBL_NoArgsCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** Clearing the local event log is not particularly hazardous, as the -** result may be making available space to record valuable event data. -** However, inappropriately clearing the local event log could result -** in a loss of critical information. Note: the event log is a back-up -** log to the on-board recorder. -** -** \sa #CFE_EVS_FILE_WRITE_LOG_DATA_CC, #CFE_EVS_SET_LOG_MODE_CC -*/ -#define CFE_EVS_CLEAR_LOG_CC 20 -/** \} */ - - -/* Event Message Format Modes */ -#define CFE_EVS_SHORT_FORMAT 0 -#define CFE_EVS_LONG_FORMAT 1 - -/* Event Type bit masks */ -#define CFE_EVS_DEBUG_BIT 0x0001 -#define CFE_EVS_INFORMATION_BIT 0x0002 -#define CFE_EVS_ERROR_BIT 0x0004 -#define CFE_EVS_CRITICAL_BIT 0x0008 - -/* Output Port bit masks */ -#define CFE_EVS_PORT1_BIT 0x0001 -#define CFE_EVS_PORT2_BIT 0x0002 -#define CFE_EVS_PORT3_BIT 0x0004 -#define CFE_EVS_PORT4_BIT 0x0008 - -/* EVS Log Modes */ -#define CFE_EVS_LOG_OVERWRITE 0 -#define CFE_EVS_LOG_DISCARD 1 - -/****************** Structure Definitions *********************/ - -/** -** \brief Write Event Log to File Command -** -** For command details, see #CFE_EVS_FILE_WRITE_LOG_DATA_CC -** -**/ -typedef struct { - char LogFilename[OS_MAX_PATH_LEN]; /**< \brief Filename where log data is to be written */ -} CFE_EVS_LogFileCmd_Payload_t; - -typedef struct { - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - CFE_EVS_LogFileCmd_Payload_t Payload; -} CFE_EVS_LogFileCmd_t; - -/** -** \brief Write Event Services Application Information to File Command -** -** For command details, see #CFE_EVS_FILE_WRITE_APP_DATA_CC -** -**/ -typedef struct { - char AppDataFilename[OS_MAX_PATH_LEN]; /**< \brief Filename where applicaton data is to be written */ -} CFE_EVS_AppDataCmd_Payload_t; - -typedef struct { - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - CFE_EVS_AppDataCmd_Payload_t Payload; -} CFE_EVS_AppDataCmd_t; - -/** -** \brief Set Event Format Mode or Set Log Mode Commands -** -** For command details, see #CFE_EVS_SET_EVENT_FORMAT_MODE_CC and/or #CFE_EVS_SET_LOG_MODE_CC -** -**/ -typedef struct { - uint8 Mode; /**< \brief Mode to use in the command*/ - uint8 Spare; /**< \brief Pad to even byte*/ -} CFE_EVS_ModeCmd_Payload_t; - -typedef struct { - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - CFE_EVS_ModeCmd_Payload_t Payload; -} CFE_EVS_ModeCmd_t; - -/** -** \brief Enable/Disable Events or Ports Commands -** -** For command details, see #CFE_EVS_ENABLE_EVENT_TYPE_CC, #CFE_EVS_DISABLE_EVENT_TYPE_CC, -** #CFE_EVS_ENABLE_PORTS_CC and/or #CFE_EVS_DISABLE_PORTS_CC -** -**/ -typedef struct { - uint8 BitMask; /**< \brief BitMask to use in the command */ - uint8 Spare; /**< \brief Pad to even byte*/ -} CFE_EVS_BitMaskCmd_Payload_t; - -typedef struct { - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - CFE_EVS_BitMaskCmd_Payload_t Payload; -} CFE_EVS_BitMaskCmd_t; - -/** -** \brief Enable/Disable Application Events or Reset One or All Filter Counters -** -** For command details, see #CFE_EVS_ENABLE_APP_EVENTS_CC, #CFE_EVS_DISABLE_APP_EVENTS_CC, -** #CFE_EVS_RESET_APP_COUNTER_CC and/or #CFE_EVS_RESET_ALL_FILTERS_CC -** -**/ -typedef struct { - char AppName[OS_MAX_API_NAME]; /**< \brief Application name to use in the command*/ -} CFE_EVS_AppNameCmd_Payload_t; - -typedef struct { - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - CFE_EVS_AppNameCmd_Payload_t Payload; -} CFE_EVS_AppNameCmd_t; - -/** -** \brief Reset an Event Filter for an Application -** -** For command details, see #CFE_EVS_RESET_FILTER_CC -** -**/ -typedef struct { - char AppName[OS_MAX_API_NAME]; /**< \brief Application name to use in the command*/ - uint16 EventID; /**< \brief Event ID to use in the command*/ -} CFE_EVS_AppNameEventIDCmd_Payload_t; - -typedef struct { - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - CFE_EVS_AppNameEventIDCmd_Payload_t Payload; -} CFE_EVS_AppNameEventIDCmd_t; - -/** -** \brief Enable/Disable an Event Type for an Application -** -** For command details, see #CFE_EVS_ENABLE_APP_EVENT_TYPE_CC and/or #CFE_EVS_DISABLE_APP_EVENT_TYPE_CC -** -**/ -typedef struct { - char AppName[OS_MAX_API_NAME]; /**< \brief Application name to use in the command*/ - uint8 BitMask; /**< \brief BitMask to use in the command*/ - uint8 Spare; /**< \brief Pad to even byte*/ -} CFE_EVS_AppNameBitMaskCmd_Payload_t; - -typedef struct { - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - CFE_EVS_AppNameBitMaskCmd_Payload_t Payload; -} CFE_EVS_AppNameBitMaskCmd_t; - -/** -** \brief Set, Add or Delete an Event Filter for an Application -** -** For command details, see #CFE_EVS_SET_FILTER_CC, #CFE_EVS_ADD_EVENT_FILTER_CC -** and/or #CFE_EVS_DELETE_EVENT_FILTER_CC -** -**/ -typedef struct { - char AppName[OS_MAX_API_NAME]; /**< \brief Application name to use in the command*/ - uint16 EventID; /**< \brief Event ID to use in the command*/ - uint16 Mask; /**< \brief Mask to use in the command */ -} CFE_EVS_AppNameEventIDMaskCmd_Payload_t; - -typedef struct { - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - CFE_EVS_AppNameEventIDMaskCmd_Payload_t Payload; -} CFE_EVS_AppNameEventIDMaskCmd_t; - -/*************************************************************************/ -/**********************************/ -/* Telemetry Message Data Formats */ -/**********************************/ -typedef struct { - uint32 AppID; /**< \cfetlmmnemonic \EVS_APPID - \brief Numerical application identifier */ - uint16 AppMessageSentCounter; /**< \cfetlmmnemonic \EVS_APPMSGSENTC - \brief Application message sent counter */ - uint8 AppEnableStatus; /**< \cfetlmmnemonic \EVS_APPENASTAT - \brief Application event service enable status */ - uint8 Padding; /**< \cfetlmmnemonic \EVS_SPARE2ALIGN3 - \brief Padding for 32 bit boundary */ - -} CFE_EVS_AppTlmData_t; - - -/** -** \cfeevstlm Event Services Housekeeping Telemetry Packet -**/ -typedef struct { - uint8 CommandCounter; /**< \cfetlmmnemonic \EVS_CMDPC - \brief EVS Command Counter */ - uint8 CommandErrCounter; /**< \cfetlmmnemonic \EVS_CMDEC - \brief EVS Command Error Counter */ - uint8 MessageFormatMode; /**< \cfetlmmnemonic \EVS_MSGFMTMODE - \brief Event message format mode (short/long) */ - uint8 MessageTruncCounter; /**< \cfetlmmnemonic \EVS_MSGTRUNC - \brief Event message truncation counter */ - - uint8 UnregisteredAppCounter; /**< \cfetlmmnemonic \EVS_UNREGAPPC - \brief Unregistered application message send counter */ - uint8 OutputPort; /**< \cfetlmmnemonic \EVS_OUTPUTPORT - \brief Output port mask */ - uint8 LogFullFlag; /**< \cfetlmmnemonic \EVS_LOGFULL - \brief Local event log full flag */ - uint8 LogMode; /**< \cfetlmmnemonic \EVS_LOGMODE - \brief Local event logging mode (overwrite/discard) */ - - uint16 MessageSendCounter; /**< \cfetlmmnemonic \EVS_MSGSENTC - \brief Event message send counter */ - uint16 LogOverflowCounter; /**< \cfetlmmnemonic \EVS_LOGOVERFLOWC - \brief Local event log overflow counter */ - - uint8 LogEnabled; /**< \cfetlmmnemonic \EVS_LOGENABLED - \brief Current event log enable/disable state */ - uint8 Spare1; /**< \cfetlmmnemonic \EVS_HK_SPARE1 - \brief Padding for 32 bit boundary */ - uint8 Spare2; /**< \cfetlmmnemonic \EVS_HK_SPARE2 - \brief Padding for 32 bit boundary */ - uint8 Spare3; /**< \cfetlmmnemonic \EVS_HK_SPARE3 - \brief Padding for 32 bit boundary */ - - CFE_EVS_AppTlmData_t AppData[CFE_ES_MAX_APPLICATIONS]; /**< \cfetlmmnemonic \EVS_APP - \brief Array of registered application table data */ - -} CFE_EVS_TlmPkt_Payload_t; - -typedef struct { - uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; - CFE_EVS_TlmPkt_Payload_t Payload; -} CFE_EVS_TlmPkt_t; - -/** Telemetry packet structures */ - -typedef struct { - char AppName[OS_MAX_API_NAME]; /**< \cfetlmmnemonic \EVS_APPNAME - \brief Application name */ - uint16 EventID; /**< \cfetlmmnemonic \EVS_EVENTID - \brief Numerical event identifier */ - uint16 EventType; /**< \cfetlmmnemonic \EVS_EVENTTYPE - \brief Numerical event type identifier */ - uint32 SpacecraftID; /**< \cfetlmmnemonic \EVS_SCID - \brief Spacecraft identifier */ - uint32 ProcessorID; /**< \cfetlmmnemonic \EVS_PROCESSORID - \brief Numerical processor identifier */ - -} CFE_EVS_PacketID_t; - - -/** -** \cfeevstlm Event Message Telemetry Packet -**/ -typedef struct { - CFE_EVS_PacketID_t PacketID; /**< \brief Event packet information */ - char Message[CFE_EVS_MAX_MESSAGE_LENGTH]; /**< \cfetlmmnemonic \EVS_EVENT - \brief Event message string */ - uint8 Spare1; /**< \cfetlmmnemonic \EVS_SPARE1 - \brief Structure padding */ - uint8 Spare2; /**< \cfetlmmnemonic \EVS_SPARE2 - \brief Structure padding */ -} CFE_EVS_Packet_Payload_t; - -typedef struct { - uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; - CFE_EVS_Packet_Payload_t Payload; -} CFE_EVS_Packet_t; - - -#define CFE_EVS_HK_TLM_LNGTH sizeof(CFE_EVS_TlmPkt_t) - - -#endif - - - diff --git a/src/components/interface/cFE/cfe_fs.h b/src/components/interface/cFE/cfe_fs.h deleted file mode 100644 index 64d388fa5f..0000000000 --- a/src/components/interface/cFE/cfe_fs.h +++ /dev/null @@ -1,363 +0,0 @@ -/* -** $Id: cfe_fs.h 1.4 2010/10/25 16:50:16GMT-05:00 jmdagost Exp $ -** -** Purpose: cFE File Services (FS) library API header file -** -** Author: S.Walling/Microtel -** -** $Log: cfe_fs.h $ -** Revision 1.4 2010/10/25 16:50:16GMT-05:00 jmdagost -** Added assumption to CFE_FS_ExtractFilenameFromPath() -** Revision 1.3 2008/08/28 08:41:10EDT apcudmore -** Fixed CFS name ( CFS-->CFE ) -** Revision 1.2 2008/06/20 15:40:26EDT apcudmore -** Added support for OSAL based module loader -** - Removed calls and references to the BSP based module loader -** Revision 1.1 2008/04/17 08:05:22EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.15 2007/09/20 14:47:24EDT apcudmore -** Changed CFE_FS_SB_QUERYALLTASKS_SUBTYPE back to CFE_FS_ES_QUERYALLTASKS_SUBTYPE -** Revision 1.14 2007/09/20 13:17:52EDT David Kobe (dlkobe) -** Added documentation for each File SubType identifier -** Revision 1.13 2007/09/20 10:52:52EDT apcudmore -** Added Query All Tasks command, file definition, events, error codes etc. -** Revision 1.12 2007/05/23 11:21:57EDT dlkobe -** Added doxygen formatting -** Revision 1.11 2007/05/09 12:43:03EDT dlkobe -** Added CFE_FS_ES_CDS_REG_SUBTYPE sub type to support Dump CDS Registry Command -** Revision 1.10 2007/03/29 08:58:09EST rjmcgraw -** Added shell subtype define -** Revision 1.9 2007/03/28 15:18:24EST rjmcgraw -** Moved file related defines from cfe_tbl.h to cfe_fs.h -** Revision 1.8 2007/03/16 15:12:13EST dlkobe -** Swapped parameter list for CFE_FS_ReadHeader API. -** Revision 1.7 2006/11/17 16:46:11GMT-05:00 dlkobe -** Updated with Doxygen formatted comments -** Revision 1.6 2006/07/25 14:37:50GMT-05:00 njyanchik -** It turns out the both the FS app and the OSAL were incorrect where file -** descriptors are concerned. File descriptors should be int32 across the board. -** -*/ - -/* -** Ensure that header is included only once... -*/ -#ifndef _cfe_fs_ -#define _cfe_fs_ - - -/* -** Required header files... -*/ -#include "common_types.h" -#include "cfe_time.h" - - - -/******************* Macro Definitions ***********************/ -#define CFE_FS_HDR_DESC_MAX_LEN 32 /**< \brief Max length of description field in a standard cFE File Header */ - -#define CFE_FS_FILE_CONTENT_ID 0x63464531 /**< \brief Magic Number for cFE compliant files (= 'cFE1') */ - -/** \name Standard cFE File Subtype Identifiers */ -/** \{ */ -#define CFE_FS_ES_ERLOG_SUBTYPE 1 /**< \brief Executive Services Exception/Reset Log Type */ - /**< Executive Services Exception/Reset Log File - which is generated in response to a - \link #CFE_ES_WRITE_ERLOG_CC \ES_WRITEERLOG2FILE \endlink - command. */ -#define CFE_FS_ES_SYSLOG_SUBTYPE 2 /**< \brief Executive Services System Log Type */ - /**< Executive Services System Log File which is - generated in response to a - \link #CFE_ES_WRITE_SYSLOG_CC \ES_WRITESYSLOG2FILE \endlink - command. */ -#define CFE_FS_ES_QUERYALL_SUBTYPE 3 /**< \brief Executive Services Information on All Applications File */ - /**< Executive Services Information on All - Applications File which is generated in response to a - \link #CFE_ES_QUERY_ALL_CC \ES_WRITEAPPINFO2FILE \endlink - command. */ -#define CFE_FS_ES_PERFDATA_SUBTYPE 4 /**< \brief Executive Services Performance Data File */ - /**< Executive Services Performance Analyzer Data File - which is generated in response to a - \link #CFE_ES_PERF_STOPDATA_CC \ES_STOPLADATA \endlink - command. */ -#define CFE_FS_ES_SHELL_SUBTYPE 5 /**< \brief Executive Services Shell Response File */ - /**< Executive Services Shell Response Data File - which is generated in response to a - \link #CFE_ES_SHELL_CMD_CC \ES_SHELL \endlink - command. */ -#define CFE_FS_ES_CDS_REG_SUBTYPE 6 /**< \brief Executive Services Critical Data Store Registry Dump File */ - /**< Executive Services Critical Data Store Registry Dump File - which is generated in response to a - \link #CFE_ES_DUMP_CDS_REG_CC \ES_DUMPCDSREG \endlink - command. */ -#define CFE_FS_TBL_REG_SUBTYPE 9 /** \brief Table Services Registry Dump File */ - /**< Table Services Registry Dump File - which is generated in response to a - \link #CFE_TBL_DUMP_REG_CC \TBL_WRITEREG2FILE \endlink - command. */ -#define CFE_FS_TBL_IMG_SUBTYPE 8 /**< \brief Table Services Table Image File */ - /**< Table Services Table Image File - which is generated either on the ground or in response to a - \link #CFE_TBL_DUMP_CC \TBL_DUMP \endlink command. */ -#define CFE_FS_EVS_APPDATA_SUBTYPE 15 /**< \brief Event Services Application Data Dump File */ - /**< Event Services Application Data Dump File - which is generated in response to a - \link #CFE_EVS_FILE_WRITE_APP_DATA_CC \EVS_WRITEAPPDATA2FILE \endlink - command. */ -#define CFE_FS_EVS_EVENTLOG_SUBTYPE 16 /**< \brief Event Services Local Event Log Dump File */ - /**< Event Services Local Event Log Dump File - which is generated in response to a - \link #CFE_EVS_FILE_WRITE_LOG_DATA_CC \EVS_WRITELOG2FILE \endlink - command. */ -#define CFE_FS_SB_PIPEDATA_SUBTYPE 20 /**< \brief Software Bus Pipe Data Dump File */ - /**< Software Bus Pipe Data Dump File - which is generated in response to a - \link #CFE_SB_SEND_PIPE_INFO_CC \SB_WRITEPIPE2FILE \endlink - command. */ -#define CFE_FS_SB_ROUTEDATA_SUBTYPE 21 /**< \brief Software Bus Message Routing Data Dump File */ - /**< Software Bus Message Routing Data Dump File - which is generated in response to a - \link #CFE_SB_SEND_ROUTING_INFO_CC \SB_WRITEROUTING2FILE \endlink - command. */ -#define CFE_FS_SB_MAPDATA_SUBTYPE 22 /**< \brief Software Bus Message Mapping Data Dump File */ - /**< Software Bus Message Mapping Data Dump File - which is generated in response to a - \link #CFE_SB_SEND_MAP_INFO_CC \SB_WRITEMAP2FILE \endlink - command. */ -#define CFE_FS_ES_QUERYALLTASKS_SUBTYPE 23 /**< \brief Executive Services Query All Tasks Data File */ - /**< Executive Services Query All Tasks Data File - which is generated in response to a - \link #CFE_ES_QUERY_ALL_TASKS_CC \ES_WRITETASKINFO2FILE \endlink - command. */ -/** \} */ - -/** -** \brief Standard cFE File header structure definition -*/ -typedef struct -{ - uint32 ContentType; /**< \brief Identifies the content type (='cFE1'=0x63464531)*/ - uint32 SubType; /**< \brief Type of \c ContentType, if necessary */ - /**< Standard SubType definitions can be found - \link #CFE_FS_ES_ERLOG_SUBTYPE here \endlink */ - uint32 Length; /**< \brief Length of primary header */ - uint32 SpacecraftID; /**< \brief Spacecraft that generated the file */ - uint32 ProcessorID; /**< \brief Processor that generated the file */ - uint32 ApplicationID; /**< \brief Application that generated the file */ - - uint32 TimeSeconds; /**< \brief File creation timestamp (seconds) */ - uint32 TimeSubSeconds; /**< \brief File creation timestamp (sub-seconds) */ - - char Description[CFE_FS_HDR_DESC_MAX_LEN]; /**< \brief File description */ - -} CFE_FS_Header_t; - - -/* -** File header access functions... -*/ - -/*****************************************************************************/ -/** -** \brief Read the contents of the Standard cFE File Header -** -** \par Description -** This API will fill the specified #CFE_FS_Header_t variable with the -** contents of the Standard cFE File Header of the file identified by -** the given File Descriptor. -** -** \par Assumptions, External Events, and Notes: -** -# The File has already been successfully opened using #OS_open and -** the caller has a legitimate File Descriptor. -** -** \param[in] FileDes File Descriptor obtained from a previous call to #OS_open -** that is associated with the file whose header is to be read. -** -** \param[in] Hdr Pointer to a variable of type #CFE_FS_Header_t that will be -** filled with the contents of the Standard cFE File Header. -** -** \param[out] *Hdr Contents of the Standard cFE File Header for the specified file. -** -** \returns -** \retstmt Any of the return codes specified for #OS_lseek or #OS_read \endstmt -** \endreturns -** -** \sa #CFE_FS_WriteHeader -** -******************************************************************************/ -int32 CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, int32 FileDes); - -/*****************************************************************************/ -/** -** \brief Initializes the contents of the Standard cFE File Header -** -** \par Description -** This API will clear the specified #CFE_FS_Header_t variable and -** initialize the description field with the specified value -** -** \param[in] Hdr Pointer to a variable of type #CFE_FS_Header_t that will be -** cleared and initialized -** -** \sa #CFE_FS_WriteHeader -** -******************************************************************************/ -void CFE_FS_InitHeader(CFE_FS_Header_t *Hdr, const char *Description, uint32 SubType); - -/*****************************************************************************/ -/** -** \brief Write the specified Standard cFE File Header to the specified file -** -** \par Description -** This API will output the specified #CFE_FS_Header_t variable, with some -** fields automatically updated, to the specified file as the Standard cFE -** File Header. This API will automatically populate the following fields -** in the specified #CFE_FS_Header_t: -** -** -# \link #CFE_FS_Header_t::ContentType \c ContentType \endlink - Filled with 0x63464531 ('cFE1') -** -# \link #CFE_FS_Header_t::Length \c Length \endlink - Filled with the sizeof(CFE_FS_Header_t) -** -# \link #CFE_FS_Header_t::SpacecraftID \c SpacecraftID \endlink - Filled with the Spacecraft ID -** -# \link #CFE_FS_Header_t::ProcessorID \c ProcessorID \endlink - Filled with the Processor ID -** -# \link #CFE_FS_Header_t::ApplicationID \c ApplicationID \endlink - Filled with the Application ID -** -# \link #CFE_FS_Header_t::TimeSeconds \c TimeSeconds \endlink - Filled with the Time, in seconds, as obtained by #CFE_TIME_GetTime -** -# \link #CFE_FS_Header_t::TimeSubSeconds \c TimeSubSeconds \endlink - Filled with the Time, subseconds, as obtained by #CFE_TIME_GetTime -** -** -** \par Assumptions, External Events, and Notes: -** -# The File has already been successfully opened using #OS_open and -** the caller has a legitimate File Descriptor. -** -# The \c SubType field has been filled appropriately by the Application. -** -# The \c Description field has been filled appropriately by the Application. -** -** \param[in] FileDes File Descriptor obtained from a previous call to #OS_open -** that is associated with the file whose header is to be read. -** -** \param[in] Hdr Pointer to a variable of type #CFE_FS_Header_t that will be -** filled with the contents of the Standard cFE File Header. -** -** \param[out] *Hdr Contents of the Standard cFE File Header for the specified file. -** -** \returns -** \retstmt Any of the return codes specified for #OS_lseek or #OS_write \endstmt -** \endreturns -** -** \sa #CFE_FS_ReadHeader -** -******************************************************************************/ -int32 CFE_FS_WriteHeader(int32 FileDes, CFE_FS_Header_t *Hdr); - -/*****************************************************************************/ -/** -** \brief Modifies the Time Stamp field in the Standard cFE File Header for the specified file -** -** \par Description -** This API will modify the \link #CFE_FS_Header_t::TimeSeconds timestamp \endlink found -** in the Standard cFE File Header of the specified file. The timestamp will be replaced -** with the time specified by the caller. -** -** \par Assumptions, External Events, and Notes: -** -# The File has already been successfully opened using #OS_open and -** the caller has a legitimate File Descriptor. -** -# The \c NewTimestamp field has been filled appropriately by the Application. -** -** \param[in] FileDes File Descriptor obtained from a previous call to #OS_open -** that is associated with the file whose header is to be read. -** -** \param[in] NewTimestamp A #CFE_TIME_SysTime_t data structure containing the desired time -** to be put into the file's Standard cFE File Header. -** -** \returns -** \retstmt Any of the return codes specified for #OS_lseek or #OS_write \endstmt -** \endreturns -** -** \sa -** -******************************************************************************/ -int32 CFE_FS_SetTimestamp(int32 FileDes, CFE_TIME_SysTime_t NewTimestamp); - - -/*****************************************************************************/ -/** -** \brief Determines if a file is a Gzip/compressed file. -** -** \par Description -** This API will check the filename and return TRUE if the file is -** a gzip file. The check is currently based on the filename, so the -** zipped files should use the ".gz" extention. -** -** \par Assumptions, External Events, and Notes: -** -# A gzipped file will use the ".gz" filename extention. -** -** \param[in] FileName The name of the file. -** -** \returns -** \retstmt TRUE if the file has the ".gz" extention and FALSE otherwise. \endstmt -** \endreturns -** -** \sa -** -******************************************************************************/ -boolean CFE_FS_IsGzFile(const char *FileName); - -/*****************************************************************************/ -/** -** \brief Extracts the filename from a unix style path and filename string. -** -** \par Description -** This API will take the original unix path/filename combination and -** extract the base filename. Example: Given the path/filename : "/cf/apps/myapp.o.gz" -** this function will return the filename: "myapp.o.gz". -** -** \par Assumptions, External Events, and Notes: -** -# The paths and filenames used here are the standard unix style -** filenames separated by "/" characters. -** -# The extracted filename is no longer than #OS_MAX_PATH_LEN -** -** \param[in] OriginalPath The original path. -** \param[out] FileNameOnly The filename that is extracted from the path. -** -** \returns -** \retstmt CFE_SUCCESS if the filename was extracted from the path \endstmt -** \endreturns -** -** \sa -** -******************************************************************************/ -int32 CFE_FS_ExtractFilenameFromPath(const char *OriginalPath, char *FileNameOnly); - -/*****************************************************************************/ -/** -** \brief Decompresses the source file to the destination file. -** -** \par Description -** This API will decompress the source file to the file specified by -** the destination file. The file must be compressed using the "gzip" -** utility. This utility is available on most unix workstations, Mac OS X, -** Cygwin, and MinGW for Windows. More information can be found at -** http://www.gzip.org/ -** -** \par Assumptions, External Events, and Notes: -** -# The paths and filenames used here are cfe compliant file names. -** -# The source file is compressed with the "gzip" utility. -** -# The destination file does not exist, or can be overwritten. -** -** \param[in] SourceFile The "gzipped" file to decompress. -** \param[out] DestinationFile The path/filename to write the decompressed or -** "gunzipped" file to. -** -** \returns -** \retstmt CFE_SUCCESS if the file was decompressed sucessfully. \endstmt -** \endreturns -** -** \sa -** -******************************************************************************/ -int32 CFE_FS_Decompress( const char * SourceFile, const char * DestinationFile ); - - -#endif /* _cfe_fs_ */ - -/************************/ -/* End of File Comment */ -/************************/ diff --git a/src/components/interface/cFE/cfe_mission_cfg.h b/src/components/interface/cFE/cfe_mission_cfg.h deleted file mode 100644 index 7c990459d5..0000000000 --- a/src/components/interface/cFE/cfe_mission_cfg.h +++ /dev/null @@ -1,477 +0,0 @@ -/****************************************************************************** -** File: cfe_mission_cfg.h -** -** Purpose: -** This header file contains the mission configuration parameters and -** typedefs with mission scope. -** -** Author: R.McGraw/SSI -** -** Notes: -** -** $Log: cfe_mission_cfg.h $ -** Revision 1.9 2011/11/30 15:13:24GMT-05:00 jmdagost -** Changed definitions to be TRUE/FALSE instead of commenting/uncommenting them. -** Revision 1.8 2011/02/03 15:20:10EST lwalling -** Added definition for CFE_SB_PACKET_TIME_FORMAT and list of supported selections -** Revision 1.7 2009/06/26 10:17:13EDT rmcgraw -** DCR8290:6 Comment changes -** Revision 1.6 2009/02/26 17:45:07EST rmcgraw -** Member moved from ../fsw/build/inc/ to ../fsw/mission_inc/ -** Revision 1.5 2009/02/26 17:45:07ACT rmcgraw -** DCR6805:1 Added comments to reflect SB cfg paramater limits -** Revision 1.4 2008/12/08 12:07:02EST dkobe -** Updates to correct doxygen errors -** Revision 1.3 2008/11/19 08:45:22EST wfmoleski -** The changes are as follows: -** added 6 #defines (2 for each cpu) that indicate the APPID_BASE for cmds and tlm. -** Revision 1.2 2008/07/07 14:09:42EDT apcudmore -** Removed FS Message ID defines from system config files. -** Revision 1.1 2008/04/17 08:02:33EDT ruperera -** Initial revision -** Member added to /fsw/build/inc/project.pj -** Revision 1.21 2007/09/19 15:21:16EDT rjmcgraw -** DCR4488 Removed all SB network message numbers and message ids -** Revision 1.20 2007/09/12 16:06:11EDT David Kobe (dlkobe) -** Moved the definitions of CFE_ES_CRC_xx to the cfe_mission_cfg.h file and deleted TBL Services -** CRC #define statement. -** Revision 1.19 2007/09/12 09:46:03EDT David Kobe (dlkobe) -** Added doxygen comments to commands and some configuration parameters -** Revision 1.18 2007/06/08 11:12:47EDT rjmcgraw -** Added doxygen comments -** Revision 1.17 2007/05/04 20:07:53EDT dlkobe -** Added command to telemeter memory pool statistics -** Revision 1.16 2007/04/19 15:43:48EDT rjmcgraw -** Removed SBP related #defines -** Revision 1.15 2007/02/23 09:11:33EST njyanchik -** Added CFE_ES_SHELL_TLM_MSG -** Revision 1.14 2006/12/28 16:25:40EST rjmcgraw -** Added msg numbers for new SB subscription pkts -** Revision 1.13 2006/12/26 15:13:37EST rjmcgraw -** Comment changes in networking defines -** Revision 1.12 2006/11/28 11:28:30EST mobartholomew -** Updated cfe_mission_cfg to reference valid CRC type -** Revision 1.11 2006/11/09 15:30:07EST rjmcgraw -** Added #define for CFE_SPACECRAFT_ID -** Revision 1.10 2006/10/30 12:53:13EST dlkobe -** Baseline Critical Data Store Implementation -** -******************************************************************************/ - -#ifndef _cfe_mission_cfg_ -#define _cfe_mission_cfg_ - - -/** -** \cfemissioncfg Spacecraft ID -** -** \par Description: -** This defines the value that is returned by the call to -** CFE_PSP_GetSpacecraftId. -** -** \par Limits -** The cFE does not place a limit on this configuration paramter. -** CCSDS allocates 8 bits for this field in the standard VCDU. -*/ -#define CFE_SPACECRAFT_ID 0x42 - - -/** -** \cfemissioncfg Spacecraft ID -** -** \par Description: -** Dictates the message format used by the cFE. -** -** \par Limits -** All versions of the cFE currently support only CCSDS as the message format -*/ -#define MESSAGE_FORMAT_IS_CCSDS - - -/** \name Packet timestamp format identifiers */ -/** \{ */ -#define CFE_SB_TIME_32_16_SUBS 1 /**< \brief 32 bits seconds + 16 bits subseconds (units = 2^^-16) */ -#define CFE_SB_TIME_32_32_SUBS 2 /**< \brief 32 bits seconds + 32 bits subseconds (units = 2^^-32) */ -#define CFE_SB_TIME_32_32_M_20 3 /**< \brief 32 bits seconds + 20 bits microsecs + 12 bits reserved */ -/** \} */ - -/** -** \cfemissioncfg Packet Timestamp Format Selection -** -** \par Description: -** Defines the size, format and contents of the telemetry packet timestamp. -** -** \par Limits -** Must be defined as one of the supported formats listed above -*/ -#define CFE_SB_PACKET_TIME_FORMAT CFE_SB_TIME_32_16_SUBS - - -/** -** \cfesbcfg Maximum SB Message Size -** -** \par Description: -** The following definition dictates the maximum message size allowed on -** the software bus. SB checks the pkt length field in the header of all -** messages sent. If the pkt length field indicates the message is larger -** than this define, SB sends an event and rejects the send. -** -** -** \par Limits -** This parameter has a lower limit of 6 (CCSDS primary header size), -** and an upper limit (including headers) of 32768 bytes. -*/ -#define CFE_SB_MAX_SB_MSG_SIZE 32768 - - -/** -** \cfetimecfg Default Time Format -** -** \par Description: -** The following definitions select either UTC or TAI as the default -** (mission specific) time format. Although it is possible for an -** application to request time in a specific format, most callers -** should use CFE_TIME_GetTime(), which returns time in the default -** format. This avoids having to modify each individual caller -** when the default choice is changed. -** -** -** \par Limits -** if CFE_TIME_CFG_DEFAULT_TAI is defined as TRUE then CFE_TIME_CFG_DEFAULT_UTC must be -** defined as FALSE. -** if CFE_TIME_CFG_DEFAULT_TAI is defined as FALSE then CFE_TIME_CFG_DEFAULT_UTC must be -** defined as TRUE. -*/ -#define CFE_TIME_CFG_DEFAULT_TAI TRUE -#define CFE_TIME_CFG_DEFAULT_UTC FALSE - - -/** -** \cfetimecfg Default Time Format -** -** \par Description: -** The following definition enables the use of a simulated time at -** the tone signal using a software bus message. -** -** -** \par Limits -** Not Applicable -*/ -#define CFE_TIME_CFG_FAKE_TONE TRUE - - -/** -** \cfetimecfg Default Time and Tone Order -** -** \par Description: -** Time Services may be configured to expect the time at the tone -** data packet to either precede or follow the tone signal. If the -** time at the tone data packet follows the tone signal, then the -** data within the packet describes what the time "was" at the tone. -** If the time at the tone data packet precedes the tone signal, then -** the data within the packet describes what the time "will be" at -** the tone. One, and only one, of the following symbols must be set to TRUE: -** - CFE_TIME_AT_TONE_WAS -** - CFE_TIME_AT_TONE_WILL_BE -** Note: If Time Services is defined as using a simulated tone signal -** (see #CFE_TIME_CFG_FAKE_TONE above), then the tone data packet -** must follow the tone signal. -** -** \par Limits -** Either CFE_TIME_AT_TONE_WAS or CFE_TIME_AT_TONE_WILL_BE must be set to TRUE. -** They may not both be TRUE and they may not both be FALSE. -*/ -#define CFE_TIME_AT_TONE_WAS TRUE -#define CFE_TIME_AT_TONE_WILL_BE FALSE - -/** -** \cfetimecfg Min and Max Time Elapsed -** -** \par Description: -** Based on the definition of Time and Tone Order -** (CFE_TIME_AT_TONE_WAS/WILL_BE) either the "time at the tone" signal or -** data packet will follow the other. This definition sets the valid window -** of time for the second of the pair to lag behind the first. Time -** Services will invalidate both the tone and packet if the second does not -** arrive within this window following the first. -** -** For example, if the data packet follows the tone, it might be valid for -** the data packet to arrive between zero and 100,000 micro-seconds after -** the tone. But, if the tone follows the the packet, it might be valid -** only if the packet arrived between 200,000 and 700,000 micro-seconds -** before the tone. -** -** Note: units are in micro-seconds -** -** -** \par Limits -** 0 to 999,999 decimal -*/ -#define CFE_TIME_MIN_ELAPSED 0 -#define CFE_TIME_MAX_ELAPSED 200000 - - -/** -** \cfetimecfg Default Time Values -** -** \par Description: -** Default time values are provided to avoid problems due to time -** calculations performed after startup but before commands can be -** processed. For example, if the default time format is UTC then -** it is important that the sum of MET and STCF always exceed the -** value of Leap Seconds to prevent the UTC time calculation -** (time = MET + STCF - Leap Seconds) from resulting in a negative -** (very large) number.

-** Some past missions have also created known (albeit wrong) default -** timestamps. For example, assume the epoch is defined as Jan 1, 1970 -** and further assume the default time values are set to create a timestamp -** of Jan 1, 2000. Even though the year 2000 timestamps are wrong, it -** may be of value to keep the time within some sort of bounds acceptable -** to the software.

-** Note: Sub-second units are in micro-seconds (0 to 999,999) and -** all values must be defined -** -** \par Limits -** Not Applicable -*/ -#define CFE_TIME_DEF_MET_SECS 1000 -#define CFE_TIME_DEF_MET_SUBS 0 - -#define CFE_TIME_DEF_STCF_SECS 1000000 -#define CFE_TIME_DEF_STCF_SUBS 0 - -#define CFE_TIME_DEF_LEAPS 32 - -#define CFE_TIME_DEF_DELAY_SECS 0 -#define CFE_TIME_DEF_DELAY_SUBS 1000 - - -/** -** \cfetimecfg Default EPOCH Values -** -** \par Description: -** Default ground time epoch values -** Note: these values are used only by the CFE_TIME_Print() API function -** -** \par Limits -** Year - must be within 136 years -** Day - Jan 1 = 1, Feb 1 = 32, etc. -** Hour - 0 to 23 -** Minute - 0 to 59 -** Second - 0 to 59 -*/ -#define CFE_TIME_EPOCH_YEAR 1980 -#define CFE_TIME_EPOCH_DAY 1 -#define CFE_TIME_EPOCH_HOUR 0 -#define CFE_TIME_EPOCH_MINUTE 0 -#define CFE_TIME_EPOCH_SECOND 0 - - -/** -** \cfetimecfg Time File System Factor -** -** \par Description: -** Define the s/c vs file system time conversion constant... -** -** Note: this value is intended for use only by CFE TIME API functions to -** convert time values based on the ground system epoch (s/c time) to -** and from time values based on the file system epoch (fs time). -** -** FS time = S/C time + factor -** S/C time = FS time - factor -** -** Worksheet: -** -** S/C epoch = Jan 1, 2005 (LRO ground system epoch) -** FS epoch = Jan 1, 1980 (vxWorks DOS file system epoch) -** -** Delta = 25 years, 0 days, 0 hours, 0 minutes, 0 seconds -** -** Leap years = 1980, 1984, 1988, 1992, 1996, 2000, 2004 -** (divisible by 4 -- except if by 100 -- unless also by 400) -** -** 1 year = 31,536,000 seconds -** 1 day = 86,400 seconds -** 1 hour = 3,600 seconds -** 1 minute = 60 seconds -** -** 25 years = 788,400,000 seconds -** 7 extra leap days = 604,800 seconds -** -** total delta = 789,004,800 seconds -** -** \par Limits -** Not Applicable -*/ -#define CFE_TIME_FS_FACTOR 789004800 - - -/** -** \cfeescfg Maximum Length of CDS Name -** -** \par Description: -** Indicates the maximum length (in characers) of the CDS name ('CDSName') -** portion of a Full CDS Name of the following form: -** "ApplicationName.CDSName" -** -** -** \par Limits -** Not Applicable -*/ -#define CFE_ES_CDS_MAX_NAME_LENGTH 16 - - - -/** -** \cfeevscfg Maximum Event Message Length -** -** \par Description: -** Indicates the maximum length (in characers) of the formatted text -** string portion of an event message -** -** \par Limits -** Not Applicable -*/ -#define CFE_EVS_MAX_MESSAGE_LENGTH 122 - - -/** \name Checksum/CRC algorithm identifiers */ -/** \{ */ -#define CFE_ES_CRC_8 1 /**< \brief CRC ( 8 bit additive - returns 32 bit total) (Currently not implemented) */ -#define CFE_ES_CRC_16 2 /**< \brief CRC (16 bit additive - returns 32 bit total) */ -#define CFE_ES_CRC_32 3 /**< \brief CRC (32 bit additive - returns 32 bit total) (Currently not implemented) */ -/** \} */ - -/** -** \cfeescfg Mission Default CRC algorithm -** -** \par Description: -** Indicates the which CRC algorithm should be used as the default -** for verifying the contents of Critical Data Stores and when calculating -** Table Image data integrity values. -** -** \par Limits -** Currently only CFE_ES_CRC_16 is supported (see #CFE_ES_CRC_16) -*/ -#define CFE_ES_DEFAULT_CRC CFE_ES_CRC_16 - - -/** -** \cfetblcfg Maximum Table Name Length -** -** \par Description: -** Indicates the maximum length (in characers) of the table name -** ('TblName') portion of a Full Table Name of the following -** form: "ApplicationName.TblName" -** -** \par Limits -** Not Applicable -*/ -#define CFE_TBL_MAX_NAME_LENGTH 16 - - -/** -** \cfemissioncfg cFE Message ID Base Numbers -** -** \par Description: -** Message Id base numbers for the cFE messages -** NOTE: cFE MsgIds are the sum of the base numbers and the portable msg -** numbers. -** -** \par Limits -** Must be less than CFE_SB_HIGHEST_VALID_MSGID -*/ -#define CFE_CMD_MID_BASE_CPU1 0x1800 -#define CFE_TLM_MID_BASE_CPU1 0x0800 -#define CFE_CMD_APPID_BASE_CPU1 1 -#define CFE_TLM_APPID_BASE_CPU1 0 - -#define CFE_CMD_MID_BASE_CPU2 0x1820 -#define CFE_TLM_MID_BASE_CPU2 0x0820 -#define CFE_CMD_APPID_BASE_CPU2 33 -#define CFE_TLM_APPID_BASE_CPU2 32 - -#define CFE_CMD_MID_BASE_CPU3 0x1840 -#define CFE_TLM_MID_BASE_CPU3 0x0840 -#define CFE_CMD_APPID_BASE_CPU3 65 -#define CFE_TLM_APPID_BASE_CPU3 64 - -#define CFE_CMD_MID_BASE_GLOB 0x1860 -#define CFE_TLM_MID_BASE_GLOB 0x0860 - - - -/** -** \cfemissioncfg cFE Portable Message Numbers for Commands -** -** \par Description: -** Portable message numbers for the cFE command messages -** NOTE: cFE MsgIds are the sum of the base numbers and the portable msg -** numbers. -** -** \par Limits -** Not Applicable -*/ -#define CFE_EVS_CMD_MSG 1 - /* Offset 2 is available */ -#define CFE_SB_CMD_MSG 3 -#define CFE_TBL_CMD_MSG 4 -#define CFE_TIME_CMD_MSG 5 -#define CFE_ES_CMD_MSG 6 - -#define CFE_ES_SEND_HK_MSG 8 -#define CFE_EVS_SEND_HK_MSG 9 - /* Offset 10 is available */ -#define CFE_SB_SEND_HK_MSG 11 -#define CFE_TBL_SEND_HK_MSG 12 -#define CFE_TIME_SEND_HK_MSG 13 - -#define CFE_TIME_TONE_CMD_MSG 16 -#define CFE_TIME_1HZ_CMD_MSG 17 - - -/** -** \cfemissioncfg cFE Portable Message Numbers for Global Messages -** -** \par Description: -** Portable message numbers for the cFE global messages -** NOTE: cFE MsgIds are the sum of the base numbers and the portable msg -** numbers. -** -** \par Limits -** Not Applicable -*/ -#define CFE_TIME_DATA_CMD_MSG 0 -#define CFE_TIME_FAKE_CMD_MSG 1 -#define CFE_TIME_SEND_CMD_MSG 2 - - -/** -** \cfemissioncfg cFE Portable Message Numbers for Telemetry -** -** \par Description: -** Portable message numbers for the cFE telemetry messages -** NOTE: cFE MsgIds are the sum of the base numbers and the portable msg -** numbers. -** -** \par Limits -** Not Applicable -*/ -#define CFE_ES_HK_TLM_MSG 0 -#define CFE_EVS_HK_TLM_MSG 1 - /* Offset 2 is available */ -#define CFE_SB_HK_TLM_MSG 3 -#define CFE_TBL_HK_TLM_MSG 4 -#define CFE_TIME_HK_TLM_MSG 5 -#define CFE_TIME_DIAG_TLM_MSG 6 - -#define CFE_EVS_EVENT_MSG_MSG 8 -#define CFE_SB_STATS_TLM_MSG 10 -#define CFE_ES_APP_TLM_MSG 11 -#define CFE_TBL_REG_TLM_MSG 12 -#define CFE_SB_ALLSUBS_TLM_MSG 13 -#define CFE_SB_ONESUB_TLM_MSG 14 -#define CFE_ES_SHELL_TLM_MSG 15 -#define CFE_ES_MEMSTATS_TLM_MSG 16 - -#endif diff --git a/src/components/interface/cFE/cfe_platform_cfg.h b/src/components/interface/cFE/cfe_platform_cfg.h deleted file mode 100644 index a2e7e66648..0000000000 --- a/src/components/interface/cFE/cfe_platform_cfg.h +++ /dev/null @@ -1,1857 +0,0 @@ -/****************************************************************************** -** File: cfe_platform_cfg.h -** -** Purpose: -** This header file contains the platform configuration parameters. -** -** Author: R.McGraw/SSI -** -** $Log: cfe_platform_cfg.h $ -** Revision 1.35 2014/09/09 13:59:50GMT-05:00 lwalling -** Describe effects of removing Table Services from CFE on definition of CFE_ES_MAX_BLOCK_SIZE -** Revision 1.34 2014/08/21 15:29:47EDT rmcgraw -** DCR22696:1 Added #define CFE_ES_EXCEPTION_FUNCTION -** Revision 1.33 2014/08/19 15:01:27EDT sstrege -** Updated reference to OS_BSPGetUserReservedArea to CFE_PSP_GetUserReservedArea -** Revision 1.32 2014/04/14 11:51:41EDT lwalling -** Created platform config definitions for Time 1HZ and Time TONE task priorities and stack sizes -** Revision 1.31 2012/01/18 16:36:58EST jmdagost -** Changed filename reference in cFE Mission Revision comment. -** Revision 1.30 2012/01/06 17:15:22EST lwalling -** Changed default shell output filename from CmdString.out to ShellCmd.out -** Revision 1.29 2011/12/27 16:39:03EST lwalling -** Include mission config file from platform config file -** Revision 1.28 2011/12/21 15:07:51EST lwalling -** Add table file verification definitions for spacecraft ID and processor ID -** Revision 1.27 2011/11/30 15:13:23EST jmdagost -** Changed definitions to be TRUE/FALSE instead of commenting/uncommenting them. -** Revision 1.26 2011/01/18 16:06:04EST lwalling -** Make sending 1hz command packet a configuration option -** Revision 1.25 2010/11/23 15:26:32EST jmdagost -** Added mission-specific revision number definition (4th digit in cFE version number) -** Revision 1.24 2010/11/23 12:10:40EST jmdagost -** Increased SB Max block size to accommodate change in SB. -** Revision 1.23 2010/11/08 16:18:29EST acudmore -** Updated RAM disk path comments -** Revision 1.22 2010/11/08 14:55:13EST aschoeni -** Moved CFE_SB_DEFAULT_MSG_LIMIT from cfe_sb_priv to cfe_platform_cfg -** Revision 1.21 2010/11/08 12:30:11EST acudmore -** Updated CFE_ES_MAX_PROCESSOR_RESETS to 2 ( rather than 5 ) -** Revision 1.20 2010/11/05 15:54:31EDT aschoeni -** Added Generic Counter API to ES -** Revision 1.19 2010/11/04 16:41:46EDT aschoeni -** Added optional sender information storage -** Revision 1.18 2010/11/04 12:48:46EDT acudmore -** Added RAM disk mount path configuration item. -** Revision 1.17 2010/10/27 16:34:42EDT jmdagost -** Changed EVS default log mode from 0 (overwrite) to 1 (discard) -** Revision 1.16 2010/10/26 16:29:28EDT jmdagost -** Deleted unnecessary CFE_ES_MAX_SHELL_CMD_SIZE -** Revision 1.15 2010/10/20 12:43:12EDT jmdagost -** Added reference to CFE_ES_PoolCreateNoSem in documentation. -** Revision 1.14 2009/07/31 14:07:08EDT aschoeni -** Added note to parameters which may affect USER_RESERVED_MEM -** Revision 1.13 2009/07/30 19:22:49EDT jmdagost -** Updated doxygen comments for CFE_TBL_MAX_CRITICAL_TABLES -** Revision 1.12 2009/07/28 18:04:45EDT jmdagost -** Increased default number of registered CDS blocks -** Revision 1.11 2009/07/28 17:16:23EDT jmdagost -** Added initial filter mask and trigger mask definitions. -** Revision 1.10 2009/02/26 17:42:26EST rmcgraw -** Member moved from cfe_platform_cfg.h in project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/platform_inc/project.pj to cfe_platform_cfg.h in project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/platform_inc/cpu1/project.pj. -** Revision 1.9 2009/02/26 17:42:26ACT rmcgraw -** Member moved from cfe_platform_cfg.h in project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/build/cpu1/inc/project.pj to cfe_platform_cfg.h in project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/platform_inc/project.pj. -** Revision 1.8 2009/02/26 17:42:26ACT rmcgraw -** DCR6805:1 Added comments to reflect SB cfg paramater limits -** Revision 1.7 2009/02/11 15:02:33EST rmcgraw -** DCR6269:1 Added SB mem pool block sizes -** Revision 1.6 2008/12/08 12:07:15EST dkobe -** Updates to correct doxygen errors -** Revision 1.5 2008/09/02 10:28:41EDT apcudmore -** Changed Ram Disk NUM_SECTORS back to 4096 -** Revision 1.4 2008/08/06 22:42:32EDT dkobe -** Added CFE_TIME_RegisterSynchCallback, CFE_TIME_UnregisterSynchCallback and CFE_TIME_CleanUpApp -** Revision 1.2 2008/07/25 12:49:08EDT dkobe -** Updated CFE_TBL_MAX_DBL_TABLE_SIZE and CFE_TBL_SNGL_TABLE_SIZE to 16K -** Revision 1.1 2008/07/22 16:51:57EDT apcudmore -** Member moved to .../fsw/build/cpu1/inc -** Revision 1.1 2008/04/17 08:01:30EDT ruperera -** Member moved from cfe project on tlserver to cfe project on tlserver3 -** Revision 1.6 2008/02/13 15:46:52EST rjmcgraw -** DCR6754:1 Removed CFE_SB_EVENT_LOG_ENTRIES -** Revision 1.5 2007/09/25 10:04:36EDT apcudmore -** Created new config parameter for default filename for Query All Tasks cmd. -** Revision 1.4 2007/09/20 11:19:09EDT apcudmore -** Removed vxWorks boot line and IP address from config file. They are no longer being used. -** -******************************************************************************/ - -#ifndef _cfe_platform_cfg_ -#define _cfe_platform_cfg_ - -/* -** Allow reference to CFE_SPACECRAFT_ID (see CFE_TBL_VALID_ definitions below) -*/ -#include "cfe_mission_cfg.h" - -/* -** CPU Id for target Processor -*/ -#define CFE_CPU_ID 1 - -/* -** CPU Name for target Processor -*/ -#define CFE_CPU_NAME "CPU1" - -/** -** \cfesbcfg Maximum Number of Unique Message IDs SB Routing Table can hold -** -** \par Description: -** Dictates the maximum number of unique MsgIds the SB routing table will hold. -** This constant has a direct affect on the size of SB's tables and arrays. -** Keeping this count as low as possible will save memory. -** To see the run-time, high-water mark and the current utilization figures -** regarding this parameter, send an SB command to 'Send Statistics Pkt'. -** -** \par Limits -** This parameter has a lower limit of 1 and an upper limit of 1024. -** -*/ -#define CFE_SB_MAX_MSG_IDS 256 - - -/** -** \cfesbcfg Maximum Number of Unique Pipes SB Routing Table can hold -** -** \par Description: -** Dictates the maximum number of unique Pipes the SB routing table will hold. -** This constant has a direct affect on the size of SB's tables and arrays. -** Keeping this count as low as possible will save memory. -** To see the run-time, high-water mark and the current utilization figures -** regarding this parameter, send an SB command to 'Send Statistics Pkt'. -** -** \par Limits -** This parameter has a lower limit of 1 and an upper limit of 255. -** This parameter must also be less than or equal to OS_MAX_QUEUES -** -*/ -#define CFE_SB_MAX_PIPES 64 - - -/** -** \cfesbcfg Maximum Number of unique local destinations a single MsgId can have -** -** \par Description: -** Dictates the maximum number of unique local destinations a single MsgId can -** have. -** -** \par Limits -** This parameter has a lower limit of 1 and an upper limit of 64. -** -*/ -#define CFE_SB_MAX_DEST_PER_PKT 16 - - -/** -** \cfesbcfg Default Subscription Message Limit -** -** \par Description: -** Dictates the default Message Limit when using the #CFE_SB_Subscribe API. This will -** limit the number of messages with a specific message ID that can be received through -** a subscription. This only changes the default; other message limits can be set on a per -** subscription basis using #CFE_SB_SubscribeEx . -** -** \par Limits -** This parameter has a lower limit of 4 and an upper limit of 65535. -** -*/ -#define CFE_SB_DEFAULT_MSG_LIMIT 4 - - -/** -** \cfesbcfg Size of the SB buffer memory pool -** -** \par Description: -** Dictates the size of the SB memory pool. For each message the SB -** sends, the SB dynamically allocates from this memory pool, the memory needed -** to process the message. The memory needed to process each message is msg -** size + msg descriptor(#CFE_SB_BufferD_t). This memory pool is also used -** to allocate destination descriptors (#CFE_SB_DestinationD_t) during the -** subscription process. -** To see the run-time, high-water mark and the current utilization figures -** regarding this parameter, send an SB command to 'Send Statistics Pkt'. -** Some memory statistics have been added to the SB housekeeping packet. -** NOTE: It is important to monitor these statistics to ensure the desired -** memory margin is met. -** -** \par Limits -** This parameter has a lower limit of 512 and an upper limit 4.29G bytes. -** -*/ -#define CFE_SB_BUF_MEMORY_BYTES 524288 - - -/** -** \cfesbcfg Maximum depth allowed when creating an SB pipe -** -** \par Description: -** The value of this constant dictates the maximum pipe depth that an -** application may request. The pipe depth is given as a paramter in the -** #CFE_SB_CreatePipe API. -** -** \par Limits -** This parameter has a lower limit of 1 and an upper limit of 65535. -*/ -#define CFE_SB_MAX_PIPE_DEPTH 256 - - -/** -** \cfesbcfg Highest Valid Message Id -** -** \par Description: -** The value of this constant dictates the size of the SB message map. The SB -** messsage map is a lookup table that provides the routing table index for -** fast access into the routing table.The default setting of 0x1FFF was chosen -** to save memory for CCSDS implementations where the CCSDS Version number -** (3 MSB's of MsgId) would remain constant throughout the mission. This -** reduces the message map from 128Kbytes to 16Kbytes.See CFE_FSW_DCR 504 for -** more details. -** -** \par Limits -** This parameter has a lower limit of 1 and an upper limit of 0xFFFF. -*/ -#define CFE_SB_HIGHEST_VALID_MSGID 0x1FFF - - -/** -** \cfesbcfg Default Routing Information Filename -** -** \par Description: -** The value of this constant defines the filename used to store the software -** bus routing information. This filename is used only when no filename is -** specified in the command. -** -** \par Limits -** The length of each string, including the NULL terminator cannot exceed the -** #OS_MAX_PATH_LEN value. -*/ -#define CFE_SB_DEFAULT_ROUTING_FILENAME "/ram/cfe_sb_route.dat" - - -/** -** \cfesbcfg Default Pipe Information Filename -** -** \par Description: -** The value of this constant defines the filename used to store the software -** bus pipe information. This filename is used only when no filename is -** specified in the command. -** -** \par Limits -** The length of each string, including the NULL terminator cannot exceed the -** #OS_MAX_PATH_LEN value. -*/ -#define CFE_SB_DEFAULT_PIPE_FILENAME "/ram/cfe_sb_pipe.dat" - - -/** -** \cfesbcfg Default Message Map Filename -** -** \par Description: -** The value of this constant defines the filename used to store the software -** bus message map information. This filename is used only when no filename is -** specified in the command. The message map is a lookup table (array of 16bit -** words) that has an element for each possible MsgId value and holds the -** routing table index for that MsgId. The Msg Map provides fast access to the -** destinations of a message. -** -** \par Limits -** The length of each string, including the NULL terminator cannot exceed the -** #OS_MAX_PATH_LEN value. -*/ -#define CFE_SB_DEFAULT_MAP_FILENAME "/ram/cfe_sb_msgmap.dat" - - -/** -** \cfesbcfg SB Event Filtering -** -** \par Description: -** This group of configuration paramters dictates what SB events will be -** filtered through EVS. The filtering will begin after the SB task initializes -** and stay in effect until a cmd to EVS changes it. -** This allows the operator to set limits on the number of event messages that -** are sent during system initialization. -** NOTE: Set all unused event values and mask values to zero -** -** \par Limits -** This filtering applies only to SB events. -** These parameters have a lower limit of 0 and an upper limit of 65535. -*/ -#define CFE_SB_FILTERED_EVENT1 CFE_SB_SEND_NO_SUBS_EID -#define CFE_SB_FILTER_MASK1 CFE_EVS_FIRST_4_STOP - -#define CFE_SB_FILTERED_EVENT2 CFE_SB_DUP_SUBSCRIP_EID -#define CFE_SB_FILTER_MASK2 CFE_EVS_FIRST_4_STOP - -#define CFE_SB_FILTERED_EVENT3 CFE_SB_MSGID_LIM_ERR_EID -#define CFE_SB_FILTER_MASK3 CFE_EVS_FIRST_16_STOP - -#define CFE_SB_FILTERED_EVENT4 CFE_SB_Q_FULL_ERR_EID -#define CFE_SB_FILTER_MASK4 CFE_EVS_FIRST_16_STOP - -#define CFE_SB_FILTERED_EVENT5 0 -#define CFE_SB_FILTER_MASK5 CFE_EVS_NO_FILTER - -#define CFE_SB_FILTERED_EVENT6 0 -#define CFE_SB_FILTER_MASK6 CFE_EVS_NO_FILTER - -#define CFE_SB_FILTERED_EVENT7 0 -#define CFE_SB_FILTER_MASK7 CFE_EVS_NO_FILTER - -#define CFE_SB_FILTERED_EVENT8 0 -#define CFE_SB_FILTER_MASK8 CFE_EVS_NO_FILTER - - -/** -** \cfeescfg Define SB Memory Pool Block Sizes -** -** \par Description: -** Software Bus Memory Pool Block Sizes -** -** \par Limits -** These sizes MUST be increasing and MUST be an integral multiple of 4. -** The number of block sizes defined cannot exceed -** #CFE_ES_MAX_MEMPOOL_BLOCK_SIZES -*/ -#define CFE_SB_MEM_BLOCK_SIZE_01 8 -#define CFE_SB_MEM_BLOCK_SIZE_02 16 -#define CFE_SB_MEM_BLOCK_SIZE_03 20 -#define CFE_SB_MEM_BLOCK_SIZE_04 36 -#define CFE_SB_MEM_BLOCK_SIZE_05 64 -#define CFE_SB_MEM_BLOCK_SIZE_06 96 -#define CFE_SB_MEM_BLOCK_SIZE_07 128 -#define CFE_SB_MEM_BLOCK_SIZE_08 160 -#define CFE_SB_MEM_BLOCK_SIZE_09 256 -#define CFE_SB_MEM_BLOCK_SIZE_10 512 -#define CFE_SB_MEM_BLOCK_SIZE_11 1024 -#define CFE_SB_MEM_BLOCK_SIZE_12 2048 -#define CFE_SB_MEM_BLOCK_SIZE_13 4096 -#define CFE_SB_MEM_BLOCK_SIZE_14 8192 -#define CFE_SB_MEM_BLOCK_SIZE_15 16384 -#define CFE_SB_MEM_BLOCK_SIZE_16 32768 -#define CFE_SB_MAX_BLOCK_SIZE (CFE_SB_MAX_SB_MSG_SIZE + 40) - -/** -** \cfesbcfg Define Default Sender Information Storage Mode -** -** \par Description: -** Defines the default mode for the storing of sender information when sending -** a software bus message. If set to 1, the sender information will be stored. -** If set to 0, the sender information will not be stored. -** -** \par Limits -** There is a lower limit of 0 and an upper limit of 1 on this configuration -** paramater. -*/ -#define CFE_SB_DEFAULT_REPORT_SENDER 1 - - -/** -** \cfetimecfg Time Server or Time Client Selection -** -** \par Description: -** This configuration parameter selects whether the Time task functions as a -** time "server" or "client". A time server generates the "time at the tone" -** packet which is received by time clients. -** -** \par Limits -** Enable one, and only one by defining either CFE_TIME_CFG_SERVER or -** CFE_TIME_CFG_CLIENT AS TRUE. The other must be defined as FALSE. -*/ -#define CFE_TIME_CFG_SERVER TRUE -#define CFE_TIME_CFG_CLIENT FALSE - -/** -** \cfetimecfg Local MET or Virtual MET Selection for Time Servers -** -** \par Description: -** Depending on the specific hardware system configuration, it may be possible -** for Time Servers to read the "local" MET from a h/w register rather than -** having to track the MET as the count of tone signal interrupts (virtual MET) -** -** Time Clients must be defined as using a virtual MET. Also, a Time Server -** cannot be defined as having both a h/w MET and an external time source (they -** both cannot synchronize to the same tone). -** -** Note: "disable" this define (set to FALSE) only for Time Servers with local hardware -** that supports a h/w MET that is synchronized to the tone signal !!! -** -** \par Limits -** Only applies if #CFE_TIME_CFG_SERVER is set to TRUE. -*/ -#define CFE_TIME_CFG_VIRTUAL TRUE - - -/** -** \cfetimecfg Include or Exclude the Primary/Redundant Tone Selection Cmd -** -** \par Description: -** Depending on the specific hardware system configuration, it may be possible -** to switch between a primary and redundant tone signal. If supported by -** hardware, this definitions will enable command interfaces to select the -** active tone signal. Both Time Clients and Time Servers support this feature. -** Note: Set the CFE_TIME_CFG_SIGNAL define to TRUE to enable tone signal commands. -** -** \par Limits -** Not Applicable -*/ -#define CFE_TIME_CFG_SIGNAL FALSE - - -/** -** \cfetimecfg Include or Exclude the Internal/External Time Source Selection Cmd -** -** \par Description: -** By default, Time Servers maintain time using an internal MET which may be a -** h/w register or software counter, depending on available hardware. The -** following definition enables command interfaces to switch between an -** internal MET, or external time data received from one of several supported -** external time sources. Only a Time Server may be configured to use external -** time data. -** Note: Set the CFE_TIME_CFG_SOURCE define to TRUE to include the Time Source -** Selection Command (command allows selection between the internal -** or external time source). Then choose the external source with the -** CFE_TIME_CFG_SRC_??? define. -** -** \par Limits -** Only applies if #CFE_TIME_CFG_SERVER is set to TRUE. -*/ -#define CFE_TIME_CFG_SOURCE FALSE - - -/** -** \cfetimecfg Choose the External Time Source for Server only -** -** \par Description: -** If #CFE_TIME_CFG_SOURCE is set to TRUE, then one of the following external time -** source types must also be set to TRUE. Do not set any of the external time -** source types to TRUE unless #CFE_TIME_CFG_SOURCE is set to TRUE. -** -** \par Limits -** -# If #CFE_TIME_CFG_SOURCE is set to TRUE then one and only one of the following -** three external time sources can and must be set TRUE: -** #CFE_TIME_CFG_SRC_MET, #CFE_TIME_CFG_SRC_GPS, #CFE_TIME_CFG_SRC_TIME -** -# Only applies if #CFE_TIME_CFG_SERVER is set to TRUE. -*/ -#define CFE_TIME_CFG_SRC_MET FALSE -#define CFE_TIME_CFG_SRC_GPS FALSE -#define CFE_TIME_CFG_SRC_TIME FALSE - - -/** -** \cfetimecfg Define the Max Delta Limits for Time Servers using an Ext Time Source -** -** \par Description: -** If #CFE_TIME_CFG_SOURCE is set to TRUE and one of the external time sources is -** also set to TRUE, then the delta time limits for range checking is used. -** -** When a new time value is received from an external source, the value is -** compared against the "expected" time value. If the delta exceeds the -** following defined amount, then the new time data will be ignored. This range -** checking is only performed after the clock state has been commanded to -** "valid". Until then, external time data is accepted unconditionally. -** -** \par Limits -** Applies only if both #CFE_TIME_CFG_SERVER and #CFE_TIME_CFG_SOURCE are set -** to TRUE. -*/ -#define CFE_TIME_MAX_DELTA_SECS 0 -#define CFE_TIME_MAX_DELTA_SUBS 500000 - - -/** -** \cfetimecfg Define the Local Clock Rollover Value in seconds and subseconds -** -** \par Description: -** Specifies the capability of the local clock. Indicates the time at which -** the local clock rolls over. -** -** \par Limits -** Not Applicable -*/ -#define CFE_TIME_MAX_LOCAL_SECS 27 -#define CFE_TIME_MAX_LOCAL_SUBS 0 - - -/** -** \cfetimecfg Define Timing Limits From One Tone To The Next -** -** \par Description: -** Defines limits to the timing of the 1Hz tone signal. A tone signal is valid -** only if it arrives within one second (plus or minus the tone limit) from -** the previous tone signal.Units are microseconds as measured with the local -** clock. -** -** \par Limits -** Not Applicable -*/ -#define CFE_TIME_CFG_TONE_LIMIT 20000 - - - -/** -** \cfetimecfg Define Time to Start Flywheel Since Last Tone -** -** \par Description: -** Define time to enter flywheel mode (in seconds since last tone data update) -** Units are microseconds as measured with the local clock. -** -** \par Limits -** Not Applicable -*/ -#define CFE_TIME_CFG_START_FLY 2 - - -/** -** \cfetimecfg Define Periodic Time to Update Local Clock Tone Latch -** -** \par Description: -** Define Periodic Time to Update Local Clock Tone Latch. Applies only when -** in flywheel mode. This define dicates the period at which the simulated -** 'last tone' time is updated. Units are seconds. -** -** \par Limits -** Not Applicable -*/ -#define CFE_TIME_CFG_LATCH_FLY 8 - - -/** -** \cfetimecfg Define Maximum number of Time Synchronization Callbacks allowed -** -** \par Description: -** Define maximum number of Time Synchronization callback functions allowed. -** Each callback is called whenever cFE TIME receives a valid time synchronization -** signal (typically 1 Hz). -** -** \par Limits -** Not Applicable -*/ -#define CFE_TIME_MAX_NUM_SYNCH_FUNCS 4 - - -/** -** \cfetimecfg Enable (or disable) the 1HZ time command packet -** -** \par Description: -** Controls the generation of a packet that may be used as a 1HZ wakeup -** signal for applications that subscribe to CFE_TIME_1HZ_CMD_MID. -** Disable the packet to avoid 'no subscriber' errors that result from -** sending a packet when there are no subscribers to the packet. -** -** \par Limits -** Enable the 1HZ packet by setting #CFE_TIME_ENA_1HZ_CMD_PKT to TRUE. -** Disable the 1HZ packet by setting #CFE_TIME_ENA_1HZ_CMD_PKT to FALSE. -*/ -#define CFE_TIME_ENA_1HZ_CMD_PKT TRUE - - -/** -** \cfeescfg Define Max Number of Applications -** -** \par Description: -** Defines the maximum number of applications that can be loaded into the -** system. This number does not include child tasks. -** -** \par Limits -** There is a lower limit of 6 and an upper limit of 64 on this configuration -** paramater. The lower limit corresponds to the cFE internal applications. -*/ -#define CFE_ES_MAX_APPLICATIONS 32 - - -/** -** \cfeescfg Define Max Number of Shared libraries -** -** \par Description: -** Defines the maximum number of cFE Shared libraries that can be loaded into -** the system. -** -** \par Limits -** There is a lower limit of 1 and an upper limit of 64 on this configuration -** paramater. -*/ -#define CFE_ES_MAX_LIBRARIES 10 - -/** -** \cfeescfg Define Max Number of ER (Exception and Reset) log entries -** -** \par Description: -** Defines the maximum number of ER (Exception and Reset) log entries -** -** \par Limits -** There is a lower limit of 10 and an upper limit of 128 on this configuration -** paramater. -*/ -#define CFE_ES_ER_LOG_ENTRIES 20 - -/** \cfeescfg Maximum size of CPU Context in ES Error Log -** -** \par Description: -** This should be large enough to accommodate the CPU context -** information supplied by the PSP on the given platform. -** -** \par Limits: -** Must be greater than zero and a multiple of sizeof(uint32). -** Limited only by the available memory and the number of entries -** in the error log. Any context information beyond this size will -** be truncated. -*/ -#define CFE_ES_ER_LOG_MAX_CONTEXT_SIZE 128 - - -/** -** \cfeescfg Define Size of the cFE System Log. -** -** \par Description: -** Defines the size in bytes of the cFE system log. The system log holds -** variable length strings that are terminated by a linefeed and null -** character. -** -** \par Limits -** There is a lower limit of 512 and an upper limit of 16384 on this -** configuration paramater. -*/ -#define CFE_ES_SYSTEM_LOG_SIZE 3072 - - -/** -** \cfeescfg Define Number of entries in the ES Object table -** -** \par Description: -** Defines the number of entries in the ES Object table. This table controls -** the core cFE startup. -** -** \par Limits -** There is a lower limit of 15 and an upper limit of 50 on this configuration -** paramater. -*/ -#define CFE_ES_OBJECT_TABLE_SIZE 30 - - -/** -** \cfeescfg Define Max Number of Generic Counters -** -** \par Description: -** Defines the maximum number of Generic Counters that can be registered. -** -** \par Limits -** This parameter has a lower limit of 1 and an upper limit of 65535. -*/ -#define CFE_ES_MAX_GEN_COUNTERS 8 - - -/** -** \cfeescfg Define ES Application Control Scan Rate -** -** \par Description: -** ES Application Control Scan Rate. This parameter controls the speed that ES -** scans the Application Table looking for App Delete/Restart/Reload requests. -** All Applications are deleted, restarted, or reloaded by the ES Application. -** ES will periodically scan for control requests to process. The scan rate is -** controlled by this parameter, which is given in milliseconds. A value of -** 1000 means that ES will scan the Application Table once per second. Be -** careful not to set the value of this too low, because ES will use more CPU -** cycles scanning the table. -** -** \par Limits -** There is a lower limit of 100 and an upper limit of 20000 on this -** configuration paramater. millisecond units. -*/ -#define CFE_ES_APP_SCAN_RATE 1000 - - -/** -** \cfeescfg Define ES Application Kill Timeout -** -** \par Description: -** ES Application Kill Timeout. This parameter controls the number of -** "scan periods" that ES will wait for an application to Exit after getting -** the signal Delete, Reload or Restart. The sequence works as follows: -** -# ES will set the control request for an App to Delete/Restart/Reload and -** set this kill timer to the value in this parameter. -** -# If the App is reponding and Calls it's RunLoop function, it will drop out -** of it's main loop and call CFE_ES_ExitApp. Once it calls Exit App, then -** ES can delete, restart, or reload the app the next time it scans the app -** table. -** -# If the App is not responding, the ES App will decrement this Kill Timeout -** value each time it runs. If the timeout value reaches zero, ES will kill -** the app. -** -** The Kill timeout value depends on the #CFE_ES_APP_SCAN_RATE. If the Scan Rate -** is 1000, or 1 second, and this #CFE_ES_APP_KILL_TIMEOUT is set to 5, then it -** will take 5 seconds to kill a non-responding App. -** If the Scan Rate is 250, or 1/4 second, and the #CFE_ES_APP_KILL_TIMEOUT is -** set to 2, then it will take 1/2 second to time out. -** -** \par Limits -** There is a lower limit of 1 and an upper limit of 100 on this configuration -** paramater. Units are number of #CFE_ES_APP_SCAN_RATE cycles. -*/ -#define CFE_ES_APP_KILL_TIMEOUT 5 - - -/** -** \cfeescfg ES Ram Disk Sector Size -** -** \par Description: -** Defines the ram disk sector size. The ram disk is 1 of 4 memory areas that -** are preserved on a processor reset. -** NOTE: Changing this value changes memory allocation, and may -** require changes to platform specific values (in CFE_PSP) such as -** USER_RESERVED_MEM in VxWorks depending on the memory areas -** being used for preserved data and on OS specific behavior. -** -** \par Limits -** There is a lower limit of 128 and an upper limit of 4096 on this -** configuration paramater. -*/ -#define CFE_ES_RAM_DISK_SECTOR_SIZE 512 - - -/** -** \cfeescfg ES Ram Disk Number of Sectors -** -** \par Description: -** Defines the ram disk number of sectors. The ram disk is one of four memory -** areas that are preserved on a processor reset. -** NOTE: Changing this value changes memory allocation, and may -** require changes to platform specific values (in CFE_PSP) such as -** USER_RESERVED_MEM in VxWorks depending on the memory areas -** being used for preserved data and on OS specific behavior. -** -** \par Limits -** There is a lower limit of 128 and an upper limit of 8192 on this -** configuration paramater. -*/ -#define CFE_ES_RAM_DISK_NUM_SECTORS 4096 - -/** -** \cfeescfg Percentage of Ram Disk Reserved for Decompressing Apps -** -** \par Description: -** The #CFE_ES_RAM_DISK_PERCENT_RESERVED parameter is used to make sure that the -** Volatile ( RAM ) Disk has a defined amount of free space during a processor -** reset. The cFE uses the Volatile disk to decompress cFE applications during -** system startup. If this Volatile disk happens to get filled with logs and -** misc files, then a processor reset may not work, because there will be no -** room to decompress cFE apps. To solve that problem, this parameter sets the -** "Low Water Mark" for disk space on a Processor reset. It should be set to -** allow the largest cFE Application to be decompressed. -** During a Processor reset, if there is not sufficient space left on the disk, -** it will be re-formatted in order to clear up some space. -** -** This feature can be turned OFF by setting the parameter to 0. -** -** \par Limits -** There is a lower limit of 0 and an upper limit of 75 on this configuration -** paramater.Units are percentage. A setting of zero will turn this feature -** off. -*/ -#define CFE_ES_RAM_DISK_PERCENT_RESERVED 30 - - -/** -** \cfeescfg RAM Disk Mount string -** -** \par Description: -** The #CFE_ES_RAM_DISK_MOUNT_STRING parameter is used to set the cFE mount path -** for the CFE RAM disk. This is a parameter for missions that do not want to -** use the default value of "/ram", or for missions that need to have a different -** value for different CPUs or Spacecraft. -** Note that the vxWorks OSAL cannot currently handle names that have more than one -** path separator in it. The names "/ram", "/ramdisk", "/disk123" will all work, but -** "/disks/ram" will not. -** Multiple separators can be used with the posix or RTEMS ports. -** -*/ -#define CFE_ES_RAM_DISK_MOUNT_STRING "/ram" - - -/** -** \cfeescfg Define Critical Data Store Size -** -** \par Description: -** Defines the Critical Data Store (CDS) area size in bytes size. The CDS is -** one of four memory areas that are preserved during a processor reset. -** NOTE: Changing this value changes memory allocation, and may -** require changes to platform specific values (in CFE_PSP) such as -** USER_RESERVED_MEM in VxWorks depending on the memory areas -** being used for preserved data and on OS specific behavior. -** -** \par Limits -** There is a lower limit of 8192 and an upper limit of 2097152 (2MBytes) on -** this configuration paramater. -*/ -#define CFE_ES_CDS_SIZE ( 128 * 1024 ) - - -/** -** \cfeescfg Define User Reserved Memory Size -** -** \par Description: -** User Reserved Memory Size. This is the size in bytes of the cFE User -** reserved Memory area. This is a block of memory that is available for cFE -** application use. The address is obtained by calling -** #CFE_PSP_GetUserReservedArea. The User Reserved Memory is one of four memory -** areas that are preserved during a processor reset. -** NOTE: Changing this value changes memory allocation, and may -** require changes to platform specific values (in CFE_PSP) such as -** USER_RESERVED_MEM in VxWorks depending on the memory areas -** being used for preserved data and on OS specific behavior. -** -** \par Limits -** There is a lower limit of 1024 and an upper limit of 33554432 (32Mbytes) on -** this configuration paramater. -*/ -#define CFE_ES_USER_RESERVED_SIZE ( 1024 * 1024 ) - - -/** -** \cfeescfg Define ES Reset Area Size -** -** \par Description: -** The ES Reset Area Size. This is the size in bytes of the cFE Reset variable -** and log area. This is a block of memory used by the cFE to store the system -** log ER Log and critical reset variables. This is 4 of 4 of the memory areas -** that are preserved during a processor reset. -** Note: This area must be sized large enough to hold all of the data -** structures. It should be automatically sized based on the #CFE_ES_ResetData_t -** type, but circular dependancies in the headers prevent it from being defined -** this way. -** NOTE: Changing this value changes memory allocation, and may -** require changes to platform specific values (in CFE_PSP) such as -** USER_RESERVED_MEM in VxWorks depending on the memory areas -** being used for preserved data and on OS specific behavior. -** -** \par Limits -** There is a lower limit of 153600 (150KBytes) and an upper limit of 2097152 -** (2MBytes) on this configuration paramater. -*/ -#define CFE_ES_RESET_AREA_SIZE ( 170 * 1024 ) - -/** -** \cfeescfg Define Default Memory Pool Alignment Mode -** -** \par Description: -** Defines the default mode for the requirement to align ES Mempool buffer. -** If this define is set, the memory pool must be aligned or the call to -** create a new memory pool will be rejected with a CFE_ES_BAD_ARGUMENT -** return code. -** -** \par Limits -** If CFE_ES_MEMPOOL_ALIGNED is defined, the alignment check is enabled. -** If CFE_ES_MEMPOOL_ALIGNED is not defined, the alignment check is not -** compiled in. -*/ -#define CFE_ES_MEMPOOL_ALIGNED 1 - -/** -** \cfeescfg ES Nonvolatile Startup Filename -** -** \par Description: -** The value of this constant defines the path and name of the file that -** contains a list of modules that will be loaded and started by the cFE after -** the cFE finishes its startup sequence. -** -** \par Limits -** The length of each string, including the NULL terminator cannot exceed the -** #OS_MAX_PATH_LEN value. -*/ -#define CFE_ES_NONVOL_STARTUP_FILE "/cf/apps/cfe_es_startup.scr" - - -/** -** \cfeescfg ES Volatile Startup Filename -** -** \par Description: -** The value of this constant defines the path and name of the file that -** contains a list of modules that will be loaded and started by the cFE after -** the cFE finishes its startup sequence. -** -** \par Limits -** The length of each string, including the NULL terminator cannot exceed the -** #OS_MAX_PATH_LEN value. -*/ -#define CFE_ES_VOLATILE_STARTUP_FILE "/ram/apps/cfe_es_startup.scr" - -/** -** \cfeescfg Default Shell Filename -** -** \par Description: -** The value of this constant defines the filename used to store the shell -** output after a shell command is received by ES. This file contains the -** entire shell output. The fsw also sends the shell output in series of fixed -** size telemetry packets. This filename is used only when no filename -** is specified in the shell command. -** -** \par Limits -** The length of each string, including the NULL terminator cannot exceed the -** #OS_MAX_PATH_LEN value. -*/ -#define CFE_ES_DEFAULT_SHELL_FILENAME "/ram/ShellCmd.out" - - -/** -** \cfeescfg Define Max Shell Command Size -** -** \par Description: -** Defines the maximum size in characters of the shell command. -** -** \par Limits -** There is a lower limit of 64 and an upper limit of 128 on this configuration -** paramater. Units are characters. -*/ -#define CFE_ES_MAX_SHELL_CMD 64 - - -/** -** \cfeescfg Define Shell Command Telemetry Pkt Segment Size -** -** \par Description: -** Defines the size of the shell command tlm packet segments.The shell command -** output size is dependant on the shell command itself. If the shell output -** size is greater than the size of the packet defined here, the fsw will -** generate a series of tlm packets (of the size defined here) that can be -** reconstructed by the ground system. -** -** \par Limits -** There is a lower limit of 32 and an upper limit of 128 on this configuration -** paramater. -*/ -#define CFE_ES_MAX_SHELL_PKT 64 - - -/** -** \cfeescfg Default Application Information Filename -** -** \par Description: -** The value of this constant defines the filename used to store information -** pertaining to all of the Applications that are registered with Executive -** Services. This filename is used only when no filename is specified in the -** the command to query all system apps. -** -** \par Limits -** The length of each string, including the NULL terminator cannot exceed the -** #OS_MAX_PATH_LEN value. -*/ -#define CFE_ES_DEFAULT_APP_LOG_FILE "/ram/cfe_es_app_info.log" - -/** -** \cfeescfg Default Application Information Filename -** -** \par Description: -** The value of this constant defines the filename used to store information -** pertaining to all of the Applications that are registered with Executive -** Services. This filename is used only when no filename is specified in the -** the command to query all system tasks. -** -** \par Limits -** The length of each string, including the NULL terminator cannot exceed the -** #OS_MAX_PATH_LEN value. -*/ -#define CFE_ES_DEFAULT_TASK_LOG_FILE "/ram/cfe_es_task_info.log" - -/** -** \cfeescfg Default System Log Filename -** -** \par Description: -** The value of this constant defines the filename used to store important -** information (as ASCII text strings) that might not be able to be sent in an -** Event Message. This filename is used only when no filename is specified in -** the command to dump the system log. No file specified in the cmd means the -** first character in the cmd filename is a NULL terminator (zero). -** -** \par Limits -** The length of each string, including the NULL terminator cannot exceed the -** #OS_MAX_PATH_LEN value. -*/ -#define CFE_ES_DEFAULT_SYSLOG_FILE "/ram/cfe_es_syslog.log" - -/** -** \cfeescfg Default Exception and Reset (ER) Log Filename -** -** \par Description: -** The value of this constant defines the filename used to store the -** Exception and Reset (ER) Log. This filename is used only when no filename is -** specified in the command to dump the ER log. No file specified in the cmd -** means the first character in the cmd filename is a NULL terminator (zero). -** -** \par Limits -** The length of each string, including the NULL terminator cannot exceed the -** #OS_MAX_PATH_LEN value. -*/ -#define CFE_ES_DEFAULT_ER_LOG_FILE "/ram/cfe_erlog.log" - -/** -** \cfeescfg Default Performance Data Filename -** -** \par Description: -** The value of this constant defines the filename used to store the -** Performance Data. This filename is used only when no filename is specified -** in the command to stop performance data collecting. -** -** \par Limits -** The length of each string, including the NULL terminator cannot exceed the -** #OS_MAX_PATH_LEN value. -*/ -#define CFE_ES_DEFAULT_PERF_DUMP_FILENAME "/ram/cfe_es_perf.dat" - - -/** -** \cfeescfg Default Critical Data Store Registry Filename -** -** \par Description: -** The value of this constant defines the filename used to store the -** Critical Data Store Registry. This filename is used only when no filename is -** specified in the command to stop performance data collecting. -** -** \par Limits -** The length of each string, including the NULL terminator cannot exceed the -** #OS_MAX_PATH_LEN value. -*/ -#define CFE_ES_DEFAULT_CDS_REG_DUMP_FILE "/ram/cfe_cds_reg.log" - -/** -** \cfeescfg Define Default System Log Mode -** -** \par Description: -** Defines the default mode for the operation of the ES System log. The log may -** operate in either Overwrite mode = 0, where once the log becomes full the -** oldest message in the log will be overwritten, or Discard mode = 1, where -** once the log becomes full the contents of the log are preserved and the new -** event is discarded. This constant may hold a value of either 0 or 1 -** depending on the desired default log mode. Overwrite Mode = 0, Discard -** Mode = 1. -** -** \par Limits -** There is a lower limit of 0 and an upper limit of 1 on this configuration -** paramater. -*/ -#define CFE_ES_DEFAULT_SYSLOG_MODE 1 - -/** -** \cfeescfg Define Max Number of Performance IDs -** -** \par Description: -** Defines the maximum number of perf ids allowed. -** -** -** \par Limits -** This number must always be divisible by 32. There is a lower limit of 32 and -** an upper limit of 512 on this configuration paramater. -*/ -#define CFE_ES_PERF_MAX_IDS 128 - -/** -** \cfeescfg Define Max Size of Performance Data Buffer -** -** \par Description: -** Defines the maximum size of the performance data buffer. Units are number of -** performance data entries. An entry is defined by a 32 bit data word followed -** by a 64 bit time stamp. -** -** \par Limits -** There is a lower limit of 1025 and an upper limit of 1048576 (1 Meg) on this -** configuration paramater. The units are number of entries. An entry is -** defined by a 32 bit data word followed by a 64 bit time stamp. -*/ -#define CFE_ES_PERF_DATA_BUFFER_SIZE 10000 - - -/** -** \cfeescfg Define Filter Mask Setting for Disabling All Performance Entries -** -** \par Description: -** Defines the filter mask for disabling all performance entries. The value is a -** bit mask. For each bit, 0 means the corresponding entry is disabled and -** 1 means it is enabled. -*/ -#define CFE_ES_PERF_FILTMASK_NONE 0 - -/** -** \cfeescfg Define Filter Mask Setting for Enabling All Performance Entries -** -** \par Description: -** Defines the filter mask for enabling all performance entries. The value is a -** bit mask. For each bit, 0 means the corresponding entry is disabled and -** 1 means it is enabled. -*/ -#define CFE_ES_PERF_FILTMASK_ALL ~CFE_ES_PERF_FILTMASK_NONE - -/** -** \cfeescfg Define Default Filter Mask Setting for Performance Data Buffer -** -** \par Description: -** Defines the default filter mask for the performance data buffer. The value is a -** bit mask. For each bit, 0 means the corresponding entry is disabled and 1 -** means it is enabled. -** -*/ -#define CFE_ES_PERF_FILTMASK_INIT CFE_ES_PERF_FILTMASK_ALL - - -/** -** \cfeescfg Define Default Filter Trigger Setting for Disabling All Performance Entries -** -** \par Description: -** Defines the default trigger mask for disabling all performance data entries. The value -** is a bit mask. For each bit, 0 means the trigger for the corresponding entry is -** disabled and 1 means it is enabled. -** -*/ -#define CFE_ES_PERF_TRIGMASK_NONE 0 - -/** -** \cfeescfg Define Filter Trigger Setting for Enabling All Performance Entries -** -** \par Description: -** Defines the trigger mask for enabling all performance data entries. The value is -** a bit mask. For each bit, 0 means the trigger for the corresponding entry is -** disabled and 1 means it is enabled. -** -*/ -#define CFE_ES_PERF_TRIGMASK_ALL ~CFE_ES_PERF_TRIGMASK_NONE - -/** -** \cfeescfg Define Default Filter Trigger Setting for Performance Data Buffer -** -** \par Description: -** Defines the default trigger mask for the performance data buffer. The value is a -** 32-bit mask. For each bit, 0 means the trigger for the corresponding entry is -** disabled and 1 means it is enabled. -** -*/ -#define CFE_ES_PERF_TRIGMASK_INIT CFE_ES_PERF_TRIGMASK_NONE - -/** -** \cfeescfg Define Performance Analyzer Child Task Priority -** -** \par Description: -** This parameter defines the priority of the child task spawed by the -** Executive Services to write performance data to a file. Lower numbers -** are higher priority, with 1 being the highest priority in the case of a -** child task. -** -** \par Limits -** Valid range for a child task is 1 to 255 however, the priority cannot -** be higher (lower number) than the ES parent application priority. -*/ -#define CFE_ES_PERF_CHILD_PRIORITY 200 - -/** -** \cfeescfg Define Performance Analyzer Child Task Stack Size -** -** \par Description: -** This parameter defines the stack size of the child task spawed by the -** Executive Services to write performance data to a file. -** -** \par Limits -** It is recommended this parameter be greater than or equal to 4KB. This parameter -** is limited by the maximum value allowed by the data type. In this case, the data -** type is an unsigned 32-bit integer, so the valid range is 0 to 0xFFFFFFFF. -*/ -#define CFE_ES_PERF_CHILD_STACK_SIZE 4096 - -/** -** \cfeescfg Define Performance Analyzer Child Task Delay -** -** \par Description: -** This parameter defines the delay time (in milliseconds) between performance -** data file writes performed by the Executive Services Performace Analyzer -** Child Task. -** -** \par Limits -** It is recommended this parameter be greater than or equal to 20ms. This parameter -** is limited by the maximum value allowed by the data type. In this case, the data -** type is an unsigned 32-bit integer, so the valid range is 0 to 0xFFFFFFFF. -*/ -#define CFE_ES_PERF_CHILD_MS_DELAY 20 - -/** -** \cfeescfg Define Performance Analyzer Child Task Number of Entries Between Delay -** -** \par Description: -** This parameter defines the number of performace analyzer entries the Performace -** Analyzer Child Task will write to the file between delays. -** -*/ -#define CFE_ES_PERF_ENTRIES_BTWN_DLYS 50 - -/** -** \cfeescfg Define Default Stack Size for an Application -** -** \par Description: -** This parameter defines a default stack size. This parameter is used by the -** cFE Core Applications. -** -** \par Limits -** There is a lower limit of 2048 and an upper limit of 16384 on this -** configuration paramater. -*/ -#define CFE_ES_DEFAULT_STACK_SIZE 8192 - -/** -** \cfeescfg Define cFE Core Exception Function -** -** \par Description: -** This parameter defines the function-to-call when an exception occurs in -** the cFE core. -** -** \par Limits -** Must be a valid function name. -*/ -#define CFE_ES_EXCEPTION_FUNCTION CFE_ES_ProcessCoreException - -/** -** \cfeescfg Define EVS Task Priority -** -** \par Description: -** Defines the cFE_EVS Task priority. -** -** \par Limits -** Not Applicable -*/ -#define CFE_EVS_START_TASK_PRIORITY 61 - -/** -** \cfeescfg Define EVS Task Stack Size -** -** \par Description: -** Defines the cFE_EVS Task Stack Size -** -** \par Limits -** There is a lower limit of 2048 and an upper limit of 16384 on this -** configuration paramater. -*/ -#define CFE_EVS_START_TASK_STACK_SIZE CFE_ES_DEFAULT_STACK_SIZE - -/** -** \cfeescfg Define SB Task Priority -** -** \par Description: -** Defines the cFE_SB Task priority. -** -** \par Limits -** Not Applicable -*/ -#define CFE_SB_START_TASK_PRIORITY 64 - -/** -** \cfeescfg Define SB Task Stack Size -** -** \par Description: -** Defines the cFE_SB Task Stack Size -** -** \par Limits -** There is a lower limit of 2048 and an upper limit of 16384 on this -** configuration paramater. -*/ -#define CFE_SB_START_TASK_STACK_SIZE CFE_ES_DEFAULT_STACK_SIZE - -/** -** \cfeescfg Define ES Task Priority -** -** \par Description: -** Defines the cFE_ES Task priority. -** -** \par Limits -** Not Applicable -*/ -#define CFE_ES_START_TASK_PRIORITY 68 - -/** -** \cfeescfg Define ES Task Stack Size -** -** \par Description: -** Defines the cFE_ES Task Stack Size -** -** \par Limits -** There is a lower limit of 2048 and an upper limit of 16384 on this -** configuration paramater. -*/ -#define CFE_ES_START_TASK_STACK_SIZE 16384 - -/** -** \cfetimecfg Define TIME Task Priorities -** -** \par Description: -** Defines the cFE_TIME Task priority. -** Defines the cFE_TIME Tone Task priority. -** Defines the cFE_TIME 1HZ Task priority. -** -** \par Limits -** There is a lower limit of zero and an upper limit of 255 on these -** configuration paramaters. Remember that the meaning of each task -** priority is inverted -- a "lower" number has a "higher" priority. -*/ -#define CFE_TIME_START_TASK_PRIORITY 60 -#define CFE_TIME_TONE_TASK_PRIORITY 25 -#define CFE_TIME_1HZ_TASK_PRIORITY 25 - -/** -** \cfetimecfg Define TIME Task Stack Sizes -** -** \par Description: -** Defines the cFE_TIME Main Task Stack Size -** Defines the cFE_TIME Tone Task Stack Size -** Defines the cFE_TIME 1HZ Task Stack Size -** -** \par Limits -** There is a lower limit of 2048 and an upper limit of 16384 on these -** configuration paramaters. -*/ -#define CFE_TIME_START_TASK_STACK_SIZE CFE_ES_DEFAULT_STACK_SIZE -#define CFE_TIME_TONE_TASK_STACK_SIZE 4096 -#define CFE_TIME_1HZ_TASK_STACK_SIZE 8192 - -/** -** \cfeescfg Define TBL Task Priority -** -** \par Description: -** Defines the cFE_TBL Task priority. -** -** \par Limits -** Not Applicable -*/ -#define CFE_TBL_START_TASK_PRIORITY 70 - -/** -** \cfeescfg Define TBL Task Stack Size -** -** \par Description: -** Defines the cFE_TBL Task Stack Size -** -** \par Limits -** There is a lower limit of 2048 and an upper limit of 16384 on this -** configuration paramater. -*/ -#define CFE_TBL_START_TASK_STACK_SIZE CFE_ES_DEFAULT_STACK_SIZE - -/** -** \cfeescfg Define Maximum Number of Registered CDS Blocks -** -** \par Description: -** Maximum number of registered CDS Blocks -** -** \par Limits -** There is a lower limit of 8 and an upper limit of 32767 on this configuration -** paramater. -*/ -#define CFE_ES_CDS_MAX_NUM_ENTRIES 512 - - -/** -** \cfeescfg Define Number of Processor Resets Before a Power On Reset -** -** \par Description: -** Number of Processor Resets before a Power On Reset is called. If set to 2, -** then 2 processor resets will occur, and the 3rd processor reset will be a -** power on reset instead. -** -** \par Limits -** There is a lower limit of 0 and an upper limit of 1024 on this configuration -** paramater. -*/ -#define CFE_ES_MAX_PROCESSOR_RESETS 2 - - -/** -** \cfeescfg Define Default ES Memory Pool Block Sizes -** -** \par Description: -** Default Intermediate ES Memory Pool Block Sizes. If an application -** is using the CFE_ES Memory Pool APIs (#CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, -** #CFE_ES_GetPoolBuf and #CFE_ES_PutPoolBuf) but finds these sizes -** inappropriate for their use, they may wish to use the #CFE_ES_PoolCreateEx -** API to specify their own intermediate block sizes -** -** \par Limits -** These sizes MUST be increasing and MUST be an integral multiple of 4. Also, -** CFE_ES_MAX_BLOCK_SIZE must be larger than CFE_SB_MAX_SB_MSG_SIZE and both -** CFE_TBL_MAX_SNGL_TABLE_SIZE and CFE_TBL_MAX_DBL_TABLE_SIZE. Note that if Table -** Services have been removed from the CFE, the table size limits are still -** enforced although the table size definitions may be reduced. Refer to the CFS -** Deployment Guide for information about removing CFE Table Services from the CFE. -*/ -#define CFE_ES_MEM_BLOCK_SIZE_01 8 -#define CFE_ES_MEM_BLOCK_SIZE_02 16 -#define CFE_ES_MEM_BLOCK_SIZE_03 32 -#define CFE_ES_MEM_BLOCK_SIZE_04 48 -#define CFE_ES_MEM_BLOCK_SIZE_05 64 -#define CFE_ES_MEM_BLOCK_SIZE_06 96 -#define CFE_ES_MEM_BLOCK_SIZE_07 128 -#define CFE_ES_MEM_BLOCK_SIZE_08 160 -#define CFE_ES_MEM_BLOCK_SIZE_09 256 -#define CFE_ES_MEM_BLOCK_SIZE_10 512 -#define CFE_ES_MEM_BLOCK_SIZE_11 1024 -#define CFE_ES_MEM_BLOCK_SIZE_12 2048 -#define CFE_ES_MEM_BLOCK_SIZE_13 4096 -#define CFE_ES_MEM_BLOCK_SIZE_14 8192 -#define CFE_ES_MEM_BLOCK_SIZE_15 16384 -#define CFE_ES_MEM_BLOCK_SIZE_16 32768 -#define CFE_ES_MAX_BLOCK_SIZE 80000 - - -/** -** \cfeescfg Define ES Critical Data Store Memory Pool Block Sizes -** -** \par Description: -** Intermediate ES Critical Data Store Memory Pool Block Sizes -** -** \par Limits -** These sizes MUST be increasing and MUST be an integral multiple of 4. -*/ -#define CFE_ES_CDS_MEM_BLOCK_SIZE_01 8 -#define CFE_ES_CDS_MEM_BLOCK_SIZE_02 16 -#define CFE_ES_CDS_MEM_BLOCK_SIZE_03 32 -#define CFE_ES_CDS_MEM_BLOCK_SIZE_04 48 -#define CFE_ES_CDS_MEM_BLOCK_SIZE_05 64 -#define CFE_ES_CDS_MEM_BLOCK_SIZE_06 96 -#define CFE_ES_CDS_MEM_BLOCK_SIZE_07 128 -#define CFE_ES_CDS_MEM_BLOCK_SIZE_08 160 -#define CFE_ES_CDS_MEM_BLOCK_SIZE_09 256 -#define CFE_ES_CDS_MEM_BLOCK_SIZE_10 512 -#define CFE_ES_CDS_MEM_BLOCK_SIZE_11 1024 -#define CFE_ES_CDS_MEM_BLOCK_SIZE_12 2048 -#define CFE_ES_CDS_MEM_BLOCK_SIZE_13 4096 -#define CFE_ES_CDS_MEM_BLOCK_SIZE_14 8192 -#define CFE_ES_CDS_MEM_BLOCK_SIZE_15 16384 -#define CFE_ES_CDS_MEM_BLOCK_SIZE_16 32768 -#define CFE_ES_CDS_MAX_BLOCK_SIZE 80000 - - - -/** -** \cfeevscfg Define Maximum Number of Event Filters per Application -** -** \par Description: -** Maximum number of events that may be filtered per application. -** -** \par Limits -** There is an upper limit of 32767 on this configuration paramater. -*/ -#define CFE_EVS_MAX_EVENT_FILTERS 8 - - -/** -** \cfeevscfg Enable or Disable EVS Local Event Log -** -** \par Description: -** The CFE_EVS_LOG_ON configuration parameter must be defined to enable EVS -** event logging. In order to disable the local event log this definition needs -** to be commented out. -** -** \par Limits -** Not Applicable -*/ -#define CFE_EVS_LOG_ON - - -/** -** \cfeevscfg Default Event Log Filename -** -** \par Description: -** The value of this constant defines the filename used to store the Event -** Services local event log. This filename is used only when no filename is -** specified in the command to dump the event log. -** -** \par Limits -** The length of each string, including the NULL terminator cannot exceed the -** #OS_MAX_PATH_LEN value. -*/ -#define CFE_EVS_DEFAULT_LOG_FILE "/ram/cfe_evs.log" - - -/** -** \cfeevscfg Maximum Number of Events in EVS Local Event Log -** -** \par Description: -** Dictates the EVS local event log capacity. Units are the number of events. -** -** \par Limits -** There is an upper limit of 65535 on this configuration paramater. -*/ -#define CFE_EVS_LOG_MAX 20 - - -/** -** \cfeevscfg Default EVS Application Data Filename -** -** \par Description: -** The value of this constant defines the filename used to store the EVS -** Application Data(event counts/filtering information). This filename is -** used only when no filename is specified in the command to dump the event -** log. -** -** \par Limits -** The length of each string, including the NULL terminator cannot exceed the -** #OS_MAX_PATH_LEN value. -*/ -#define CFE_EVS_DEFAULT_APP_DATA_FILE "/ram/cfe_evs_app.dat" - - -/** -** \cfeevscfg Default EVS Output Port State -** -** \par Description: -** Defines the default port state (enabled or deisabled) for the four output -** ports defined within the Event Service. Port 1 is usually the uart output -** terminal. To enable a port, set the proper bit to a 1. Bit 0 is port 1, -** bit 1 is port2 etc. -** -** \par Limits -** The valid settings are 0x0 to 0xF. -*/ -#define CFE_EVS_PORT_DEFAULT 0x0001 - - -/** -** \cfeevscfg Default EVS Event Type Filter Mask -** -** \par Description: -** Defines a state of on or off for all four event types. The term event -** 'type' refers to the criticality level and may be Debug, Informational, -** Error or Critical. Each event type has a bit position. (bit 0 = Debug, -** bit 1 = Info, bit 2 = Error, bit 3 = Critical). This is a global setting, -** meaning it applies to all applications. To filter an event type, set its -** bit to zero. For example, -** 0xE means Debug = OFF, Info = ON, Error = ON, Critical = ON -** -** \par Limits -** The valid settings are 0x0 to 0xF. -*/ -#define CFE_EVS_DEFAULT_TYPE_FLAG 0xE - - - -/** -** \cfeevscfg Default EVS Local Event Log Mode -** -** \par Description: -** Defines a state of overwrite(0) or discard(1) for the operation of the -** EVS local event log. The log may operate in either Overwrite mode = 0, -** where once the log becomes full the oldest event in the log will be -** overwritten, or Discard mode = 1, where once the log becomes full the -** contents of the log are preserved and the new event is discarded. -** Overwrite Mode = 0, Discard Mode = 1. -** -** \par Limits -** The valid settings are 0 or 1 -*/ -#define CFE_EVS_DEFAULT_LOG_MODE 1 - - -/** -** \cfeevscfg Default EVS Message Format Mode -** -** \par Description: -** Defines the default message format (long or short) for event messages being -** sent to the ground. Choose between #CFE_EVS_LONG_FORMAT or -** #CFE_EVS_SHORT_FORMAT. -** -** \par Limits -** The valid settings are #CFE_EVS_LONG_FORMAT or #CFE_EVS_SHORT_FORMAT -*/ -#define CFE_EVS_DEFAULT_MSG_FORMAT_MODE CFE_EVS_LONG_FORMAT - - - -/* Platform Configuration Parameters for Table Service (TBL) */ - -/** -** \cfetblcfg Size of Table Services Table Memory Pool -** -** \par Description: -** Defines the TOTAL size of the memory pool that cFE Table Services allocates -** from the system. The size must be large enough to provide memory for each -** registered table, the inactive buffers for double buffered tables and for -** the shared inactive buffers for single buffered tables. -** -** \par Limits -** The cFE does not place a limit on the size of this parameter. -*/ -#define CFE_TBL_BUF_MEMORY_BYTES 524288 - -/** -** \cfetblcfg Maximum Size Allowed for a Double Buffered Table -** -** \par Description: -** Defines the maximum allowed size (in bytes) of a double buffered table. -** -** \par Limits -** The cFE does not place a limit on the size of this parameter but it must be -** less than half of #CFE_TBL_BUF_MEMORY_BYTES. -*/ -#define CFE_TBL_MAX_DBL_TABLE_SIZE 16384 - -/** -** \cfetblcfg Maximum Size Allowed for a Single Buffered Table -** -** \par Description: -** Defines the maximum allowed size (in bytes) of a single buffered table. -** \b NOTE: This size determines the size of all shared table buffers. -** Therefore, this size will be multiplied by #CFE_TBL_MAX_SIMULTANEOUS_LOADS -** below when allocating memory for shared tables. -** -** \par Limits -** The cFE does not place a limit on the size of this parameter but it must be -** small enough to allow for #CFE_TBL_MAX_SIMULTANEOUS_LOADS number of tables -** to fit into #CFE_TBL_BUF_MEMORY_BYTES. -*/ -#define CFE_TBL_MAX_SNGL_TABLE_SIZE 16384 - -/** -** \cfetblcfg Maximum Number of Tables Allowed to be Registered -** -** \par Description: -** Defines the maximum number of tables supported by this processor's Table Services. -** -** \par Limits -** This number must be less than 32767. It should be recognized that this parameter -** determines the size of the Table Registry. An excessively high number will waste -** memory. -*/ -#define CFE_TBL_MAX_NUM_TABLES 128 - -/** -** \cfetblcfg Maximum Number of Critical Tables that can be Registered -** -** \par Description: -** Defines the maximum number of critical tables supported by this processor's Table Services. -** -** \par Limits -** This number must be less than 32767. It should be recognized that this parameter -** determines the size of the Critical Table Registry which is maintained in the Critical -** Data Store. An excessively high number will waste Critical Data Store memory. Therefore, -** this number must not exceed the value defined in CFE_ES_CDS_MAX_CRITICAL_TABLES. -*/ -#define CFE_TBL_MAX_CRITICAL_TABLES 32 - -/** -** \cfetblcfg Maximum Number of Table Handles -** -** \par Description: -** Defines the maximum number of Table Handles. -** -** \par Limits -** This number must be less than 32767. This number must be at least as big as -** the number of tables (#CFE_TBL_MAX_NUM_TABLES) and should be set higher if tables -** are shared between applications. -*/ -#define CFE_TBL_MAX_NUM_HANDLES 256 - -/** -** \cfetblcfg Maximum Number of Simultaneous Loads to Support -** -** \par Description: -** Defines the maximum number of single buffered tables that can be -** loaded simultaneously. This number is used to determine the number -** of shared buffers to allocate. -** -** \par Limits -** This number must be less than 32767. An excessively high number will -** degrade system performance and waste memory. A number less than 5 is -** suggested but not required. -*/ -#define CFE_TBL_MAX_SIMULTANEOUS_LOADS 4 - -/** -** \cfetblcfg Maximum Number of Simultaneous Table Validations -** -** \par Description: -** Defines the maximum number of pending validations that -** the Table Services can handle at any one time. When a -** table has a validation function, a validation request is -** made of the application to perform that validation. This -** number determines how many of those requests can be -** outstanding at any one time. -** -** \par Limits -** This number must be less than 32767. An excessively high number will -** degrade system performance and waste memory. A number less than 20 is -** suggested but not required. -*/ -#define CFE_TBL_MAX_NUM_VALIDATIONS 10 - -/** -** \cfetblcfg Default Filename for a Table Registry Dump -** -** \par Description: -** Defines the file name used to store the table registry when -** no filename is specified in the dump registry command. -** -** \par Limits -** The length of each string, including the NULL terminator cannot exceed the -** #OS_MAX_PATH_LEN value. -*/ -#define CFE_TBL_DEFAULT_REG_DUMP_FILE "/ram/cfe_tbl_reg.log" - -/** -** \cfetblcfg Number of Spacecraft ID's specified for validation -** -** \par Description: -** Defines the number of specified spacecraft ID values that -** are verified during table loads. If the number is zero -** then no validation of the spacecraft ID field in the table -** file header is performed when tables are loaded. Non-zero -** values indicate how many values from the list of spacecraft -** ID's defined below are compared to the spacecraft ID field -** in the table file header. The ELF2CFETBL tool may be used -** to create table files with specified spacecraft ID values. -** -** \par Limits -** This number must be greater than or equal to zero and -** less than or equal to 2. -*/ -#define CFE_TBL_VALID_SCID_COUNT 0 - -/* macro to construct 32 bit value from 4 chars */ -#define CFE_TBL_U32FROM4CHARS( _C1, _C2, _C3, _C4 ) \ - ( (uint32)(_C1) << 24 | \ - (uint32)(_C2) << 16 | \ - (uint32)(_C3) << 8 | \ - (uint32)(_C4) ) - -/** -** \cfetblcfg Spacecraft ID values used for table load validation -** -** \par Description: -** Defines the spacecraft ID values used for validating the -** spacecraft ID field in the table file header. To be valid, -** the spacecraft ID specified in the table file header must -** match one of the values defined here. -** -** \par Limits -** This value can be any 32 bit unsigned integer. -*/ -#define CFE_TBL_VALID_SCID_1 (CFE_SPACECRAFT_ID) -#define CFE_TBL_VALID_SCID_2 (CFE_TBL_U32FROM4CHARS('a', 'b', 'c', 'd')) - -/** -** \cfetblcfg Number of Processor ID's specified for validation -** -** \par Description: -** Defines the number of specified processor ID values that -** are verified during table loads. If the number is zero -** then no validation of the processor ID field in the table -** file header is performed when tables are loaded. Non-zero -** values indicate how many values from the list of processor -** ID's defined below are compared to the processor ID field -** in the table file header. The ELF2CFETBL tool may be used -** to create table files with specified processor ID values. -** -** \par Limits -** This number must be greater than or equal to zero and -** less than or equal to 4. -*/ -#define CFE_TBL_VALID_PRID_COUNT 0 - -/** -** \cfetblcfg Processor ID values used for table load validation -** -** \par Description: -** Defines the processor ID values used for validating the -** processor ID field in the table file header. To be valid, -** the spacecraft ID specified in the table file header must -** match one of the values defined here. -** -** \par Limits -** This value can be any 32 bit unsigned integer. -*/ -#define CFE_TBL_VALID_PRID_1 (CFE_CPU_ID) -#define CFE_TBL_VALID_PRID_2 (CFE_TBL_U32FROM4CHARS('a', 'b', 'c', 'd')) -#define CFE_TBL_VALID_PRID_3 0 -#define CFE_TBL_VALID_PRID_4 0 - -/** \cfeescfg Mission specific version number for cFE -** -** \par Description: -** The cFE version number consists of four parts: -** major version number, minor version number, revision -** number and mission specific revision number. The mission -** specific revision number is defined here and the other -** parts are defined in "cfe_version.h". -** -** \par Limits: -** Must be defined as a numeric value that is greater than -** or equal to zero. -*/ -#define CFE_MISSION_REV 0 - -/** \cfeescfg Poll timer for startup sync delay -** -** \par Description: -** During startup, some tasks may need to synchronize their own initialization -** with the initialization of other applications in the system. -** -** CFE ES implements an API to accomplish this, that performs a task delay (sleep) -** while polling the overall system state until other tasks are ready. -** -** This value controls the amount of time that the CFE_ES_ApplicationSyncDelay -** will sleep between each check of the system state. This should be large enough -** to allow other tasks to run, but not so large as to noticeably delay the startup -** completion. -** -** Units are in milliseconds -** -** \par Limits: -** Must be defined as an integer value that is greater than -** or equal to zero. -*/ -#define CFE_ES_STARTUP_SYNC_POLL_MSEC 50 - -/** \cfeescfg CFE core application startup timeout -** -** \par Description: -** The upper limit for the amount of time that the cFE core applications -** (ES, SB, EVS, TIME, TBL) are each alloted to reach their respective -** "ready" states. -** -** The CFE "main" thread starts individual tasks for each of the core applications -** (except FS). Each of these must perform some initialization work before the -** next core application can be started, so the main thread waits to ensure that the -** application has reached the "ready" state before starting the next application. -** -** If any core application fails to start, then it indicates a major problem with -** the system and startup is aborted. -** -** Units are in milliseconds -** -** \par Limits: -** Must be defined as an integer value that is greater than -** or equal to zero. -** -*/ -#define CFE_CORE_MAX_STARTUP_MSEC 30000 - -/** \cfeescfg Startup script timeout -** -** \par Description: -** The upper limit for the total amount of time that all apps listed in the CFE ES startup -** script may take to all become ready. -** -** Unlike the "core" app timeout, this is a soft limit; if the alloted time is exceeded, -** it probably indicates an issue with one of the apps, but does not cause CFE ES to take -** any additional action other than logging the event to the syslog. -** -** Units are in milliseconds -** -** \par Limits: -** Must be defined as an integer value that is greater than -** or equal to zero. - */ -#define CFE_ES_STARTUP_SCRIPT_TIMEOUT_MSEC 30000 - - -#endif diff --git a/src/components/interface/cFE/cfe_psp.h b/src/components/interface/cFE/cfe_psp.h deleted file mode 100644 index 277816e188..0000000000 --- a/src/components/interface/cFE/cfe_psp.h +++ /dev/null @@ -1,422 +0,0 @@ -/* -** File Name: cfe_psp.h -** -** Copyright (c) 2004-2011, United States Government as represented by -** Administrator for The National Aeronautics and Space Administration. -** All Rights Reserved. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Author: A. Cudmore -** -** Purpose: This file contains the cFE Platform Support Package(PSP) -** prototypes. -** The PSP routines serve as the "glue" between the RTOS and -** the cFE Flight Software. The routines fill gaps that are not -** really considered part of the OS Abstraction, but are required -** for the cFE flight software implementation. It is possible that -** some of these routines could migrate into the OS AL. -** -** $Log: cfe_psp.h $ -** Revision 1.3 2009/07/29 12:04:46GMT-05:00 acudmore -** Added Bank parameter to EEPROM Power up/down and EEPROM write enable/disable functions. -** Revision 1.2 2009/07/22 17:34:10EDT acudmore -** Added new watchdog API -** Revision 1.1 2009/06/10 09:28:44EDT acudmore -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFE-PSP-REPOSITORY/fsw/inc/project.pj -** -*/ - -#ifndef _cfe_psp_ -#define _cfe_psp_ - -/* -** Include Files -*/ - -#include "common_types.h" -#include "osapi.h" - -/* - * These internal header files should not be used in application code - * They will not be accessible when using the newest build scripts - */ -#if !defined(_ENHANCED_BUILD_) || defined(_CFE_PSP_) -#include "cfe_psp_config.h" -#include "psp_version.h" -#endif - -/* -** Macro Definitions -*/ - -/* -** Error and return codes -*/ -#define CFE_PSP_SUCCESS (0) -#define CFE_PSP_ERROR (-1) -#define CFE_PSP_INVALID_POINTER (-2) -#define CFE_PSP_ERROR_ADDRESS_MISALIGNED (-3) -#define CFE_PSP_ERROR_TIMEOUT (-4) -#define CFE_PSP_INVALID_INT_NUM (-5) -#define CFE_PSP_INVALID_MEM_ADDR (-21) -#define CFE_PSP_INVALID_MEM_TYPE (-22) -#define CFE_PSP_INVALID_MEM_RANGE (-23) -#define CFE_PSP_INVALID_MEM_WORDSIZE (-24) -#define CFE_PSP_INVALID_MEM_SIZE (-25) -#define CFE_PSP_INVALID_MEM_ATTR (-26) -#define CFE_PSP_ERROR_NOT_IMPLEMENTED (-27) -#define CFE_PSP_INVALID_MODULE_NAME (-28) -#define CFE_PSP_INVALID_MODULE_ID (-29) - - - -/* -** Definitions for PSP PANIC types -*/ -#define CFE_PSP_PANIC_STARTUP 1 -#define CFE_PSP_PANIC_VOLATILE_DISK 2 -#define CFE_PSP_PANIC_MEMORY_ALLOC 3 -#define CFE_PSP_PANIC_NONVOL_DISK 4 -#define CFE_PSP_PANIC_STARTUP_SEM 5 -#define CFE_PSP_PANIC_CORE_APP 6 -#define CFE_PSP_PANIC_GENERAL_FAILURE 7 - -/* -** Macros for the file loader -*/ -#define BUFF_SIZE 256 -#define SIZE_BYTE 1 -#define SIZE_HALF 2 -#define SIZE_WORD 3 - -/* -** Define memory types -*/ -#define CFE_PSP_MEM_RAM 1 -#define CFE_PSP_MEM_EEPROM 2 -#define CFE_PSP_MEM_ANY 3 -#define CFE_PSP_MEM_INVALID 4 - -/* -** Define Memory Read/Write Attributes -*/ -#define CFE_PSP_MEM_ATTR_WRITE 0x01 -#define CFE_PSP_MEM_ATTR_READ 0x02 -#define CFE_PSP_MEM_ATTR_READWRITE 0x03 - -/* -** Define the Memory Word Sizes -*/ -#define CFE_PSP_MEM_SIZE_BYTE 0x01 -#define CFE_PSP_MEM_SIZE_WORD 0x02 -#define CFE_PSP_MEM_SIZE_DWORD 0x04 - -/* - * Common definition for reset types at the PSP layer - */ -/** \name Reset Types */ -/** \{ */ -#define CFE_PSP_RST_TYPE_PROCESSOR 1 /**< Volatile disk, Critical Data Store and User Reserved memory could still be valid */ -#define CFE_PSP_RST_TYPE_POWERON 2 /**< All memory has been cleared */ -#define CFE_PSP_RST_TYPE_MAX 3 /**< Placeholder to indicate 1+ the maximum value that the PSP will ever use. */ -/** \} */ - -/* -** Reset Sub-Types -*/ -/** \name Reset Sub-Types */ -/** \{ */ -#define CFE_PSP_RST_SUBTYPE_POWER_CYCLE 1 /**< \brief Reset caused by power having been removed and restored */ -#define CFE_PSP_RST_SUBTYPE_PUSH_BUTTON 2 /**< \brief Reset caused by reset button on the board having been pressed */ -#define CFE_PSP_RST_SUBTYPE_HW_SPECIAL_COMMAND 3 /**< \brief Reset was caused by a reset line having been stimulated by a hardware special command */ -#define CFE_PSP_RST_SUBTYPE_HW_WATCHDOG 4 /**< \brief Reset was caused by a watchdog timer expiring */ -#define CFE_PSP_RST_SUBTYPE_RESET_COMMAND 5 /**< \brief Reset was caused by cFE ES processing a \link #CFE_ES_RESTART_CC Reset Command \endlink */ -#define CFE_PSP_RST_SUBTYPE_EXCEPTION 6 /**< \brief Reset was caused by a Processor Exception */ -#define CFE_PSP_RST_SUBTYPE_UNDEFINED_RESET 7 /**< \brief Reset was caused in an unknown manner */ -#define CFE_PSP_RST_SUBTYPE_HWDEBUG_RESET 8 /**< \brief Reset was caused by a JTAG or BDM connection */ -#define CFE_PSP_RST_SUBTYPE_BANKSWITCH_RESET 9 /**< \brief Reset reverted to a cFE POWERON due to a boot bank switch */ -#define CFE_PSP_RST_SUBTYPE_MAX 10 /**< \brief Placeholder to indicate 1+ the maximum value that the PSP will ever use. */ -/** \} */ - -/* Replacements for the "version" macros */ -#ifdef _ENHANCED_BUILD_ - -#define CFE_PSP_MAJOR_VERSION (GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MajorVersion) -#define CFE_PSP_MINOR_VERSION (GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MinorVersion) -#define CFE_PSP_REVISION (GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.Revision) -#define CFE_PSP_MISSION_REV (GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MissionRev) - -/* For backwards compatibility */ -#define CFE_PSP_SUBMINOR_VERSION CFE_PSP_REVISION - -#endif - -/* -** Type Definitions -*/ - -/* -** Memory table type -*/ -typedef struct -{ - uint32 MemoryType; - uint32 WordSize; - cpuaddr StartAddr; - uint32 Size; - uint32 Attributes; -} CFE_PSP_MemTable_t; - -/* -** Function prototypes -*/ - -/* -** PSP entry point and reset routines -*/ -extern void CFE_PSP_Main(uint32 ModeId, char *StartupFilePath); - -/* -** CFE_PSP_Main is the entry point that the real time OS calls to start our -** software. This routine will do any BSP/OS specific setup, then call the -** entrypoint of the flight software ( i.e. the cFE main entry point ). -** The flight software (i.e. cFE ) should not call this routine. -*/ - -extern void CFE_PSP_GetTime(OS_time_t *LocalTime); -/* This call gets the local time from the hardware on the Vxworks system - * on the mcp750s - * on the other os/hardware setup, it will get the time the normal way */ - - -extern void CFE_PSP_Restart(uint32 resetType); -/* -** CFE_PSP_Restart is the entry point back to the BSP to restart the processor. -** The flight software calls this routine to restart the processor. -*/ - - -extern uint32 CFE_PSP_GetRestartType(uint32 *restartSubType ); -/* -** CFE_PSP_GetRestartType returns the last reset type and if a pointer to a valid -** memory space is passed in, it returns the reset sub-type in that memory. -** Right now the reset types are application specific. For the cFE they -** are defined in the cfe_es.h file. -*/ - - -extern void CFE_PSP_FlushCaches(uint32 type, cpuaddr address, uint32 size); -/* -** This is a BSP specific cache flush routine -*/ - -extern uint32 CFE_PSP_GetProcessorId ( void ); -/* -** CFE_PSP_GetProcessorId returns the CPU ID as defined by the specific board -** and BSP. -*/ - - -extern uint32 CFE_PSP_GetSpacecraftId ( void ); -/* -** CFE_PSP_GetSpacecraftId retuns the Spacecraft ID (if any ) -*/ - - -extern uint32 CFE_PSP_Get_Timer_Tick(void); -/* -** CFE_PSP_Get_Timer_Tick returns the underlying OS timer tick value -** It is used for the performance monitoring software -*/ - -extern uint32 CFE_PSP_GetTimerTicksPerSecond(void); -/* -** CFE_PSP_GetTimerTicksPerSecond provides the resolution of the least significant -** 32 bits of the 64 bit time stamp returned by CFE_PSP_Get_Timebase in timer -** ticks per second. The timer resolution for accuracy should not be any slower -** than 1000000 ticks per second or 1 us per tick -*/ - -extern uint32 CFE_PSP_GetTimerLow32Rollover(void); -/* -** CFE_PSP_GetTimerLow32Rollover provides the number that the least significant -** 32 bits of the 64 bit time stamp returned by CFE_PSP_Get_Timebase rolls over. -** If the lower 32 bits rolls at 1 second, then the CFE_PSP_TIMER_LOW32_ROLLOVER -** will be 1000000. if the lower 32 bits rolls at its maximum value (2^32) then -** CFE_PSP_TIMER_LOW32_ROLLOVER will be 0. -*/ - -extern void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32 *Tbl); -/* -** CFE_PSP_Get_Timebase -*/ - -extern uint32 CFE_PSP_Get_Dec(void); -/* -** CFE_PSP_Get_Dec -*/ - - -extern int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType ); -/* -** CFE_PSP_InitProcessorReservedMemory initializes all of the memory in the -** BSP that is preserved on a processor reset. The memory includes the -** Critical Data Store, the ES Reset Area, the Volatile Disk Memory, and -** the User Reserved Memory. In general, the memory areas will be initialized -** ( cleared ) on a Power On reset, and preserved during a processor reset. -*/ - -extern int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS); -/* -** CFE_PSP_GetCDSSize fetches the size of the OS Critical Data Store area. -*/ - -extern int32 CFE_PSP_WriteToCDS(void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumBytes); -/* -** CFE_PSP_WriteToCDS writes to the CDS Block. -*/ - -extern int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumBytes); -/* -** CFE_PSP_ReadFromCDS reads from the CDS Block -*/ - -extern int32 CFE_PSP_GetResetArea (cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea); -/* -** CFE_PSP_GetResetArea returns the location and size of the ES Reset information area. -** This area is preserved during a processor reset and is used to store the -** ER Log, System Log and reset related variables -*/ - -extern int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea ); -/* -** CFE_PSP_GetUserReservedArea returns the location and size of the memory used for the cFE -** User reserved area. -*/ - -extern int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk ); -/* -** CFE_PSP_GetVolatileDiskMem returns the location and size of the memory used for the cFE -** volatile disk. -*/ - -extern int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *SizeOfKernelSegment); -/* -** CFE_PSP_GetKernelTextSegmentInfo returns the location and size of the kernel memory. -*/ - -extern int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFESegment); -/* -** CFE_PSP_GetCFETextSegmentInfo returns the location and size of the kernel memory. -*/ - -extern void CFE_PSP_WatchdogInit(void); -/* -** CFE_PSP_WatchdogInit configures the watchdog timer. -*/ - -extern void CFE_PSP_WatchdogEnable(void); -/* -** CFE_PSP_WatchdogEnable enables the watchdog timer. -*/ - -extern void CFE_PSP_WatchdogDisable(void); -/* -** CFE_PSP_WatchdogDisable disables the watchdog timer. -*/ - -extern void CFE_PSP_WatchdogService(void); -/* -** CFE_PSP_WatchdogService services the watchdog timer according to the -** value set in WatchDogSet. -*/ - -extern uint32 CFE_PSP_WatchdogGet(void); -/* -** CFE_PSP_WatchdogGet gets the watchdog time in milliseconds -*/ - -extern void CFE_PSP_WatchdogSet(uint32 WatchdogValue); -/* -** CFE_PSP_WatchdogSet sets the watchdog time in milliseconds -*/ - -extern void CFE_PSP_Panic(int32 ErrorCode); -/* -** CFE_PSP_Panic is called by the cFE Core startup code when it needs to abort the -** cFE startup. This should not be called by applications. -*/ - -extern int32 CFE_PSP_InitSSR(uint32 bus, uint32 device, char *DeviceName ); -/* -** CFE_PSP_InitSSR will initialize the Solid state recorder memory for a particular platform -*/ - -extern int32 CFE_PSP_Decompress( char * srcFileName, char * dstFileName ); -/* -** CFE_PSP_Decompress will uncompress the source file to the file specified in the -** destination file name. The Decompress uses the "gzip" algorithm. Files can -** be compressed using the "gzip" program available on almost all host platforms. -*/ - -extern void CFE_PSP_AttachExceptions(void); -/* -** CFE_PSP_AttachExceptions will setup the exception environment for the chosen platform -** On a board, this can be configured to look at a debug flag or switch in order to -** keep the standard OS exeption handlers, rather than restarting the system -*/ - - -extern void CFE_PSP_SetDefaultExceptionEnvironment(void); -/* -** -** CFE_PSP_SetDefaultExceptionEnvironment defines the CPU and FPU exceptions that are enabled for each cFE Task/App -** -** Notes: The exception environment is local to each task Therefore this must be -** called for each task that that wants to do floating point and catch exceptions -*/ - - -/* -** I/O Port API -*/ -int32 CFE_PSP_PortRead8 (cpuaddr PortAddress, uint8 *ByteValue); -int32 CFE_PSP_PortWrite8 (cpuaddr PortAddress, uint8 ByteValue); -int32 CFE_PSP_PortRead16 (cpuaddr PortAddress, uint16 *uint16Value); -int32 CFE_PSP_PortWrite16 (cpuaddr PortAddress, uint16 uint16Value); -int32 CFE_PSP_PortRead32 (cpuaddr PortAddress, uint32 *uint32Value); -int32 CFE_PSP_PortWrite32 (cpuaddr PortAddress, uint32 uint32Value); - -/* -** Memory API -*/ -int32 CFE_PSP_MemRead8 (cpuaddr MemoryAddress, uint8 *ByteValue); -int32 CFE_PSP_MemWrite8 (cpuaddr MemoryAddress, uint8 ByteValue); -int32 CFE_PSP_MemRead16 (cpuaddr MemoryAddress, uint16 *uint16Value); -int32 CFE_PSP_MemWrite16 (cpuaddr MemoryAddress, uint16 uint16Value); -int32 CFE_PSP_MemRead32 (cpuaddr MemoryAddress, uint32 *uint32Value); -int32 CFE_PSP_MemWrite32 (cpuaddr MemoryAddress, uint32 uint32Value); - -int32 CFE_PSP_MemCpy (void *dest, void *src, uint32 n); -int32 CFE_PSP_MemSet (void *dest, uint8 value, uint32 n); - -int32 CFE_PSP_MemValidateRange (cpuaddr Address, uint32 Size, uint32 MemoryType); -uint32 CFE_PSP_MemRanges (void); -int32 CFE_PSP_MemRangeSet (uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, - uint32 Size, uint32 WordSize, uint32 Attributes); -int32 CFE_PSP_MemRangeGet (uint32 RangeNum, uint32 *MemoryType, cpuaddr *StartAddr, - uint32 *Size, uint32 *WordSize, uint32 *Attributes); - -int32 CFE_PSP_EepromWrite8 (cpuaddr MemoryAddress, uint8 ByteValue); -int32 CFE_PSP_EepromWrite16 (cpuaddr MemoryAddress, uint16 uint16Value); -int32 CFE_PSP_EepromWrite32 (cpuaddr MemoryAddress, uint32 uint32Value); - -int32 CFE_PSP_EepromWriteEnable (uint32 Bank); -int32 CFE_PSP_EepromWriteDisable(uint32 Bank); -int32 CFE_PSP_EepromPowerUp (uint32 Bank); -int32 CFE_PSP_EepromPowerDown (uint32 Bank); - -#endif /* _cfe_psp_ */ diff --git a/src/components/interface/cFE/cfe_psp_config.h b/src/components/interface/cFE/cfe_psp_config.h deleted file mode 100644 index 44699696a3..0000000000 --- a/src/components/interface/cFE/cfe_psp_config.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -** cfe_psp_config.h -** -** Copyright (c) 2004-2011, United States Government as represented by -** Administrator for The National Aeronautics and Space Administration. -** All Rights Reserved. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** -*/ - -#ifndef _cfe_psp_config_ -#define _cfe_psp_config_ - - - -#include "common_types.h" - - -/* -** This define sets the number of memory ranges that are defined in the memory range defintion -** table. -*/ -#define CFE_PSP_MEM_TABLE_SIZE 10 - - -/* -** Processor Context type. -** This is needed to determine the size of the context entry in the ER log. -** Although this file is in a CPU directory, it really is OS dependant, so supporting -** multiple OSs on the same CPU architecture ( i.e. x86/linux, x86/windows, x86/osx ) -** will require IFDEFS. -*/ -typedef struct -{ - uint32 regs[32]; - -} CFE_PSP_ExceptionContext_t; - -#define CFE_PSP_CPU_CONTEXT_SIZE (sizeof(CFE_PSP_ExceptionContext_t)) - - -/* -** Watchdog minimum and maximum values ( in milliseconds ) -*/ -#define CFE_PSP_WATCHDOG_MIN (0) -#define CFE_PSP_WATCHDOG_MAX (0xFFFFFFFF) - -/* -** Number of EEPROM banks on this platform -*/ -#define CFE_PSP_NUM_EEPROM_BANKS 1 - -#endif - diff --git a/src/components/interface/cFE/cfe_psp_configdata.h b/src/components/interface/cFE/cfe_psp_configdata.h deleted file mode 100644 index 9e60caf3d7..0000000000 --- a/src/components/interface/cFE/cfe_psp_configdata.h +++ /dev/null @@ -1,88 +0,0 @@ -/** - * \file cfe_psp_config.h - * - * Created on: Dec 31, 2014 - * Author: joseph.p.hickey@nasa.gov - * - * Copyright (c) 2004-2011, United States Government as represented by - * Administrator for The National Aeronautics and Space Administration. - * All Rights Reserved. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only pursuant to the terms of that agreement. - */ - -#ifndef CFE_PSP_CONFIG_H_ -#define CFE_PSP_CONFIG_H_ - -/* osapi.h is required for the definition of OS_VolumeInto_t */ -#include -/* cfe_psp.h is required for the definition of CFE_PSP_MemTable_t */ -#include - -/* -** PSP software version record -** (replaces PSP_*_VERSION macros) -*/ -typedef const struct -{ - uint8 MajorVersion; - uint8 MinorVersion; - uint8 Revision; - uint8 MissionRev; -} CFE_PSP_VersionInfo_t; - - - -/** - * PSP/Hardware configuration parameters - * This structure should be instantiated by the PSP according - * such that other modules do not need to directly include - * the PSP configuration at compile time. - */ -typedef const struct -{ - uint32 PSP_WatchdogMin; /**< PSP Minimum watchdog in milliseconds */ - uint32 PSP_WatchdogMax; /**< PSP Maximum watchdog in milliseconds */ - uint32 PSP_MemTableSize; /**< Size of PSP memory table */ - CFE_PSP_MemTable_t *PSP_MemoryTable; /**< Pointer to PSP memory table (forward reference) */ - - uint32 OS_VolumeTableSize; /**< Size of OS volume table */ - OS_VolumeInfo_t *OS_VolumeTable; /**< Pointer to OS volume table (forward reference) */ - - /** - * Processor Context type. - * This is needed to determine the size of the context entry in the ER log. - * It is a placeholder as the implementation to use it is not merged in yet. - */ - uint32 OS_CpuContextSize; - - /** - * Number of EEPROM banks on this platform - */ - uint32 HW_NumEepromBanks; - - CFE_PSP_VersionInfo_t PSP_VersionInfo; - -} Target_PspConfigData; - -/** - * Extern reference to psp config struct. - * Allows the actual instantiation to be done outside this module - */ -extern Target_PspConfigData GLOBAL_PSP_CONFIGDATA; - -/** - * Extern reference to the psp memory table - * Allows the actual instantiation to be done outside this module - */ -extern CFE_PSP_MemTable_t CFE_PSP_MemoryTable[]; - -/** - * Extern reference to the psp volume table - * Allows the actual instantiation to be done outside this module - */ -extern OS_VolumeInfo_t OS_VolumeTable[]; - - -#endif /* CFE_PSP_CONFIG_H_ */ diff --git a/src/components/interface/cFE/cfe_sb.h b/src/components/interface/cFE/cfe_sb.h deleted file mode 100644 index a0fabd581c..0000000000 --- a/src/components/interface/cFE/cfe_sb.h +++ /dev/null @@ -1,1267 +0,0 @@ -/****************************************************************************** -** File: cfe_sb.h -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** -** Purpose: -** This header file contains all definitions for the cFE Software Bus -** Application Programmer's Interface. -** -** Author: R.McGraw/SSI -** -** $Log: cfe_sb.h $ -** Revision 1.10 2011/04/07 08:34:14GMT-05:00 lwalling -** This file references CFE TIME structures, therefore it should include cfe_time.h -** Revision 1.9 2009/07/29 19:21:50EDT aschoeni -** Added ZeroCopyHandle_t -** Revision 1.8 2009/07/24 18:25:20EDT aschoeni -** Added Zero Copy Mode -** Revision 1.7 2009/07/17 19:42:20EDT aschoeni -** Added PassMsg API to sb to support sequence count preservation -** Revision 1.6 2009/06/10 09:15:06EDT acudmore -** updated os_bsp.h to cfe_psp.h -** Revision 1.5 2009/04/29 10:03:59EDT rmcgraw -** DCR5801:11 Changed comments related to subscription return value -** Revision 1.4 2009/02/27 09:55:04EST rmcgraw -** DCR1709:1 Removed incorrect comment in SetTotalMsgLength -** and reworded other comments -** Revision 1.3 2009/02/26 17:49:19EST rmcgraw -** DCR6805:1 Added note under subscription API declaration -** Revision 1.2 2008/12/08 12:06:56EST dkobe -** Updates to correct doxygen errors -** Revision 1.1 2008/04/17 08:05:22EDT ruperera -** Initial revision -** Member added to cfe project on tlserver3 -** Revision 1.25 2007/09/25 10:34:38EDT rjmcgraw -** DCR5127 Added doxygen comments -** Revision 1.24 2007/07/06 13:18:35EDT rjmcgraw -** DCR469:1 Changed function prototype for GetLastSenderId -** Revision 1.23 2007/05/23 11:22:02EDT dlkobe -** Added doxygen formatting -** Revision 1.22 2007/04/19 15:47:03EDT rjmcgraw -** Moved subscription reporting structs to cfe_sb_msg.h -** Revision 1.20 2007/03/22 12:55:20EST rjmcgraw -** Added comments regarding Qos -** Revision 1.19 2007/01/24 16:49:35EST rjmcgraw -** Added Pipe to SubEntries_t -** Revision 1.18 2007/01/08 14:42:18EST rjmcgraw -** Moved SubscribeLocal prototypes to this file from cfe_sb_priv.h -** Revision 1.17 2007/01/04 14:49:44EST rjmcgraw -** Added SubType to CFE_SB_SubRprtMsg_t -** Revision 1.16 2007/01/02 10:01:35EST rjmcgraw -** Moved structs from priv.h to cfe_sb.h for exposure to apps -** Revision 1.15 2006/12/28 16:27:34EST rjmcgraw -** Added cmd codes for SB subscription processing -** -******************************************************************************/ - -#ifndef _cfe_sb_ -#define _cfe_sb_ - -/* -** Includes -*/ -#include "osconfig.h" -#include "cfe_psp.h" -#include "common_types.h" -#include "cfe_mission_cfg.h" -#include "cfe_platform_cfg.h" -#include "ccsds.h" -#include "cfe_time.h" - - -/* -** Defines -*/ -#define CFE_SB_POLL 0 /**< \brief Option used with #CFE_SB_RcvMsg to request immediate pipe status */ -#define CFE_SB_PEND_FOREVER -1 /**< \brief Option used with #CFE_SB_RcvMsg to force a wait for next message */ -#define CFE_SB_SUB_ENTRIES_PER_PKT 20 /**< \brief Configuration parameter used by SBN App */ -#define CFE_SB_SUBSCRIPTION 0 /**< \brief Subtype specifier used in #CFE_SB_SubRprtMsg_t by SBN App */ -#define CFE_SB_UNSUBSCRIPTION 1 /**< \brief Subtype specified used in #CFE_SB_SubRprtMsg_t by SBN App */ - -/* -** Macro Definitions -*/ -#define CFE_BIT(x) (1 << (x)) /**< \brief Places a one at bit positions 0 - 31*/ -#define CFE_SET(i,x) ((i) |= CFE_BIT(x)) /**< \brief Sets bit x of i */ -#define CFE_CLR(i,x) ((i) &= ~CFE_BIT(x)) /**< \brief Clears bit x of i */ -#define CFE_TST(i,x) (((i) & CFE_BIT(x)) != 0)/**< \brief TRUE(non zero) if bit x of i is set */ - -/** - * Macro that should be used to set memory addresses within software bus messages. - * For now this does a straight copy, but in a future revision this may translate the - * raw memory address into a "safe" integer value. This is particularly important if - * the message is to be sent off this CPU. - */ -#define CFE_SB_SET_MEMADDR(msgdst,src) msgdst = (cpuaddr)src - -/** - * Macro that should be used to get memory addresses from software bus messages. - * This is the inverse operation of CFE_SB_SET_MEMADDR. - */ -#define CFE_SB_GET_MEMADDR(msgsrc) (cpuaddr)msgsrc - -/* -** Type Definitions -*/ -#ifdef MESSAGE_FORMAT_IS_CCSDS - - /**< \brief Generic Software Bus Message Type Definition */ - typedef union { - CCSDS_PriHdr_t Hdr; /**< \brief CCSDS Primary Header #CCSDS_PriHdr_t */ - uint32 Dword; /**< \brief Forces minimum of 32-bit alignment for this object */ - uint8 Byte[sizeof(CCSDS_PriHdr_t)]; /**< \brief Allows byte-level access */ - }CFE_SB_Msg_t; - - /**< \brief Generic Software Bus Command Header Type Definition */ - typedef struct{ - CCSDS_PriHdr_t Pri;/**< \brief CCSDS Primary Header #CCSDS_PriHdr_t */ - CCSDS_CmdSecHdr_t Sec;/**< \brief CCSDS Command Secondary Header #CCSDS_CmdSecHdr_t */ - }CFE_SB_CmdHdr_t; - - /**< \brief Generic Software Bus Telemetry Header Type Definition */ - typedef struct{ - CCSDS_PriHdr_t Pri;/**< \brief CCSDS Primary Header #CCSDS_PriHdr_t */ - CCSDS_TlmSecHdr_t Sec;/**< \brief CCSDS Telemetry Secondary Header #CCSDS_TlmSecHdr_t */ - }CFE_SB_TlmHdr_t; - - #define CFE_SB_CMD_HDR_SIZE (sizeof(CFE_SB_CmdHdr_t))/**< \brief Size of #CFE_SB_CmdHdr_t in bytes */ - #define CFE_SB_TLM_HDR_SIZE (sizeof(CFE_SB_TlmHdr_t))/**< \brief Size of #CFE_SB_TlmHdr_t in bytes */ - -#endif /* MESSAGE_FORMAT_IS_CCSDS */ - -/**< \brief CFE_SB_TimeOut_t to primitive type definition -** -** Internally used by SB in the #CFE_SB_RcvMsg API. Translated from the -** input parmater named TimeOut which specifies the maximum time in -** milliseconds that the caller wants to wait for a message. -*/ -typedef uint32 CFE_SB_TimeOut_t; - -/**< \brief CFE_SB_PipeId_t to primitive type definition -** -** Software Bus pipe identifier used in many SB APIs -*/ -typedef uint8 CFE_SB_PipeId_t; - -/**< \brief CFE_SB_MsgId_t to primitive type definition -** -** Software Bus message identifier used in many SB APIs -*/ -typedef uint16 CFE_SB_MsgId_t; - -/**< \brief CFE_SB_MsgPtr_t defined as a pointer to an SB Message */ -typedef CFE_SB_Msg_t *CFE_SB_MsgPtr_t; - -/**< \brief CFE_SB_MsgPayloadPtr_t defined as an opaque pointer to a message Payload portion */ -typedef uint8 *CFE_SB_MsgPayloadPtr_t; - -/**< \brief CFE_SB_ZeroCopyId_t to primitive type definition -** -** Software Zero Copy handle used in many SB APIs -*/ -typedef cpuaddr CFE_SB_ZeroCopyHandle_t; - -/**< \brief Quality Of Service Type Definition -** -** Currently an unused parameter in #CFE_SB_SubscribeEx -** Intended to be used for interprocessor communication only -**/ -typedef struct { - uint8 Priority;/**< \brief Specify high(1) or low(0) message priority for off-board routing, currently unused */ - uint8 Reliability;/**< \brief Specify high(1) or low(0) message transfer reliability for off-board routing, currently unused */ -}CFE_SB_Qos_t; - -extern CFE_SB_Qos_t CFE_SB_Default_Qos;/**< \brief Defines a default priority and reliabilty for off-board routing */ - - -/**< \brief Message Sender Identification Type Definition -** -** Parameter used in #CFE_SB_GetLastSenderId API which allows the receiver of a message -** to validate the sender of the message. -**/ -typedef struct { - uint32 ProcessorId;/**< \brief Processor Id from which the message was sent */ - char AppName[OS_MAX_API_NAME];/**< \brief Application that sent the message */ -} CFE_SB_SenderId_t; - -/* -** cFE SB Application Programmer Interface's (API's) -*/ - -/*****************************************************************************/ -/** -** \brief Creates a new software bus pipe. -** -** \par Description -** This routine creates and initializes an input pipe that the calling -** application can use to receive software bus messages. By default, no -** messages are routed to the new pipe. So, the application must use -** #CFE_SB_Subscribe() to specify which messages it wants to receive on -** this pipe. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] PipeIdPtr A pointer to a variable of type #CFE_SB_PipeId_t, -** which will be filled in with the pipe ID information -** by the #CFE_SB_CreatePipe routine. -** -** \param[in] Depth The maximum number of messages that will be allowed on -** this pipe at one time. -** -** \param[in] PipeName A string to be used to identify this pipe in error messages -** and routing information telemetry. The string must be no -** longer than #OS_MAX_API_NAME. Longer strings will be truncated. -** -** \param[out] *PipeIdPtr The identifier for the created pipe. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode -** \retcode #CFE_SB_MAX_PIPES_MET \retdesc \copydoc CFE_SB_MAX_PIPES_MET \endcode -** \retcode #CFE_SB_PIPE_CR_ERR \retdesc \copydoc CFE_SB_PIPE_CR_ERR \endcode -** \endreturns -** -** \sa #CFE_SB_DeletePipe -**/ -int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, - uint16 Depth, - const char *PipeName); - -/*****************************************************************************/ -/** -** \brief Delete a software bus pipe. -** -** \par Description -** This routine deletes an input pipe and cleans up all data structures -** associated with the pipe. All subscriptions made for this pipe by -** calls to #CFE_SB_Subscribe will be automatically removed from the -** SB routing tables. Any messages in the pipe will be discarded. -** Applications must call this routine for all of their SB pipes as part -** of their orderly shutdown process. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] PipeId The pipe ID (obtained previously from #CFE_SB_CreatePipe) -** of the pipe to be deleted. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode -** \endreturns -** -** \sa #CFE_SB_CreatePipe -**/ -int32 CFE_SB_DeletePipe(CFE_SB_PipeId_t PipeId); - -/*****************************************************************************/ -/** -** \brief Subscribe to a message on the software bus -** -** \par Description -** This routine adds the specified pipe to the destination list associated -** with the specified message ID. -** -** \par Assumptions, External Events, and Notes: -** Note: As subscriptions are received, the destinations are added to -** the head of a linked list. During the sending of a message, the list -** is traversed beginning at the head of the list. Therefore the -** message will first be sent to the last subscriber. If an application -** has timing constraints and needs to receive a message in the -** shortest possible time, the developer may consider holding off its -** subscription until other applications have subscribed to the message. -** -** \param[in] MsgId The message ID of the message to be subscribed to. -** -** \param[in] PipeId The pipe ID of the pipe the subscribed message -** should be sent to. -** -** \param[in] Quality The requested Quality of Service (QoS) required of -** the messages. Most callers will use #CFE_SB_Default_Qos -** for this parameter. -** -** \param[in] MsgLim The maximum number of messages with this Message ID to -** allow in this pipe at the same time. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_SB_MAX_MSGS_MET \retdesc \copydoc CFE_SB_MAX_MSGS_MET \endcode -** \retcode #CFE_SB_MAX_DESTS_MET \retdesc \copydoc CFE_SB_MAX_DESTS_MET \endcode -** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode -** \retcode #CFE_SB_BUF_ALOC_ERR \retdesc \copydoc CFE_SB_BUF_ALOC_ERR \endcode -** \endreturns -** -** \sa #CFE_SB_Subscribe, #CFE_SB_SubscribeLocal, #CFE_SB_Unsubscribe, #CFE_SB_UnsubscribeLocal -**/ -int32 CFE_SB_SubscribeEx(CFE_SB_MsgId_t MsgId, - CFE_SB_PipeId_t PipeId, - CFE_SB_Qos_t Quality, - uint16 MsgLim); - -/*****************************************************************************/ -/** -** \brief Subscribe to a message on the software bus with default parameters -** -** \par Description -** This routine adds the specified pipe to the destination list for -** the specified message ID. This is the same as #CFE_SB_SubscribeEx -** with the Quality field set to #CFE_SB_Default_Qos and MsgLim set -** to #CFE_SB_DEFAULT_MSG_LIMIT (4). -** -** \par Assumptions, External Events, and Notes: -** Note: As subscriptions are received, the destinations are added to -** the head of a linked list. During the sending of a message, the list -** is traversed beginning at the head of the list. Therefore the -** message will first be sent to the last subscriber. If an application -** has timing constraints and needs to receive a message in the -** shortest possible time, the developer may consider holding off its -** subscription until other applications have subscribed to the message. -** -** \param[in] MsgId The message ID of the message to be subscribed to. -** -** \param[in] PipeId The pipe ID of the pipe the subscribed message -** should be sent to. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_SB_MAX_MSGS_MET \retdesc \copydoc CFE_SB_MAX_MSGS_MET \endcode -** \retcode #CFE_SB_MAX_DESTS_MET \retdesc \copydoc CFE_SB_MAX_DESTS_MET \endcode -** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode -** \retcode #CFE_SB_BUF_ALOC_ERR \retdesc \copydoc CFE_SB_BUF_ALOC_ERR \endcode -** \endreturns -** -** \sa #CFE_SB_SubscribeEx, #CFE_SB_SubscribeLocal, #CFE_SB_Unsubscribe, #CFE_SB_UnsubscribeLocal -**/ -int32 CFE_SB_Subscribe(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId); - -/*****************************************************************************/ -/** -** \brief Subscribe to a message while keeping the request local to a cpu -** -** \par Description -** This routine adds the specified pipe to the destination list for -** the specified message ID. This is similar to #CFE_SB_SubscribeEx -** with the Quality field set to #CFE_SB_Default_Qos and MsgLim set -** to #CFE_SB_DEFAULT_MSG_LIMIT, but will not report the subscription. -** Subscription Reporting is enabled for interprocessor communication -** by way of the Software Bus Network (SBN) Application. -** -** \par Assumptions, External Events, and Notes: -** - This API is typically only used by Software Bus Network (SBN) Application -** -** \param[in] MsgId The message ID of the message to be subscribed to. -** -** \param[in] PipeId The pipe ID of the pipe the subscribed message -** should be sent to. -** -** \param[in] MsgLim The maximum number of messages with this Message ID to -** allow in this pipe at the same time. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_SB_MAX_MSGS_MET \retdesc \copydoc CFE_SB_MAX_MSGS_MET \endcode -** \retcode #CFE_SB_MAX_DESTS_MET \retdesc \copydoc CFE_SB_MAX_DESTS_MET \endcode -** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode -** \retcode #CFE_SB_BUF_ALOC_ERR \retdesc \copydoc CFE_SB_BUF_ALOC_ERR \endcode -** \endreturns -** -** \sa #CFE_SB_Subscribe, #CFE_SB_SubscribeEx, #CFE_SB_Unsubscribe, #CFE_SB_UnsubscribeLocal -**/ -int32 CFE_SB_SubscribeLocal(CFE_SB_MsgId_t MsgId, - CFE_SB_PipeId_t PipeId, - uint16 MsgLim); - -/*****************************************************************************/ -/** -** \brief Remove a subscription to a message on the software bus -** -** \par Description -** This routine removes the specified pipe from the destination -** list for the specified message ID. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] MsgId The message ID of the message to be unsubscribed. -** -** \param[in] PipeId The pipe ID of the pipe the subscribed message -** should no longer be sent to. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_SB_NO_SUBSCRIBERS \retdesc \copydoc CFE_SB_NO_SUBSCRIBERS \endcode -** \retcode #CFE_SB_INTERNAL_ERR \retdesc \copydoc CFE_SB_INTERNAL_ERR \endcode -** \endreturns -** -** \sa #CFE_SB_Subscribe, #CFE_SB_SubscribeEx, #CFE_SB_SubscribeLocal, #CFE_SB_UnsubscribeLocal -**/ -int32 CFE_SB_Unsubscribe(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId); - -/*****************************************************************************/ -/** -** \brief Remove a subscription to a message on the software bus on the current CPU -** -** \par Description -** This routine removes the specified pipe from the destination -** list for the specified message ID on the current CPU. -** -** \par Assumptions, External Events, and Notes: -** - This API is typically only used by Software Bus Network (SBN) Application -** -** \param[in] MsgId The message ID of the message to be unsubscribed. -** -** \param[in] PipeId The pipe ID of the pipe the subscribed message -** should no longer be sent to. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_SB_NO_SUBSCRIBERS \retdesc \copydoc CFE_SB_NO_SUBSCRIBERS \endcode -** \retcode #CFE_SB_INTERNAL_ERR \retdesc \copydoc CFE_SB_INTERNAL_ERR \endcode -** \endreturns -** -** \sa #CFE_SB_Subscribe, #CFE_SB_SubscribeEx, #CFE_SB_SubscribeLocal, #CFE_SB_Unsubscribe -**/ -int32 CFE_SB_UnsubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId); - -/*****************************************************************************/ -/** -** \brief Send a software bus message -** -** \par Description -** This routine sends the specified message to all subscribers. The -** software bus will read the message ID from the message header to -** determine which pipes should receive the message. -** -** \par Assumptions, External Events, and Notes: -** - This routine will not normally wait for the receiver tasks to -** process the message before returning control to the caller's task. -** - However, if a higher priority task is pending and subscribed to -** this message, that task may get to run before #CFE_SB_SendMsg -** returns control to the caller. -** - This function tracks and increments the source sequence counter -** of a telemetry message. -** -** \param[in] MsgPtr A pointer to the message to be sent. This must point -** to the first byte of the software bus message header -** (#CFE_SB_Msg_t). -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode -** \retcode #CFE_SB_MSG_TOO_BIG \retdesc \copydoc CFE_SB_MSG_TOO_BIG \endcode -** \retcode #CFE_SB_BUF_ALOC_ERR \retdesc \copydoc CFE_SB_BUF_ALOC_ERR \endcode -** \endreturns -** -** \sa #CFE_SB_RcvMsg, #CFE_SB_ZeroCopySend, #CFE_SB_PassMsg -**/ -int32 CFE_SB_SendMsg(CFE_SB_Msg_t *MsgPtr); - -/*****************************************************************************/ -/** -** \brief Passes a software bus message -** -** \par Description -** This routine sends the specified message to all subscribers. The -** software bus will read the message ID from the message header to -** determine which pipes should receive the message. This routine is -** intended to pass messages not generated by the sending application. -** -** \par Assumptions, External Events, and Notes: -** - This routine will not normally wait for the receiver tasks to -** process the message before returning control to the caller's task. -** - However, if a higher priority task is pending and subscribed to -** this message, that task may get to run before #CFE_SB_PassMsg -** returns control to the caller. -** - Unlike #CFE_SB_SendMsg this routine will preserve the source -** sequence counter in a telemetry message. -** -** \param[in] MsgPtr A pointer to the message to be sent. This must point -** to the first byte of the software bus message header -** (#CFE_SB_Msg_t). -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode -** \retcode #CFE_SB_MSG_TOO_BIG \retdesc \copydoc CFE_SB_MSG_TOO_BIG \endcode -** \retcode #CFE_SB_BUF_ALOC_ERR \retdesc \copydoc CFE_SB_BUF_ALOC_ERR \endcode -** \endreturns -** -** \sa #CFE_SB_RcvMsg, #CFE_SB_ZeroCopySend, #CFE_SB_SendMsg -**/ -int32 CFE_SB_PassMsg(CFE_SB_Msg_t *MsgPtr); - -/*****************************************************************************/ -/** -** \brief Receive a message from a software bus pipe -** -** \par Description -** This routine retrieves the next message from the specified pipe. -** If the pipe is empty, this routine will block until either a new -** message comes in or the timeout value is reached. -** -** \par Assumptions, External Events, and Notes: -** Note - If an error occurs in this API, the *BufPtr value may be NULL or -** random. Therefore, it is recommended that the return code be tested -** for CFE_SUCCESS before processing the message. -** -** \param[in] BufPtr A pointer to a local variable of type #CFE_SB_MsgPtr_t. -** Typically a caller declares a ptr of type CFE_SB_Msg_t -** (i.e. CFE_SB_Msg_t *Ptr) then gives the address of that -** pointer (&Ptr) as this parmeter. After a successful -** receipt of a message, *BufPtr will point to the first -** byte of the software bus message header. This should be -** used as a read-only pointer (in systems with an MMU, -** writes to this pointer may cause a memory protection fault). -** The *BufPtr is valid only until the next call to -** CFE_SB_RcvMsg for the same pipe. -** -** \param[in] PipeId The pipe ID of the pipe containing the message to be obtained. -** -** \param[in] TimeOut The number of milliseconds to wait for a new message if the -** pipe is empty at the time of the call. This can also be set -** to #CFE_SB_POLL for a non-blocking receive or -** #CFE_SB_PEND_FOREVER to wait forever for a message to arrive. -** -** \param[out] *BufPtr A pointer to the message obtained from the pipe. Valid -** only until the next call to CFE_SB_RcvMsg for the same pipe. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode -** \retcode #CFE_SB_TIME_OUT \retdesc \copydoc CFE_SB_TIME_OUT \endcode -** \retcode #CFE_SB_PIPE_RD_ERR \retdesc \copydoc CFE_SB_PIPE_RD_ERR \endcode -** \retcode #CFE_SB_NO_MESSAGE \retdesc \copydoc CFE_SB_NO_MESSAGE \endcode -** \endreturns -** -** \sa #CFE_SB_SendMsg, #CFE_SB_ZeroCopySend -**/ -int32 CFE_SB_RcvMsg(CFE_SB_MsgPtr_t *BufPtr, - CFE_SB_PipeId_t PipeId, - int32 TimeOut); - -/*****************************************************************************/ -/** -** \brief Retrieve the application Info of the sender for the last message. -** -** \par Description -** This routine can be used after a successful #CFE_SB_RcvMsg call -** to find out which application sent the message that was received. -** -** \par Assumptions, External Events, and Notes: -** Note - If an error occurs in this API, the *Ptr value may be NULL or -** random. Therefore, it is recommended that the return code be tested -** for CFE_SUCCESS before reading the sender information. -** -** \param[in] Ptr A pointer to a local variable of type #CFE_SB_SenderId_t. -** Typically a caller declares a ptr of type CFE_SB_SenderId_t -** (i.e. CFE_SB_SenderId_t *Ptr) then gives the address of that -** pointer (&Ptr) for this parameter. After a successful call -** to this API, *Ptr will point to the first byte of the -** CFE_SB_SenderId_t structure containing the sender information -** for the last message received on the given pipe. This should -** be used as a read-only pointer (in systems with an MMU, writes -** to this pointer may cause a memory protection fault). The *Ptr -** is valid only until the next call to CFE_SB_RcvMsg for the -** same pipe. -** -** \param[in] PipeId The pipe ID of the pipe the message was taken from. -** -** \returns -** \retcode The sender's application ID \retdesc \endcode -** \endreturns -** -** \sa -**/ -uint32 CFE_SB_GetLastSenderId(CFE_SB_SenderId_t **Ptr,CFE_SB_PipeId_t PipeId); - -/*****************************************************************************/ -/** -** \brief Get a buffer pointer to use for "zero copy" SB sends. -** -** \par Description -** This routine can be used to get a pointer to one of the software bus' -** internal memory buffers that are used for sending messages. The caller -** can use this memory buffer to build an SB message, then send it using -** the #CFE_SB_ZeroCopySend function. This interface is more complicated -** than the normal #CFE_SB_ZeroCopySend interface, but it avoids an extra -** copy of the message from the user's memory buffer to the software bus -** internal buffer. The "zero copy" interface can be used to improve -** performance in high-rate, high-volume software bus traffic. -** -** \par Assumptions, External Events, and Notes: -** -# The pointer returned by #CFE_SB_ZeroCopyGetPtr is only good for one -** call to #CFE_SB_ZeroCopySend. -** -# Applications should be written as if #CFE_SB_ZeroCopyGetPtr is -** equivalent to a \c malloc() and #CFE_SB_ZeroCopySend is equivalent to -** a \c free(). -** -# Applications must not de-reference the message pointer (for reading -** or writing) after the call to #CFE_SB_ZeroCopySend. -** -** \param[in] MsgSize The size of the SB message buffer the caller wants -** (including the SB message header). -** -** \param[out] BufferHandle A handle that must be supplied when sending or releasing -** in zero copy mode. -** -** \returns -** \retstmt A pointer to a memory buffer that can be used to build one SB message -** for use with #CFE_SB_ZeroCopySend. \endstmt -** \endreturns -** -** \sa #CFE_SB_ZeroCopyReleasePtr, #CFE_SB_ZeroCopySend -**/ -CFE_SB_Msg_t *CFE_SB_ZeroCopyGetPtr(uint16 MsgSize, - CFE_SB_ZeroCopyHandle_t *BufferHandle); - -/*****************************************************************************/ -/** -** \brief Release an unused "zero copy" buffer pointer. -** -** \par Description -** This routine can be used to release a pointer to one of the software -** bus' internal memory buffers. -** -** \par Assumptions, External Events, and Notes: -** -# This function is not needed for normal "zero copy" transfers. It -** is needed only for cleanup when an application gets a pointer using -** #CFE_SB_ZeroCopyGetPtr, but (due to some error condition) never uses -** that pointer for a #CFE_SB_ZeroCopySend -** -** \param[in] Ptr2Release A pointer to the SB internal buffer. This must be a -** pointer returned by a call to #CFE_SB_ZeroCopyGetPtr, -** but never used in a call to #CFE_SB_ZeroCopySend. -** -** \param[in] BufferHandle This must be the handle supplied with the pointer -** when #CFE_SB_ZeroCopyGetPtr was called. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_SB_BUFFER_INVALID \retdesc \copydoc CFE_SB_BUFFER_INVALID \endcode -** \endreturns -** -** \sa #CFE_SB_ZeroCopyGetPtr, #CFE_SB_ZeroCopySend -**/ -int32 CFE_SB_ZeroCopyReleasePtr(CFE_SB_Msg_t *Ptr2Release, - CFE_SB_ZeroCopyHandle_t BufferHandle); - -/*****************************************************************************/ -/** -** \brief Send an SB message in "zero copy" mode. -** -** \par Description -** This routine sends a message that has been created directly in an -** internal SB message buffer by an application (after a call to -** #CFE_SB_ZeroCopyGetPtr). This interface is more complicated than -** the normal #CFE_SB_SendMsg interface, but it avoids an extra copy of -** the message from the user's memory buffer to the software bus -** internal buffer. The "zero copy" interface can be used to improve -** performance in high-rate, high-volume software bus traffic. -** -** \par Assumptions, External Events, and Notes: -** -# The pointer returned by #CFE_SB_ZeroCopyGetPtr is only good for -** one call to #CFE_SB_ZeroCopySend. -** -# Callers must not use the same SB message buffer for multiple sends. -** -# Applications should be written as if #CFE_SB_ZeroCopyGetPtr is -** equivalent to a \c malloc() and #CFE_SB_ZeroCopySend is equivalent -** to a \c free(). -** -# Applications must not de-reference the message pointer (for reading -** or writing) after the call to #CFE_SB_ZeroCopySend. -** -# This function tracks and increments the source sequence counter -** of a telemetry message. -** -** \param[in] MsgPtr A pointer to the SB message to be sent. -** -** \param[in] BufferHandle The handle supplied with the #CFE_SB_ZeroCopyGetPtr call. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode -** \retcode #CFE_SB_MSG_TOO_BIG \retdesc \copydoc CFE_SB_MSG_TOO_BIG \endcode -** \retcode #CFE_SB_BUF_ALOC_ERR \retdesc \copydoc CFE_SB_BUF_ALOC_ERR \endcode -** \retcode #CFE_SB_BUFFER_INVALID \retdesc \copydoc CFE_SB_BUFFER_INVALID \endcode -** \endreturns -** -** \sa #CFE_SB_SendMsg, #CFE_SB_RcvMsg, #CFE_SB_ZeroCopyReleasePtr, #CFE_SB_ZeroCopyGetPtr -**/ -int32 CFE_SB_ZeroCopySend(CFE_SB_Msg_t *MsgPtr, - CFE_SB_ZeroCopyHandle_t BufferHandle); - -/*****************************************************************************/ -/** -** \brief Pass an SB message in "zero copy" mode. -** -** \par Description -** This routine sends a message that has been created directly in an -** internal SB message buffer by an application (after a call to -** #CFE_SB_ZeroCopyGetPtr). This interface is more complicated than -** the normal #CFE_SB_SendMsg interface, but it avoids an extra copy of -** the message from the user's memory buffer to the software bus -** internal buffer. The "zero copy" interface can be used to improve -** performance in high-rate, high-volume software bus traffic. This -** version is intended to pass messages not generated by the caller -** (to preserve the source sequence count). -** -** \par Assumptions, External Events, and Notes: -** -# The pointer returned by #CFE_SB_ZeroCopyGetPtr is only good for -** one call to #CFE_SB_ZeroCopySend or #CFE_SB_ZeroCopyPass. -** -# Callers must not use the same SB message buffer for multiple sends. -** -# Applications should be written as if #CFE_SB_ZeroCopyGetPtr is -** equivalent to a \c malloc() and #CFE_SB_ZeroCopyPass is equivalent -** to a \c free(). -** -# Applications must not de-reference the message pointer (for reading -** or writing) after the call to #CFE_SB_ZeroCopyPass. -** -# Unlike #CFE_SB_ZeroCopySend this routine will preserve the source -** sequence counter in a telemetry message. -** -** \param[in] MsgPtr A pointer to the SB message to be sent. -** -** \param[in] BufferHandle The handle supplied with the #CFE_SB_ZeroCopyGetPtr call. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_SB_BAD_ARGUMENT \retdesc \copydoc CFE_SB_BAD_ARGUMENT \endcode -** \retcode #CFE_SB_MSG_TOO_BIG \retdesc \copydoc CFE_SB_MSG_TOO_BIG \endcode -** \retcode #CFE_SB_BUF_ALOC_ERR \retdesc \copydoc CFE_SB_BUF_ALOC_ERR \endcode -** \retcode #CFE_SB_BUFFER_INVALID \retdesc \copydoc CFE_SB_BUFFER_INVALID \endcode -** \endreturns -** -** \sa #CFE_SB_PassMsg, #CFE_SB_ZeroCopySend, #CFE_SB_ZeroCopyReleasePtr, #CFE_SB_ZeroCopyGetPtr -**/ -int32 CFE_SB_ZeroCopyPass(CFE_SB_Msg_t *MsgPtr, - CFE_SB_ZeroCopyHandle_t BufferHandle); - - -/*****************************************************************************/ -/** -** \brief Initialize a buffer for a software bus message. -** -** \par Description -** This routine fills in the header information needed to create a -** valid software bus message. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] MsgPtr A pointer to the buffer that will contain the message. -** This will point to the first byte of the message header. -** The \c void* data type allows the calling routine to use -** any data type when declaring its message buffer. -** -** \param[in] MsgId The message ID to put in the message header. -** -** \param[in] Length The total number of bytes of message data, including the SB -** message header . -** -** \param[in] Clear A flag indicating whether to clear the rest of the message: -** \arg TRUE - fill sequence count and packet data with zeroes. -** \arg FALSE - leave sequence count and packet data unchanged. -** -** \sa #CFE_SB_SetMsgId, #CFE_SB_SetUserDataLength, #CFE_SB_SetTotalMsgLength, -** #CFE_SB_SetMsgTime, #CFE_SB_TimeStampMsg, #CFE_SB_SetCmdCode -**/ -void CFE_SB_InitMsg(void *MsgPtr, - CFE_SB_MsgId_t MsgId, - uint16 Length, - boolean Clear ); - -/*****************************************************************************/ -/** -** \brief Get the size of a software bus message header. -** -** \par Description -** This routine returns the number of bytes in a software bus message header. -** This can be used for sizing buffers that need to store SB messages. SB -** message header formats can be different for each deployment of the cFE. -** So, applications should use this function and avoid hard coding their buffer -** sizes. -** -** \par Assumptions, External Events, and Notes: -** - For statically defined messages, a function call will not work. The -** macros #CFE_SB_CMD_HDR_SIZE and #CFE_SB_TLM_HDR_SIZE are available for use -** in static message buffer sizing or structure definitions. -** -** \param[in] MsgId The message ID to calculate header size for. The size of the message -** header may depend on the MsgId in some implementations. For example, -** if SB messages are implemented as CCSDS packets, the size of the header -** is different for command vs. telemetry packets. -** -** \returns -** \retstmt The number of bytes in the software bus message header for -** messages with the given \c MsgId. endstmt -** \endreturns -** -** \sa #CFE_SB_GetUserData, #CFE_SB_GetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_GetTotalMsgLength, -** #CFE_SB_GetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum -**/ -uint16 CFE_SB_MsgHdrSize(CFE_SB_MsgId_t MsgId); - -/*****************************************************************************/ -/** -** \brief Get a pointer to the user data portion of a software bus message. -** -** \par Description -** This routine returns a pointer to the user data portion of a software -** bus message. SB message header formats can be different for each -** deployment of the cFE. So, applications should use this function and -** avoid hard coding offsets into their SB message buffers. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. -** -** \returns -** \retstmt A pointer to the first byte of user data within the software bus message. \endstmt -** \endreturns -** -** \sa #CFE_SB_GetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_GetTotalMsgLength, -** #CFE_SB_GetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum, #CFE_SB_MsgHdrSize -**/ -void *CFE_SB_GetUserData(CFE_SB_MsgPtr_t MsgPtr); - -/*****************************************************************************/ -/** -** \brief Get the message ID of a software bus message. -** -** \par Description -** This routine returns the message ID from a software bus message. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. -** -** \returns -** \retstmt The software bus Message ID from the message header. \endstmt -** \endreturns -** -** \sa #CFE_SB_GetUserData, #CFE_SB_SetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_GetTotalMsgLength, -** #CFE_SB_GetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum, #CFE_SB_MsgHdrSize -**/ -CFE_SB_MsgId_t CFE_SB_GetMsgId(CFE_SB_MsgPtr_t MsgPtr); - -/*****************************************************************************/ -/** -** \brief Sets the message ID of a software bus message. -** -** \par Description -** This routine sets the Message ID in a software bus message header. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. -** This must point to the first byte of the message header. -** -** \param[in] MsgId The message ID to put into the message header. -** -** \returns -** \retstmt The software bus Message ID from the message header. \endstmt -** \endreturns -** -** \sa #CFE_SB_GetMsgId, #CFE_SB_SetUserDataLength, #CFE_SB_SetTotalMsgLength, -** #CFE_SB_SetMsgTime, #CFE_SB_TimeStampMsg, #CFE_SB_SetCmdCode, #CFE_SB_InitMsg -**/ -void CFE_SB_SetMsgId(CFE_SB_MsgPtr_t MsgPtr, - CFE_SB_MsgId_t MsgId); - -/*****************************************************************************/ -/** -** \brief Gets the length of user data in a software bus message. -** -** \par Description -** This routine returns the size of the user data in a software bus message. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. -** This must point to the first byte of the message header. -** -** \returns -** \retstmt The size (in bytes) of the user data in the software bus message. \endstmt -** \endreturns -** -** \sa #CFE_SB_GetUserData, #CFE_SB_GetMsgId, #CFE_SB_SetUserDataLength, #CFE_SB_GetTotalMsgLength, -** #CFE_SB_GetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum, #CFE_SB_MsgHdrSize -**/ -uint16 CFE_SB_GetUserDataLength(CFE_SB_MsgPtr_t MsgPtr); - -/*****************************************************************************/ -/** -** \brief Sets the length of user data in a software bus message. -** -** \par Description -** This routine sets the field in the SB message header that determines -** the size of the user data in a software bus message. SB message header -** formats can be different for each deployment of the cFE. So, applications -** should use this function rather than trying to poke a length value directly -** into their SB message buffers. -** -** \par Assumptions, External Events, and Notes: -** - You must set a valid message ID in the SB message header before -** calling this function. -** -** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. -** This must point to the first byte of the message header. -** -** \param[in] DataLength The length to set (size of the user data, in bytes). -** -** -** \sa #CFE_SB_SetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_SetTotalMsgLength, -** #CFE_SB_SetMsgTime, #CFE_SB_TimeStampMsg, #CFE_SB_SetCmdCode, #CFE_SB_InitMsg -**/ -void CFE_SB_SetUserDataLength(CFE_SB_MsgPtr_t MsgPtr,uint16 DataLength); - -/*****************************************************************************/ -/** -** \brief Gets the total length of a software bus message. -** -** \par Description -** This routine returns the total size of the software bus message. -** -** \par Assumptions, External Events, and Notes: -** - For the CCSDS implementation of this API, the size is derived from -** the message header. -** -** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. -** This must point to the first byte of the message header. -** -** \returns -** \retstmt The total size (in bytes) of the software bus message, including headers. \endstmt -** \endreturns -** -** \sa #CFE_SB_GetUserData, #CFE_SB_GetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_SetTotalMsgLength, -** #CFE_SB_GetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum, #CFE_SB_MsgHdrSize -**/ -uint16 CFE_SB_GetTotalMsgLength(CFE_SB_MsgPtr_t MsgPtr); - -/*****************************************************************************/ -/** -** \brief Sets the total length of a software bus message. -** -** \par Description -** This routine sets the field in the SB message header that determines -** the total length of the message. SB message header formats can be -** different for each deployment of the cFE. So, applications should -** use this function rather than trying to poke a length value directly -** into their SB message buffers. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. -** This must point to the first byte of the message header. -** -** \param[in] TotalLength The length to set (total size of the message, in bytes, -** including headers). -** -** \sa #CFE_SB_SetMsgId, #CFE_SB_SetUserDataLength, #CFE_SB_GetTotalMsgLength, -** #CFE_SB_SetMsgTime, #CFE_SB_TimeStampMsg, #CFE_SB_SetCmdCode, #CFE_SB_InitMsg -**/ -void CFE_SB_SetTotalMsgLength(CFE_SB_MsgPtr_t MsgPtr,uint16 TotalLength); - -/*****************************************************************************/ -/** -** \brief Gets the time field from a software bus message. -** -** \par Description -** This routine gets the time from a software bus message. -** -** \par Assumptions, External Events, and Notes: -** - If the underlying implementation of software bus messages does not -** include a time field, then this routine will return a zero time. -** -** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. -** This must point to the first byte of the message header. -** \returns -** \retstmt The system time included in the software bus message header (if present), -** otherwise, returns a time value of zero. \endstmt -** \endreturns -** -** \sa #CFE_SB_GetUserData, #CFE_SB_GetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_GetTotalMsgLength, -** #CFE_SB_SetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum, #CFE_SB_MsgHdrSize -**/ -CFE_TIME_SysTime_t CFE_SB_GetMsgTime(CFE_SB_MsgPtr_t MsgPtr); - -/*****************************************************************************/ -/** -** \brief Sets the time field in a software bus message. -** -** \par Description -** This routine sets the time of a software bus message. Most applications -** will want to use #CFE_SB_TimeStampMsg instead of this function. But, -** when needed, #CFE_SB_SetMsgTime can be used to send a group of SB messages -** with identical time stamps. -** -** \par Assumptions, External Events, and Notes: -** - If the underlying implementation of software bus messages does not include -** a time field, then this routine will do nothing to the message contents -** and will return #CFE_SB_WRONG_MSG_TYPE. -** -** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. -** This must point to the first byte of the message header. -** -** \param[in] Time The time to include in the message. This will usually be a time -** returned by the function #CFE_TIME_GetTime(). -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_SB_WRONG_MSG_TYPE \retdesc \copydoc CFE_SB_WRONG_MSG_TYPE \endcode -** \endreturns -** -** \sa #CFE_SB_SetMsgId, #CFE_SB_SetUserDataLength, #CFE_SB_SetTotalMsgLength, -** #CFE_SB_GetMsgTime, #CFE_SB_TimeStampMsg, #CFE_SB_SetCmdCode, #CFE_SB_InitMsg -**/ -int32 CFE_SB_SetMsgTime(CFE_SB_MsgPtr_t MsgPtr, - CFE_TIME_SysTime_t Time); - -/*****************************************************************************/ -/** -** \brief Sets the time field in a software bus message with the current spacecraft time. -** -** \par Description -** This routine sets the time of a software bus message with the current -** spacecraft time. This will be the same time that is returned by the -** function #CFE_TIME_GetTime. -** -** \par Assumptions, External Events, and Notes: -** - If the underlying implementation of software bus messages does not -** include a time field, then this routine will do nothing. -** -** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. -** This must point to the first byte of the message header. -** -** \sa #CFE_SB_SetMsgId, #CFE_SB_SetUserDataLength, #CFE_SB_SetTotalMsgLength, -** #CFE_SB_SetMsgTime, #CFE_SB_SetCmdCode, #CFE_SB_InitMsg -**/ -void CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr); - -/*****************************************************************************/ -/** -** \brief Gets the command code field from a software bus message. -** -** \par Description -** This routine gets the command code from a software bus message (if -** SB messages are implemented as CCSDS packets, this will be the function -** code). -** -** \par Assumptions, External Events, and Notes: -** - If the underlying implementation of software bus messages does not -** include a command code field, then this routine will return a zero. -** -** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. -** This must point to the first byte of the message header. -** -** \returns -** \retstmt The command code included in the software bus message header (if present). -** Otherwise, returns a command code value of zero. \endstmt -** \endreturns -** -** \sa #CFE_SB_GetUserData, #CFE_SB_GetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_GetTotalMsgLength, -** #CFE_SB_GetMsgTime, #CFE_SB_SetCmdCode, #CFE_SB_GetChecksum, #CFE_SB_MsgHdrSize -**/ -uint16 CFE_SB_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr); - -/*****************************************************************************/ -/** -** \brief Sets the command code field in a software bus message. -** -** \par Description -** This routine sets the command code of a software bus message (if SB -** messages are implemented as CCSDS packets, this will be the function code). -** -** \par Assumptions, External Events, and Notes: -** - If the underlying implementation of software bus messages does not -** include a command code field, then this routine will do nothing to -** the message contents and will return #CFE_SB_WRONG_MSG_TYPE. -** -** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. -** This must point to the first byte of the message header. -** -** \param[in] CmdCode The command code to include in the message. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_SB_WRONG_MSG_TYPE \retdesc \copydoc CFE_SB_WRONG_MSG_TYPE \endcode -** \endreturns -** -** \sa #CFE_SB_SetMsgId, #CFE_SB_SetUserDataLength, #CFE_SB_SetTotalMsgLength, -** #CFE_SB_SetMsgTime, #CFE_SB_TimeStampMsg, #CFE_SB_GetCmdCode, #CFE_SB_InitMsg -**/ -int32 CFE_SB_SetCmdCode(CFE_SB_MsgPtr_t MsgPtr, - uint16 CmdCode); - -/*****************************************************************************/ -/** -** \brief Gets the checksum field from a software bus message. -** -** \par Description -** This routine gets the checksum (or other message integrity check -** value) from a software bus message. The contents and location of -** this field will depend on the underlying implementation of software -** bus messages. It may be a checksum, a CRC, or some other algorithm. -** Users should not call this function as part of a message integrity -** check (call #CFE_SB_ValidateChecksum instead). -** -** \par Assumptions, External Events, and Notes: -** - If the underlying implementation of software bus messages does not -** include a checksum field, then this routine will return a zero. -** -** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. -** This must point to the first byte of the message header. -** -** \returns -** \retstmt The checksum included in the software bus message header (if present), otherwise, -** returns a checksum value of zero. \endstmt -** \endreturns -** -** \sa #CFE_SB_GetUserData, #CFE_SB_GetMsgId, #CFE_SB_GetUserDataLength, #CFE_SB_GetTotalMsgLength, -** #CFE_SB_GetMsgTime, #CFE_SB_GetCmdCode, #CFE_SB_GetChecksum, #CFE_SB_MsgHdrSize, -** #CFE_SB_ValidateChecksum, #CFE_SB_GenerateChecksum -**/ -uint16 CFE_SB_GetChecksum(CFE_SB_MsgPtr_t MsgPtr); - -/*****************************************************************************/ -/** -** \brief Calculates and sets the checksum of a software bus message -** -** \par Description -** This routine calculates the checksum of a software bus message according -** to an implementation-defined algorithm. Then, it sets the checksum field -** in the message with the calculated value. The contents and location of -** this field will depend on the underlying implementation of software bus -** messages. It may be a checksum, a CRC, or some other algorithm. -** -** \par Assumptions, External Events, and Notes: -** - If the underlying implementation of software bus messages does not -** include a checksum field, then this routine will do nothing. -** -** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. -** This must point to the first byte of the message header. -** -** \sa #CFE_SB_ValidateChecksum, #CFE_SB_GetChecksum -**/ -void CFE_SB_GenerateChecksum(CFE_SB_MsgPtr_t MsgPtr); - -/*****************************************************************************/ -/** -** \brief Validates the checksum of a software bus message. -** -** \par Description -** This routine calculates the expected checksum of a software bus message -** according to an implementation-defined algorithm. Then, it checks the -** calculated value against the value in the message's checksum. If the -** checksums do not match, this routine will generate an event message -** reporting the error. -** -** \par Assumptions, External Events, and Notes: -** - If the underlying implementation of software bus messages does not -** include a checksum field, then this routine will always return \c TRUE. -** -** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. -** This must point to the first byte of the message header. -** -** \returns -** \retcode TRUE \retdesc The checksum field in the packet is valid. \endcode -** \retcode FALSE \retdesc The checksum field in the packet is not valid or the message type is wrong. \endcode -** \endreturns -** -** \sa #CFE_SB_GenerateChecksum, #CFE_SB_GetChecksum -**/ -boolean CFE_SB_ValidateChecksum(CFE_SB_MsgPtr_t MsgPtr); - -/****************************************************************************** -** Function: CFE_SB_MessageStringGet() -** -** Purpose: -** Copies a string out of a software bus message -** -** Strings within software bus messages have a defined/fixed maximum length, and -** may not necessarily be null terminated within the message. This presents a possible -** issue when using the C library functions to copy strings out of a message. -** -** This function should replace use of C library functions such as strcpy/strncpy -** when copying strings out of software bus messages to local storage buffers. -** -** Up to [SourceMaxSize] or [DestMaxSize-1] (whichever is smaller) characters will be -** coped from the source buffer to the destination buffer, and a NUL termination -** character will be written to the destination buffer as the last character. -** -** If the DefaultString pointer is non-NULL, it will be used in place of the source -** string if the source is an empty string. This is typically a string constant that -** comes from the platform configuration, allowing default values to be assumed for -** fields that are unspecified. -** -** IMPORTANT - the default string, if specified, must be null terminated. This will -** be the case if a string literal is passed in (the typical/expected use case). -** -** If the default is NULL, then only the source string will be copied, and the result -** will be an empty string if the source was empty. -** -** If the destination buffer is too small to store the entire string, it will be -** truncated, but it will still be null terminated. -** -** Arguments: -** DestStringPtr - pointer to destination buffer -** SourceStringPtr - pointer to source buffer (component of SB message definition) -** DefaultString - alternative string to use if the source is an empty string -** DestMaxSize - size of the destination storage buffer (must be at least 2) -** SourceMaxSize - size of the source buffer as defined by the message definition -** -** Returns: -** Length of result - number of characters copied, not including the terminating NUL. -** This should match the value that would be returned by "strlen(DestStringPtr)" -** -*/ -int32 CFE_SB_MessageStringGet(char *DestStringPtr, const char *SourceStringPtr, const char *DefaultString, uint32 DestMaxSize, uint32 SourceMaxSize); - -/****************************************************************************** -** Function: CFE_SB_MessageStringSet() -** -** Purpose: -** Copies a string into a software bus message -** -** Strings within software bus messages have a defined/fixed maximum length, and -** may not necessarily be null terminated within the message. This presents a possible -** issue when using the C library functions to copy strings out of a message. -** -** This performs a very similar function to "strncpy()" except that the sizes -** of _both_ buffers are passed in. Neither buffer is required to be null-terminated, -** but copying will stop after the first termination character is encountered. -** -** If the destination buffer is not completely filled by the source data (such as if -** the supplied string was shorter than the allotted length) the destination buffer -** will be padded with NUL characters up to the size of the buffer, similar to what -** strncpy() does. This ensures that the entire destination buffer is set. -** -** NOTE - if the source string buffer is already guaranteed to be null terminated, -** then there is no difference between the C library "strncpy()" function and this -** implementation. It is only necessary to use this when termination of the source -** buffer is not guaranteed. -** -** Arguments: -** DestStringPtr - pointer to destination buffer -** SourceStringPtr - pointer to source buffer (component of SB message definition) -** DestMaxSize - size of the destination storage buffer (must be at least 2) -** SourceMaxSize - size of the source buffer as defined by the message definition -** -** Returns: -** Length of result - number of actual data characters copied -** This should match the value that would be returned by "strlen(DestStringPtr)" -** -*/ -int32 CFE_SB_MessageStringSet(char *DestStringPtr, const char *SourceStringPtr, uint32 DestMaxSize, uint32 SourceMaxSize); - - -#endif /* _cfesb_ */ -/*****************************************************************************/ diff --git a/src/components/interface/cFE/cfe_sb_events.h b/src/components/interface/cFE/cfe_sb_events.h deleted file mode 100644 index e7b0d72b21..0000000000 --- a/src/components/interface/cFE/cfe_sb_events.h +++ /dev/null @@ -1,798 +0,0 @@ -/* -** File: cfe_sb_events.h -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** -** Purpose: -** cFE Software Bus (SB) Event IDs -** -** References: -** Flight Software Branch C Coding Standard Version 1.0a -** cFE Flight Software Application Developers Guide -** -** -** $Log: cfe_sb_events.h $ -** Revision 1.7 2011/12/20 10:52:41GMT-05:00 rmcgraw -** DCR15187:2 Removed event CFE_SB_MSGCNT_ERR1_EID (23) -** Revision 1.6 2009/05/08 11:29:10EDT rmcgraw -** DCR7631:1 Removed 2 events rergarding index error and renumbered events -** Revision 1.5 2009/02/10 11:24:46EST rmcgraw -** DCR1699:1 Removed pipe owner in five events -** Revision 1.4 2009/02/03 11:03:45EST rmcgraw -** DCR5801:2 Added event CFE_SB_DEST_BLK_ERR_EID -** Revision 1.3 2009/01/23 15:00:06EST rmcgraw -** DCR5802:1 Removed redundant events in cfe_sb_buf.c -** Revision 1.2 2008/12/08 12:07:07EST dkobe -** Updates to correct doxygen errors -** Revision 1.1 2008/04/17 08:05:23EDT ruperera -** Initial revision -** Member added to cfe project on tlserver3 -** Revision 1.21 2007/09/19 14:37:06EDT rjmcgraw -** Removed Use Count Error events 1 and 4 -** Revision 1.20 2007/07/12 16:46:22EDT rjmcgraw -** DCR4680:1 Removed events associated with SB event log -** Revision 1.19 2007/07/06 13:16:38EDT rjmcgraw -** DCR469:1 Added 3 events for new GetLastSender code -** Revision 1.18 2007/06/02 10:10:10EDT dlkobe -** Added doxygen comments for User's Guides -** Revision 1.17 2007/05/25 16:24:48EDT dlkobe -** Continued updating doxygen comments -** Revision 1.16 2007/05/25 15:59:30EDT rjmcgraw -** Added comments to events -** Revision 1.15 2007/03/23 09:50:16EST rjmcgraw -** DCR3217 Removed event 29 -** Revision 1.14 2007/03/19 14:46:00EST rjmcgraw -** Removed #define for create pipe duplicate name event id -** Revision 1.13 2007/03/16 15:30:36EST rjmcgraw -** New event for duplicate pipe name check -** Revision 1.12 2007/03/16 14:09:04EST rjmcgraw -** Added new event for array index out of range in subscribe -** Revision 1.11 2007/03/16 09:57:54EST rjmcgraw -** Added new events related to pipe owner checks -** -**************************************************************************/ -#ifndef _cfe_sb_events_ -#define _cfe_sb_events_ - -/* -** SB task event message ID's. -*/ -/* -** Event ID's -*/ - -/** \brief 'cFE SB Initialized' -** \event 'cFE SB Initialized' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is issued when the Software Bus Task completes its -** initialization. -**/ -#define CFE_SB_INIT_EID 1 - -/** \brief 'CreatePipeErr:Bad Input Arg:app=\%s,ptr=0x\%x,depth=\%d,maxdepth=\%d' -** \event 'CreatePipeErr:Bad Input Arg:app=\%s,ptr=0x\%x,depth=\%d,maxdepth=\%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the #CFE_SB_CreatePipe API receives a bad -** argument. In this case, a bad argument is defined by the following: -** A NULL PipeIdPtr, PipeDepth = 0 and PipeDepth > cfg param #CFE_SB_MAX_PIPE_DEPTH -**/ -#define CFE_SB_CR_PIPE_BAD_ARG_EID 2 - -/** \brief 'CreatePipeErr:Max Pipes(\%d)In Use.app \%s' -** \event 'CreatePipeErr:Max Pipes(\%d)In Use.app \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the #CFE_SB_CreatePipe API is called and -** the maximum number of pipes (defined by cfg param #CFE_SB_MAX_PIPES) are in use. -**/ -#define CFE_SB_MAX_PIPES_MET_EID 3 - - -/** \brief 'CreatePipeErr:OS_QueueCreate returned \%d,app \%s' -** \event 'CreatePipeErr:OS_QueueCreate returned \%d,app \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the #CFE_SB_CreatePipe API is called and -** the OS returns an error when the OS returns an error from the OS_QueueCreate API. -** The error status returned by the OS is displayed in the event. Most commonly, -** this event is displayed as a result of trying to create pipes with the same name. -**/ -#define CFE_SB_CR_PIPE_ERR_EID 4 - -/** \brief 'Pipe Created:name \%s,id \%d,app \%s' -** \event 'Pipe Created:name \%s,id \%d,app \%s' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This debug event message is issued when a pipe was successfully created in the -** #CFE_SB_CreatePipe API. -**/ -#define CFE_SB_PIPE_ADDED_EID 5 - - -/** \brief 'Subscribe Err:Bad Arg,MsgId 0x\%x,PipeId \%d,app \%s,scope \%d' -** \event 'Subscribe Err:Bad Arg,MsgId 0x\%x,PipeId \%d,app \%s,scope \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when one of the Subscribe API's are called -** with an invalid MsgId. An invalid MsgId is defined as being greater than the -** cfg param #CFE_SB_HIGHEST_VALID_MSGID. -** -**/ -#define CFE_SB_SUB_ARG_ERR_EID 6 - -/** \brief 'Duplicate Subscription,MsgId 0x\%x on \%s pipe,app \%s' -** \event 'Duplicate Subscription,MsgId 0x\%x on \%s pipe,app \%s' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This info event message is issued when a subscription request is received that -** already exists in the routing table. A duplicate subscription is defined by a -** matching MsgId and PipeId. No other parameters are used in detecting a duplicate -** subscription. -** NOTE: By default, SB filters this event. The EVS filter algorithm allows the -** first event to pass through the filter, but all subsequent events with this -** event id will be filtered. A command must be sent to unfilter this event if -** the user desires to see it. -**/ -#define CFE_SB_DUP_SUBSCRIP_EID 7 - -/** \brief 'Subscribe Err:Max Msgs(\%d)In Use,MsgId 0x\%x,pipe \%s,app \%s' -** \event 'Subscribe Err:Max Msgs(\%d)In Use,MsgId 0x\%x,pipe \%s,app \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when one of the SB subscribe APIs are called -** with a new MsgId, and SB cannot accommodate the new MsgId because the maximum -** number of MsgIds are in use. The maximum number of MsgIds is defined by cfg param -** #CFE_SB_MAX_MSG_IDS. This cfg param dictates the number of elements in the SB -** routing table. There is one element per MsgId. The user may monitor the routing -** table utilization figures (msgids currently in use, high water mark and max -** allowed) by sending the SB cmd to dump the SB statistics data. -**/ -#define CFE_SB_MAX_MSGS_MET_EID 8 - -/** \brief 'Subscribe Err:Max Dests(\%d)In Use For Msg 0x\%x,pipe \%s,app \%s' -** \event 'Subscribe Err:Max Dests(\%d)In Use For Msg 0x\%x,pipe \%s,app \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when a subscription request is received and -** all destinations for that MsgId are in use. The number of destinations per msgid -** is a configuration parameter named #CFE_SB_MAX_DEST_PER_PKT. A destination is -** defined as a pipe. -**/ -#define CFE_SB_MAX_DESTS_MET_EID 9 - -/** \brief 'Subscription Rcvd:MsgId 0x\%x on \%s(\%d),app \%s' -** \event 'Subscription Rcvd:MsgId 0x\%x on \%s(\%d),app \%s' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This debug event message is issued when a subscription is successfully made -** through one of the SB Subscribe API's -**/ -#define CFE_SB_SUBSCRIPTION_RCVD_EID 10 - -/** \brief 'UnSubscribe Err:Bad Arg,MsgId 0x\%x,PipeId \%d,app \%s,scope \%d' -** \event 'UnSubscribe Err:Bad Arg,MsgId 0x\%x,PipeId \%d,app \%s,scope \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when a request to unsubscribe fails due to -** an invalid msgid or an invalid pipeid in one of SB's unsubscribe API's. The msgid -** must be less than cfg param #CFE_SB_HIGHEST_VALID_MSGID and the pipeid must have -** been created and have a value less than cfg param #CFE_SB_MAX_PIPES. The SB pipe -** table may be viewed to verify its value or existence. -**/ -#define CFE_SB_UNSUB_ARG_ERR_EID 11 - -/** \brief 'Unsubscribe Err:No subs for Msg 0x\%x on \%s,app \%s' -** \event 'Unsubscribe Err:No subs for Msg 0x\%x on \%s,app \%s' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This info event message is issued when a request to unsubscribe fails due to -** a non existent msgid/pipeid combination in the SB routing table. The SB routing -** table may be viewed to see a list of valid msgid/pipeid combinations. -**/ -#define CFE_SB_UNSUB_NO_SUBS_EID 12 - -/** \brief 'Send Err:Bad input argument,Arg 0x\%x,App \%s' -** \event 'Send Err:Bad input argument,Arg 0x\%x,App \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the #CFE_SB_SendMsg API receives an -** invalid (possibly NULL) ptr as an argument. -**/ -#define CFE_SB_SEND_BAD_ARG_EID 13 - -/** \brief 'No subscribers for MsgId 0x\%x,sender \%s' -** \event 'No subscribers for MsgId 0x\%x,sender \%s' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This info event message is issued when the #CFE_SB_SendMsg API is called and there -** are no subscribers (therefore no destinations) for the message to be sent. Each -** time the SB detects this situation, the corresponding SB telemetry point is -** incremented.. -** NOTE: By default, SB filters this event. The EVS filter algorithm allows the -** first event to pass through the filter, but all subsequent events with this -** event id will be filtered. A command must be sent to unfilter this event if -** the user desires to see it. -**/ -#define CFE_SB_SEND_NO_SUBS_EID 14 - -/** \brief 'Send Err:Msg Too Big MsgId=0x\%x,app=\%s,size=\%d,MaxSz=\%d' -** \event 'Send Err:Msg Too Big MsgId=0x\%x,app=\%s,size=\%d,MaxSz=\%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the #CFE_SB_SendMsg API is called and the -** packet length field in the message header implies that the message size exceeds -** the max size defined by mission cfg param #CFE_SB_MAX_SB_MSG_SIZE. The request to -** send the message is denied, there is no partial packet sent. -**/ -#define CFE_SB_MSG_TOO_BIG_EID 15 - -/** \brief 'Send Err:Request for Buffer Failed. MsgId 0x\%x,app \%s,size \%d' -** \event 'Send Err:Request for Buffer Failed. MsgId 0x\%x,app \%s,size \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the #CFE_SB_SendMsg API fails to receive -** the necessary buffer memory from the ES memory pool. This could be an indication -** that the cfg param #CFE_SB_BUF_MEMORY_BYTES is set too low. To check this, send SB -** cmd to dump the SB statistics pkt and view the buffer memory parameters. -**/ -#define CFE_SB_GET_BUF_ERR_EID 16 - -/** \brief 'Send Err:Msg Limit Err MsgId 0x\%x,pipe \%s,sender \%s' -** \event 'Send Err:Msg Limit Err MsgId 0x\%x,pipe \%s,sender \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the #CFE_SB_SendMsg API cannot route the -** MsgId (displayed in event) to the pipe (displayed in the event) because the pipe -** currently contains the maximum number of messages of this type (MsgId). This is -** typically an indication that the receiver is not reading its pipe fast enough, or -** at all. A less typical scenerio is that the sender is sending a burst of pkts of -** this type (or MsgId) and the receiver (owner of 'pipe') cannot keep up. The -** subscriber of the message dictates this limit count in the 'MsgLim' parameter of -** the #CFE_SB_SubscribeEx API or uses the default value of 4 if using the -** #CFE_SB_Subscribe API. -**/ -#define CFE_SB_MSGID_LIM_ERR_EID 17 - -/** \brief 'Rcv Err:Bad Input Arg:BufPtr 0x\%x,pipe \%d,t/o \%d,app \%s' -** \event 'Rcv Err:Bad Input Arg:BufPtr 0x\%x,pipe \%d,t/o \%d,app \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when an invalid paramter is passed into the -** #CFE_SB_RcvMsg API. Two possibile problems would be the first parameter (*BufPtr) -** being NULL or the third paramter (TimeOut) being less than -1. -**/ -#define CFE_SB_RCV_BAD_ARG_EID 18 - -/** \brief 'Rcv Err:PipeId \%d does not exist,app \%s' -** \event 'Rcv Err:PipeId \%d does not exist,app \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when an invalid PipeId is passed into the -** #CFE_SB_RcvMsg API. The SB Pipe Table shows all valid PipeIds and may be viewed -** for verification. -**/ -#define CFE_SB_BAD_PIPEID_EID 19 - - -/** \brief 'Subscribe Err:Request for Destination Blk failed for Msg 0x\%x,Pipe \%s' -** \event 'Subscribe Err:Request for Destination Blk failed for Msg 0x\%x,Pipe \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the SB receives an error from the memory -** pool in the attempt to obtain a new destination block. Then memory pool statistics -** may be viewed by sending the related ES command. -**/ -#define CFE_SB_DEST_BLK_ERR_EID 20 - - -/** \brief 'Send Err:Invalid msgid in msg,MsgId 0x\%x,App \%s' -** \event 'Send Err:Invalid msgid in msg,MsgId 0x\%x,App \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the #CFE_SB_SendMsg API is called and -** the SB discovers that the message to send has a msg id that is invalid. It may be -** due to a msg id that is greater than cfg parameter #CFE_SB_HIGHEST_VALID_MSGID -**/ -#define CFE_SB_SEND_INV_MSGID_EID 21 - -/** \brief 'Sending Subscription Report Msg=0x\%x,Pipe=\%d,Stat=0x\%x' -** \event 'Sending Subscription Report Msg=0x\%x,Pipe=\%d,Stat=0x\%x' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This debug event message is issued when SB subscription reporting is enabled, -** (which is disabled by default) and a subscription is successfully received. -**/ -#define CFE_SB_SUBSCRIPTION_RPT_EID 22 - - -/** \brief 'Sending Unsubscription Report Msg=0x\%x,Pipe=\%d,Stat=0x\%x' -** \event 'Sending Unsubscription Report Msg=0x\%x,Pipe=\%d,Stat=0x\%x' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This debug event message is issued when SB subscription reporting is enabled, -** (which is disabled by default) and a subscription is successfully received. -**/ -#define CFE_SB_UNSUBSCRIPTION_RPT_EID 24 - - -/** \brief 'Pipe Overflow,MsgId 0x\%x,pipe \%s,stat 0x\%x,app \%s' -** \event 'Pipe Overflow,MsgId 0x\%x,pipe \%s,stat 0x\%x,app \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the #CFE_SB_SendMsg API is called and -** encounters an error when attempting to write the msg to the destination pipe -** (which is an underlying queue). This could indicate that the owner of the pipe is -** not readings its messages fast enough or at all. It may also mean that the -** pipe depth is not deep enough. The pipe depth is an input parameter to the -** #CFE_SB_CreatePipe API. -**/ -#define CFE_SB_Q_FULL_ERR_EID 25 - -/** \brief 'Pipe Write Err,MsgId 0x\%x,pipe \%s,stat 0x\%x,app \%s' -** \event 'Pipe Write Err,MsgId 0x\%x,pipe \%s,stat 0x\%x,app \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the #CFE_SB_SendMsg API is called and -** encounters an error when attempting to write the msg to the destination pipe -** (which is an underlying queue). More precisely, the OS API #OS_QueuePut has -** returned an unexpected error. The return code is displayed in the event. For -** more information, the user may look up the return code in the OSAL documention or -** source code. -**/ -#define CFE_SB_Q_WR_ERR_EID 26 - -/** \brief 'Pipe Read Err,pipe \%s,app \%s,stat 0x\%x' -** \event 'Pipe Read Err,pipe \%s,app \%s,stat 0x\%x' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the #CFE_SB_SendMsg API is called and -** encounters an error when attempting to read the msg from the destination pipe -** (which is an underlying queue). More precisely, the OS API #OS_QueueGet has -** returned an unexpected error. The return code is displayed in the event. For -** more information, the user may look up the return code in the OSAL documention or -** source code. -**/ -#define CFE_SB_Q_RD_ERR_EID 27 - -/** \brief 'No-op Cmd Rcvd' -** \event 'No-op Cmd Rcvd' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This info event message is issued in response an SB NO-OP command -**/ -#define CFE_SB_CMD0_RCVD_EID 28 - -/** \brief 'Reset Counters Cmd Rcvd' -** \event 'Reset Counters Cmd Rcvd' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This debug event message is issued in response an SB Reset Counters command -**/ -#define CFE_SB_CMD1_RCVD_EID 29 - - -/** \brief 'SB GetLastSender Err:Rcvd Null Ptr,Pipe=%d,App=%s' -** \event 'SB GetLastSender Err:Rcvd Null Ptr,Pipe=%d,App=%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when SB receives a Null pointer from the -** caller of CFE_SB_GetLastSenderId. -**/ -#define CFE_SB_LSTSNDER_ERR1_EID 30 - -/** \brief 'SB GetLastSender Err:Rcvd Invalid Pipe=%d,App=%s' -** \event 'SB GetLastSender Err:Rcvd Invalid Pipe=%d,App=%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when SB receives an invalid pipe from the -** caller of CFE_SB_GetLastSenderId. -**/ -#define CFE_SB_LSTSNDER_ERR2_EID 31 - - -/** \brief 'Software Bus Statistics packet sent' -** \event 'Software Bus Statistics packet sent' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This debug event message is issued when SB receives a cmd to send the SB -** statistics pkt. -**/ -#define CFE_SB_SND_STATS_EID 32 - -/** \brief 'Enbl Route Cmd:Route does not exist.Msg 0x\%x,Pipe \%d' -** \event 'Enbl Route Cmd:Route does not exist.Msg 0x\%x,Pipe \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when SB receives a cmd to enable a route that -** does not exist in the routing table. A route is defined by a MsgId, PipeId pair. -**/ -#define CFE_SB_ENBL_RTE1_EID 33 - -/** \brief 'Enabling Route,Msg 0x\%x,Pipe \%d' -** \event 'Enabling Route,Msg 0x\%x,Pipe \%d' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This debug event message is issued when SB receives a cmd to enable a route and -** the request is successfully executed. -**/ -#define CFE_SB_ENBL_RTE2_EID 34 - -/** \brief 'Enbl Route Cmd:Invalid Param.Msg 0x\%x,Pipe \%d' -** \event 'Enbl Route Cmd:Invalid Param.Msg 0x\%x,Pipe \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when SB receives a cmd to enable a route and -** the MsgId or PipeId does not pass the validation checks. The MsgId must be less -** than cfg param #CFE_SB_HIGHEST_VALID_MSGID. The PipeId must exist and be less than -** cfg param #CFE_SB_MAX_PIPES. The SB pipe table may be viewed to verify the PipeId -** existence. -**/ -#define CFE_SB_ENBL_RTE3_EID 35 - -/** \brief 'Disable Route Cmd:Route does not exist,Msg 0x\%x,Pipe \%d' -** \event 'Disable Route Cmd:Route does not exist,Msg 0x\%x,Pipe \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when SB receives a cmd to disable a route that -** does not exist in the routing table. A route is defined by a MsgId, PipeId pair. -**/ -#define CFE_SB_DSBL_RTE1_EID 36 - -/** \brief 'Route Disabled,Msg 0x\%x,Pipe \%d' -** \event 'Route Disabled,Msg 0x\%x,Pipe \%d' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This debug event message is issued when SB receives a cmd to disable a route and -** the request is successfully executed. -**/ -#define CFE_SB_DSBL_RTE2_EID 37 - -/** \brief 'Disable Route Cmd:Invalid Param.Msg 0x\%x,Pipe \%d' -** \event 'Disable Route Cmd:Invalid Param.Msg 0x\%x,Pipe \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when SB receives a cmd to disable a route and -** the MsgId or PipeId does not pass the validation checks. The MsgId must be less -** than cfg param #CFE_SB_HIGHEST_VALID_MSGID. The PipeId must exist and be less than -** cfg param #CFE_SB_MAX_PIPES. The SB pipe table may be viewed to verify the PipeId -** existence. -**/ -#define CFE_SB_DSBL_RTE3_EID 38 - -/** \brief '\%s written:Size=\%d,Entries=\%d' -** \event '\%s written:Size=\%d,Entries=\%d' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This debug event message is issued after the SB routing info file, pipe info -** file or the map info file is written and closed. This is done is response to -** the SB 'Send Routing Info' cmd, the SB 'Send pipe Info' cmd or the SB 'Send -** Map Info' cmd, respectively. -**/ -#define CFE_SB_SND_RTG_EID 39 - - -/** \brief 'Error creating file \%s, stat=0x\%x' -** \event 'Error creating file \%s, stat=0x\%x' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the SB 'Send Routing Info' cmd is -** received and the file create fails. The event displays the status received from -** the OS. -**/ -#define CFE_SB_SND_RTG_ERR1_EID 40 - - -/** \brief 'SB GetLastSender Err:Caller(\%s) is not the owner of pipe \%d' -** \event 'SB GetLastSender Err:Caller(\%s) is not the owner of pipe \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the caller of CFE_SB_GetLastSenderId is -** not the owner of the given pipe Id. -**/ -#define CFE_SB_GLS_INV_CALLER_EID 41 - - -/** \brief 'Invalid Cmd, Unexpected Command Code \%d' -** \event 'Invalid Cmd, Unexpected Command Code \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the SB receives a cmd that has an -** unexpected cmd code. -**/ -#define CFE_SB_BAD_CMD_CODE_EID 42 - -/** \brief 'Invalid Cmd, Unexpected Msg Id: 0x\%04x' -** \event 'Invalid Cmd, Unexpected Msg Id: 0x\%04x' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the SB receives a msg that has an -** unexpected msg id. -**/ -#define CFE_SB_BAD_MSGID_EID 43 - - -/** \brief 'Full Sub Pkt \%d Sent,Entries=\%d,Stat=0x\%x\n' -** \event 'Full Sub Pkt \%d Sent,Entries=\%d,Stat=0x\%x\n' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This debug event message is issued in response to the -** 'Send Previous Subscriptions' command and a full pkt segment is sent. -**/ -#define CFE_SB_FULL_SUB_PKT_EID 44 - -/** \brief 'Partial Sub Pkt \%d Sent,Entries=\%d,Stat=0x\%x' -** \event 'Partial Sub Pkt \%d Sent,Entries=\%d,Stat=0x\%x' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This debug event message is issued in response to the -** 'Send Previous Subscriptions' command and a partial pkt segment is sent. -**/ -#define CFE_SB_PART_SUB_PKT_EID 45 - - -/** \brief 'Pipe Delete Error:Bad Argument,PipedId \%d,Requestor \%s,Idx \%d,Stat \%d' -** \event 'Pipe Delete Error:Bad Argument,PipedId \%d,Requestor \%s,Idx \%d,Stat \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued from one of SB's subscribe API's when the -** function #CFE_SB_GetRoutingTblIdx returns an index that is out of range. This -** error is not expected and is an indication that the SB internal memory has been -** corrupted. -**/ -#define CFE_SB_DEL_PIPE_ERR1_EID 46 - -/** \brief 'Pipe Deleted:id \%d,owner \%s' -** \event 'Pipe Deleted:id \%d,owner \%s' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This debug event message is issued when the #CFE_SB_DeletePipe API is called and -** the request is successfully completed. -**/ -#define CFE_SB_PIPE_DELETED_EID 47 - -/** \brief 'Subscription Removed:Msg 0x\%x on pipe \%d,app \%s' -** \event 'Subscription Removed:Msg 0x\%x on pipe \%d,app \%s' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This debug event message is issued when #CFE_SB_Unsubscribe API is called -** and the request is successfully completed. -**/ -#define CFE_SB_SUBSCRIPTION_REMOVED_EID 48 - -/** \brief 'File write,byte cnt err,file \%s,request=\%d,actual=\%d' -** \event 'File write,byte cnt err,file \%s,request=\%d,actual=\%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when one of many SB's file write operations -** is unsuccessful. This event is a result of #CFE_FS_WriteHeader or OS_write -** returning something other than the number of bytes requested to be written. -** The requested value and the return value are displayed in the event. -**/ -#define CFE_SB_FILEWRITE_ERR_EID 49 - -/** \brief 'Subscribe Err:Invalid Pipe Id,Msg=0x\%x,PipeId=\%d,App \%s' -** \event 'Subscribe Err:Invalid Pipe Id,Msg=0x\%x,PipeId=\%d,App \%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the input PipeId has a value that is not -** listed in the pipe table. This typically means that the pipe does not exist. -** The pipe table may be viewed for verification. -**/ -#define CFE_SB_SUB_INV_PIPE_EID 50 - -/** \brief 'Subscribe Err:Caller(\%s) is not the owner of pipe \%d, Msg=0x\%x' -** \event 'Subscribe Err:Caller(\%s) is not the owner of pipe \%d, Msg=0x\%x' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when one of the SB subscribe API's are called -** and the requestor is not the owner of the pipe. Only the owner of the pipe may -** subscribe to messages on the pipe. -**/ -#define CFE_SB_SUB_INV_CALLER_EID 51 - -/** \brief 'Unsubscribe Err:Invalid Pipe Id Msg=0x\%x,Pipe=\%d,app=\%s' -** \event 'Unsubscribe Err:Invalid Pipe Id Msg=0x\%x,Pipe=\%d,app=\%s' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when one of the SB unsubscribe API's are -** called and the input parameter PipeId is not listed in the pipe table. -** This typically means that the pipe does not exist. The pipe table may be viewed -** for verification. -**/ -#define CFE_SB_UNSUB_INV_PIPE_EID 52 - -/** \brief 'Unsubscribe Err:Caller(\%s) is not the owner of pipe \%d,Msg=0x\%x' -** \event 'Unsubscribe Err:Caller(\%s) is not the owner of pipe \%d,Msg=0x\%x' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when one of the SB unsubscribe API's are -** called and the requestor is not the owner of the pipe (or ES). Only the owner of -** the pipe(or ES for cleanup purposes)may unsubscribe messages from a pipe. -**/ -#define CFE_SB_UNSUB_INV_CALLER_EID 53 - -/** \brief 'Pipe Delete Error:Caller(\%s) is not the owner of pipe \%d' -** \event 'Pipe Delete Error:Caller(\%s) is not the owner of pipe \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This error event message is issued when the #CFE_SB_DeletePipe API is called by a -** task that is not the owner of the pipe. Pipes may be deleted only by the task -** that created the pipe or ES(for cleanup purposes). -**/ -#define CFE_SB_DEL_PIPE_ERR2_EID 54 - - -#endif /* _cfe_sb_events_ */ - -/************************/ -/* End of File Comment */ -/************************/ - diff --git a/src/components/interface/cFE/cfe_sb_msg.h b/src/components/interface/cFE/cfe_sb_msg.h deleted file mode 100644 index 3a18929162..0000000000 --- a/src/components/interface/cFE/cfe_sb_msg.h +++ /dev/null @@ -1,769 +0,0 @@ -/****************************************************************************** -** File: cfe_sb_msg.h -** -** Copyright (c) 2004-2012, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** -** Purpose: -** This header file contains structure definitions for all SB command and -** telemetry packets -** -** Author: R.McGraw/SSI -** -** $Log: cfe_sb_msg.h $ -** Revision 1.11 2014/07/15 08:50:49GMT-05:00 rmcgraw -** DCR22588:1 Add spare byte to ena/dis packet route cmd -** Revision 1.10 2012/01/13 12:32:51EST acudmore -** Changed license text to reflect open source -** Revision 1.9 2011/12/20 10:53:44EST rmcgraw -** DCR17187:2 Changed MsgIdToPipeErrCnt to MsgLimErrCnt -** Revision 1.8 2009/05/08 11:29:41EDT rmcgraw -** DCR7631:1 Changed comment regarding internal error counter -** Revision 1.7 2009/04/01 15:22:38EDT rmcgraw -** DCR6296:4 Changed tlm item pk-mem-in-use to unmarked mem -** Revision 1.6 2009/02/26 17:47:24EST rmcgraw -** DCR6805:1 Corrected comment for InUse member of pipe depth stats -** Revision 1.5 2009/02/11 14:18:49EST rmcgraw -** DCR6269:1 Removed the 'Buf' in MemInUse names -** Revision 1.4 2009/02/06 12:55:55EST rmcgraw -** DCR5802:3 Removed two of four new telemetry items -** Revision 1.3 2009/02/05 16:19:38EST rmcgraw -** DCR5802:2 Added SB statistics to hk pkt -** Revision 1.2 2008/12/08 12:06:58EST dkobe -** Updates to correct doxygen errors -** Revision 1.1 2008/04/17 08:05:23EDT ruperera -** Initial revision -** Member added to cfe project on tlserver3 -** Revision 1.13 2007/09/25 15:39:07EDT rjmcgraw -** DCR5127 Added doxygen comments -** Revision 1.12 2007/09/19 15:31:59EDT rjmcgraw -** DCR5055 Removed SB event log items in HK tlm pkt and statistics pkt -** Revision 1.11 2007/09/18 13:50:59EDT rjmcgraw -** DCR5045:1 Added User Guide information in doxygen comments -** Revision 1.10 2007/06/07 13:07:48EDT dlkobe -** Added Command and Telemetry doxygen comments to TIME, EVS and SB -** Revision 1.9 2007/06/02 10:10:14EDT dlkobe -** Added doxygen comments for User's Guides -** Revision 1.8 2007/05/23 12:06:51EDT rjmcgraw -** Added doxygen comments -** Revision 1.7 2007/05/16 15:13:41EDT dlkobe -** Added MemPoolHandle members to HK packet -** Revision 1.6 2007/04/24 11:07:59EDT rjmcgraw -** Added PipeId to PipeDepthStats -** Revision 1.5 2007/04/24 09:39:29EDT rjmcgraw -** Reformatted SB statistics pkt structure and PipeDepthStats struct -** Revision 1.4 2007/04/19 15:47:23EDT rjmcgraw -** Moved subscription reporting structs to cfe_sb_msg.h -** Revision 1.2 2007/03/27 13:47:41EST rjmcgraw -** Added DupSubscriptionsCnt to HK Tlm -** Revision 1.1 2007/03/27 08:59:54EST rjmcgraw -** Initial revision -** Member added to project -** -******************************************************************************/ - -#ifndef _cfe_sb_msg_ -#define _cfe_sb_msg_ - -/* -** Includes -*/ -#include "common_types.h" -#include "cfe_sb.h" -#include "osconfig.h" -#include "cfe_es.h" - - -/**************************************** -** SB task command packet command codes -****************************************/ - -/** \cfesbcmd Software Bus No-Op -** -** \par Description -** This command performs no other function than to increment the -** command execution counter. The command may be used to verify -** general aliveness of the Software Bus task. -** -** \cfecmdmnemonic \SB_NOOP -** -** \par Command Structure -** #CFE_SB_CmdHdr_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \SB_CMDPC - command execution counter will -** increment -** - The #CFE_SB_CMD0_RCVD_EID informational event message will -** be generated -** -** \par Error Conditions -** There are no error conditions for this command. If the Software -** Bus receives the command, the event is sent (although it -** may be filtered by EVS) and the counter is incremented -** unconditionally. -** -** \par Criticality -** None -** -** \sa -*/ -#define CFE_SB_NOOP_CC 0 - -/** \cfesbcmd Software Bus Reset Counters -** -** \par Description -** This command resets the following counters within the Software -** Bus housekeeping telemetry: -** - Command Execution Counter (\SB_CMDPC) -** - Command Error Counter (\SB_CMDEC) -** -** \cfecmdmnemonic \SB_RESETCTRS -** -** \par Command Structure -** #CFE_SB_CmdHdr_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \SB_CMDPC - command execution counter will -** increment -** - The #CFE_SB_CMD1_RCVD_EID informational event message will -** be generated -** -** \par Error Conditions -** There are no error conditions for this command. If the Software -** Bus receives the command, the event is sent (although it -** may be filtered by EVS) and the counter is incremented -** unconditionally. -** -** \par Criticality -** This command is not inherently dangerous. However, it is -** possible for ground systems and on-board safing procedures -** to be designed such that they react to changes in the counter -** values that are reset by this command. -** -** \sa -*/ -#define CFE_SB_RESET_CTRS_CC 1 - -/** \cfesbcmd Send Software Bus Statistics -** -** \par Description -** This command will cause the SB task to send a statistics packet -** containing current utilization figures and high water marks which -** may be useful for checking the margin of the SB platform configuration -** settings. -** -** \cfecmdmnemonic \SB_DUMPSTATS -** -** \par Command Structure -** #CFE_SB_CmdHdr_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \SB_CMDPC - command execution counter will increment -** - Receipt of statistics packet with MsgId #CFE_SB_STATS_TLM_MID -** - The #CFE_SB_SND_STATS_EID debug event message will be generated. All -** debug events are filtered by default. -** -** \par Error Conditions -** There are no error conditions for this command. If the Software -** Bus receives the command, the debug event is sent and the counter -** is incremented unconditionally. -** -** \par Criticality -** This command is not inherently dangerous. It will create and send -** a message on the software bus. If performed repeatedly, it is -** possible that receiver pipes may overflow. -** -** \sa -*/ -#define CFE_SB_SEND_SB_STATS_CC 2 - -/** \cfesbcmd Write Software Bus Routing Info to a File -** -** \par Description -** This command will create a file containing the software bus routing -** information. The routing information contains information about every -** subscription that has been received through the SB subscription APIs. -** An abosulte path and filename may be specified in the command. -** If this command field contains an empty string (NULL terminator as -** the first character) the default file path and name is used. -** The default file path and name is defined in the platform -** configuration file as #CFE_SB_DEFAULT_ROUTING_FILENAME. -** -** \cfecmdmnemonic \SB_WRITEROUTING2FILE -** -** \par Command Structure -** #CFE_SB_WriteFileInfoCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \SB_CMDPC - command execution counter will increment. -** - Specified filename created at specified location. See description. -** - The #CFE_SB_SND_RTG_EID debug event message will be generated. All -** debug events are filtered by default. -** -** \par Error Conditions -** - Errors may occur during write operations to the file. Possible -** causes might be insufficient space in the file system or the -** filename or file path is improperly specified. -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \SB_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases. See #CFE_SB_SND_RTG_ERR1_EID and #CFE_SB_FILEWRITE_ERR_EID -** -** \par Criticality -** This command is not inherently dangerous. It will create a new -** file in the file system and could, if performed repeatedly without -** sufficient file management by the operator, fill the file system. -** -** \sa #CFE_SB_SEND_PIPE_INFO_CC, #CFE_SB_SEND_MAP_INFO_CC, #CFE_SB_WriteFileInfoCmd_t -*/ -#define CFE_SB_SEND_ROUTING_INFO_CC 3 - -/** \cfesbcmd Enable Software Bus Route -** -** \par Description -** This command will enable a particular destination. The destination -** is specified in terms of MsgID and PipeID. The MsgId and PipeID are -** parmaters in the command. All destinations are enabled by default. -** This command is needed only after a #CFE_SB_DISABLE_ROUTE_CC command -** is used. -** -** \cfecmdmnemonic \SB_ENAROUTE -** -** \par Command Structure -** #CFE_SB_EnRoutCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \SB_CMDPC - command execution counter will increment -** - View routing information #CFE_SB_SEND_ROUTING_INFO_CC to verify -** enable/disable state change -** - The #CFE_SB_ENBL_RTE2_EID debug event message will be generated. All -** debug events are filtered by default. -** - Destination will begin receiving messages. -** -** \par Error Conditions -** An Error may occur if the MsgId or PipeId parmaters do not pass -** validation or the destination does not exist. - -** Evidence of failure may be found in the following telemetry: -** - \b \c \SB_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases. See #CFE_SB_ENBL_RTE1_EID or #CFE_SB_ENBL_RTE3_EID -** -** \par Criticality -** This command is not inherently dangerous. -** -** \sa #CFE_SB_SEND_ROUTING_INFO_CC, #CFE_SB_DISABLE_ROUTE_CC, #CFE_SB_EnRoutCmd_t -*/ -#define CFE_SB_ENABLE_ROUTE_CC 4 - -/** \cfesbcmd Disable Software Bus Route -** -** \par Description -** This command will disable a particular destination. The destination -** is specified in terms of MsgID and PipeID. The MsgId and PipeID are -** parmaters in the command. All destinations are enabled by default. -** -** \cfecmdmnemonic \SB_DISROUTE -** -** \par Command Structure -** #CFE_SB_EnRoutCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \SB_CMDPC - command execution counter will increment -** - View routing information #CFE_SB_SEND_ROUTING_INFO_CC to verify -** enable/disable state change -** - The #CFE_SB_DSBL_RTE2_EID debug event message will be generated. All -** debug events are filtered by default. -** - Destination will stop receiving messages. -** -** \par Error Conditions -** An Error may occur if the MsgId or PipeId parmaters do not pass -** validation or the destination does not exist. - -** Evidence of failure may be found in the following telemetry: -** - \b \c \SB_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases. See #CFE_SB_DSBL_RTE1_EID or #CFE_SB_DSBL_RTE3_EID -** -** \par Criticality -** This command is not intended to be used in nominal conditions. It is -** possible to get into a state where a destination cannot be re-enabled -** without reseting the processor. For instance, sending this command -** with #CFE_SB_CMD_MID and the SB_Cmd_Pipe would inhibit any ground -** commanding to the software bus until the processor was reset. There -** are similar problems that may occur when using this command. -** -** \sa #CFE_SB_SEND_ROUTING_INFO_CC, #CFE_SB_ENABLE_ROUTE_CC, #CFE_SB_EnRoutCmd_t -*/ -#define CFE_SB_DISABLE_ROUTE_CC 5 - -/** \cfesbcmd Write Pipe Info to a File -** -** \par Description -** This command will create a file containing the software bus pipe -** information. The pipe information contains information about every -** pipe that has been created through the #CFE_SB_CreatePipe API. An -** abosulte path and filename may be specified in the command. -** If this command field contains an empty string (NULL terminator as -** the first character) the default file path and name is used. -** The default file path and name is defined in the platform -** configuration file as #CFE_SB_DEFAULT_PIPE_FILENAME. -** -** \cfecmdmnemonic \SB_WRITEPIPE2FILE -** -** \par Command Structure -** #CFE_SB_WriteFileInfoCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \SB_CMDPC - command execution counter will increment. -** - Specified filename created at specified location. See description. -** - The #CFE_SB_SND_RTG_EID debug event message will be generated. All -** debug events are filtered by default. -** -** \par Error Conditions -** - Errors may occur during write operations to the file. Possible -** causes might be insufficient space in the file system or the -** filename or file path is improperly specified. -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \SB_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases. See #CFE_SB_SND_RTG_ERR1_EID and #CFE_SB_FILEWRITE_ERR_EID -** -** \par Criticality -** This command is not inherently dangerous. It will create a new -** file in the file system and could, if performed repeatedly without -** sufficient file management by the operator, fill the file system. -** -** \sa #CFE_SB_SEND_ROUTING_INFO_CC, #CFE_SB_SEND_MAP_INFO_CC -*/ -#define CFE_SB_SEND_PIPE_INFO_CC 7 - -/** \cfesbcmd Write Map Info to a File -** -** \par This command will create a file containing the software bus message -** map information. The message map is a lookup table (an array of -** uint16s)that allows fast access to the correct routing table element -** during a softeware bus send operation. This is diasgnostic -** information that may be needed due to the dynamic nature of the -** cFE software bus. An abosulte path and filename may be specified -** in the command. If this command field contains an empty string -** (NULL terminator as the first character) the default file path and -** name is used. The default file path and name is defined in the -** platform configuration file as #CFE_SB_DEFAULT_MAP_FILENAME. -** -** \cfecmdmnemonic \SB_WRITEMAP2FILE -** -** \par Command Structure -** #CFE_SB_WriteFileInfoCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \SB_CMDPC - command execution counter will increment. -** - Specified filename created at specified location. See description. -** - The #CFE_SB_SND_RTG_EID debug event message will be generated. All -** debug events are filtered by default. -** -** \par Error Conditions -** - Errors may occur during write operations to the file. Possible -** causes might be insufficient space in the file system or the -** filename or file path is improperly specified. -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \SB_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases. See #CFE_SB_SND_RTG_ERR1_EID and #CFE_SB_FILEWRITE_ERR_EID -** -** \par Criticality -** This command is not inherently dangerous. It will create a new -** file in the file system and could, if performed repeatedly without -** sufficient file management by the operator, fill the file system. -** -** \sa #CFE_SB_SEND_ROUTING_INFO_CC, #CFE_SB_SEND_PIPE_INFO_CC -*/ -#define CFE_SB_SEND_MAP_INFO_CC 8 - -/** \cfesbcmd Enable Subscription Reporting Command -** -** \par This command will enable subscription reporting and is intended to -** be used only by the CFS SBN (Software Bus Networking) Application. -** It is not intended to be sent from the ground or used by operations. -** When subscription reporting is enabled, SB will generate -** and send a software bus packet for each subscription received. -** The software bus packet that is sent contains the information -** received in the subscription API. This subscription report is -** neeeded by SBN if offboard routing is required. -* -** \cfecmdmnemonic \SB_ENASUBRPTG -** -** \par Command Structure -** #CFE_SB_CmdHdr_t -** -** \par Command Verification -** Successful execution of this command will result in the sending -** of a packet (with the #CFE_SB_ONESUB_TLM_MID MsgId) for each -** subscription received by SB through the subscription APIs. -** -** \par Error Conditions -** None -** -** \par Criticality -** None -** -** \sa #CFE_SB_SubRprtMsg_t, #CFE_SB_DISABLE_SUB_REPORTING_CC, -** #CFE_SB_SEND_PREV_SUBS_CC -*/ -#define CFE_SB_ENABLE_SUB_REPORTING_CC 9 - -/** \cfesbcmd Disable Subscription Reporting Command -** -** \par This command will disable subscription reporting and is intended to -** be used only by the CFS SBN (Software Bus Networking) Application. -** It is not intended to be sent from the ground or used by operations. -** When subscription reporting is enabled, SB will generate -** and send a software bus packet for each subscription received. -** The software bus packet that is sent contains the information -** received in the subscription API. This subscription report is -** neeeded by SBN if offboard routing is required. -** -** \cfecmdmnemonic \SB_DISSUBRPTG -** -** \par Command Structure -** #CFE_SB_CmdHdr_t -** -** \par Command Verification -** Successful execution of this command will result in the suppression -** of packets (with the #CFE_SB_ONESUB_TLM_MID MsgId) for each -** subscription received by SB through the subscription APIs. -** -** \par Error Conditions -** None -** -** \par Criticality -** None -** -** \sa #CFE_SB_SubRprtMsg_t, #CFE_SB_ENABLE_SUB_REPORTING_CC, -** #CFE_SB_SEND_PREV_SUBS_CC -*/ -#define CFE_SB_DISABLE_SUB_REPORTING_CC 10 - -/** \cfesbcmd Send Previous Subscriptions Command -** -** \par This command generates a series of packets that contain information -** regarding all subscriptions previously received by SB. -** This command is intended to be used only by the CFS SBN(Software Bus -** Networking) Application. -** It is not intended to be sent from the ground or used by operations. -** When this command is received the software bus will generate and -** send a series of packets containing information about all subscription -** previously received. -** -** \cfecmdmnemonic \SB_SENDPREVSUBS -** -** \par Command Structure -** #CFE_SB_CmdHdr_t -** -** \par Command Verification -** Successful execution of this command will result in a series -** of packets (with the #CFE_SB_ALLSUBS_TLM_MID MsgId) being sent -** on the software bus. -** -** \par Error Conditions -** None -** -** \par Criticality -** None -** -** \sa #CFE_SB_PrevSubMsg_t, #CFE_SB_ENABLE_SUB_REPORTING_CC, -** #CFE_SB_DISABLE_SUB_REPORTING_CC -*/ -#define CFE_SB_SEND_PREV_SUBS_CC 11 - - -/**************************** -** SB Command Formats ** -*****************************/ - - -/** -** \brief Write File Info Commands -** -** This structure contains a generic definition used by three SB commands, -** 'Write Routing Info to File' #CFE_SB_SEND_ROUTING_INFO_CC, -** 'Write Pipe Info to File' #CFE_SB_SEND_PIPE_INFO_CC and -** 'Write Map Info to File' #CFE_SB_SEND_MAP_INFO_CC. -*/ -typedef struct{ - char Filename[OS_MAX_PATH_LEN];/**< \brief Path and Filename of data to be loaded */ -} CFE_SB_WriteFileInfoCmd_Payload_t; - -typedef struct{ - CFE_SB_CmdHdr_t Hdr;/**< \brief cFE Software Bus Command Message Header #CFE_SB_CmdHdr_t */ - CFE_SB_WriteFileInfoCmd_Payload_t Payload; -}CFE_SB_WriteFileInfoCmd_t; - - -/** -** \brief Enable/Disable Route Commands -** -** This structure contains a definition used by two SB commands, -** 'Enable Route' #CFE_SB_ENABLE_ROUTE_CC and 'Disable Route' #CFE_SB_DISABLE_ROUTE_CC. -** A route is the destination pipe for a particular message and is therefore defined -** as a MsgId and PipeId combination. -*/ -typedef struct { - - CFE_SB_MsgId_t MsgId;/**< \brief Message ID of route to be enabled or disabled #CFE_SB_MsgId_t */ - CFE_SB_PipeId_t Pipe;/**< \brief Pipe ID of route to be enabled or disabled #CFE_SB_PipeId_t */ - uint8 Spare;/**<\brief Spare byte to make command even number of bytes */ -} CFE_SB_EnRoutCmd_Payload_t; - -typedef struct{ - CFE_SB_CmdHdr_t Hdr;/**< \brief cFE Software Bus Command Message Header #CFE_SB_CmdHdr_t */ - CFE_SB_EnRoutCmd_Payload_t Payload; -} CFE_SB_EnRoutCmd_t; - - -/**************************** -** SB Telemetry Formats ** -*****************************/ - -/** -** \cfesbtlm Software Bus task housekeeping Packet -*/ -typedef struct { - - uint8 CommandCnt;/**< \cfetlmmnemonic \SB_CMDPC - \brief Count of valid commands received */ - uint8 CmdErrCnt;/**< \cfetlmmnemonic \SB_CMDEC - \brief Count of invalid commands received */ - uint8 NoSubscribersCnt;/**< \cfetlmmnemonic \SB_NOSUBEC - \brief Count pkts sent with no subscribers */ - uint8 MsgSendErrCnt;/**< \cfetlmmnemonic \SB_MSGSNDEC - \brief Count of message send errors */ - - uint8 MsgReceiveErrCnt;/**< \cfetlmmnemonic \SB_MSGRECEC - \brief Count of message receive errors */ - uint8 InternalErrCnt;/**< \cfetlmmnemonic \SB_INTERNALEC - \brief Count of queue read or write errors */ - uint8 CreatePipeErrCnt;/**< \cfetlmmnemonic \SB_NEWPIPEEC - \brief Count of errors in create pipe API */ - uint8 SubscribeErrCnt;/**< \cfetlmmnemonic \SB_SUBSCREC - \brief Count of errors in subscribe API */ - - uint8 Spare;/**< \cfetlmmnemonic \SB_SPARE - \brief Spare Byte */ - uint8 DupSubscriptionsCnt;/**< \cfetlmmnemonic \SB_DUPSUBCNT - \brief Count of duplicate subscriptions */ - uint8 Spare2Align[2];/**< \cfetlmmnemonic \SB_SPARE2ALIGN - \brief Spare bytes to ensure alignment */ - - uint16 PipeOverflowErrCnt;/**< \cfetlmmnemonic \SB_PIPEOVREC - \brief Count of pipe overflow errors */ - uint16 MsgLimErrCnt;/**< \cfetlmmnemonic \SB_MSGLIMEC - \brief Count of msg id to pipe errors */ - - CFE_ES_MemHandle_t MemPoolHandle;/**< \cfetlmmnemonic \SB_MEMPOOLHANDLE - \brief Handle to SB's Memory Pool */ - - uint32 MemInUse;/**< \cfetlmmnemonic \SB_MEMINUSE - \brief Memory in use */ - - uint32 UnmarkedMem;/**< \cfetlmmnemonic \SB_UNMARKEDMEM - \brief cfg param CFE_SB_BUF_MEMORY_BYTES minus Peak Memory in use */ -} CFE_SB_HKMsg_Payload_t; - -typedef struct{ - CFE_SB_TlmHdr_t Hdr;/**< \brief cFE Software Bus Telemetry Message Header */ - CFE_SB_HKMsg_Payload_t Payload; -} CFE_SB_HKMsg_t; - - -/** -** \brief SB Pipe Depth Statistics -** -** Used in SB Statistics Telemetry Packet #CFE_SB_StatMsg_t -*/ -typedef struct { - - CFE_SB_PipeId_t PipeId;/**< \cfetlmmnemonic \SB_PDPIPEID - \brief Pipe Id associated with the stats below */ - uint8 Spare;/**< \cfetlmmnemonic \SB_PDSPARE - \brief Spare byte to ensure alignment */ - uint16 Depth;/**< \cfetlmmnemonic \SB_PDDEPTH - \brief Number of messages the pipe can hold */ - uint16 InUse;/**< \cfetlmmnemonic \SB_PDINUSE - \brief Number of messages currently on the pipe */ - uint16 PeakInUse;/**< \cfetlmmnemonic \SB_PDPKINUSE - \brief Peak number of messages that have been on the pipe */ - -}CFE_SB_PipeDepthStats_t; - -/** -** \cfesbtlm SB Statistics Telemetry Packet -** -** SB Statistics packet sent (via CFE_SB_SendMsg) in response to #CFE_SB_SEND_SB_STATS_CC -*/ -typedef struct { - - uint32 MsgIdsInUse;/**< \cfetlmmnemonic \SB_SMMIDIU - \brief Current number of MsgIds with a destination */ - uint32 PeakMsgIdsInUse;/**< \cfetlmmnemonic \SB_SMPMIDIU - \brief Peak number of MsgIds with a destination */ - uint32 MaxMsgIdsAllowed;/**< \cfetlmmnemonic \SB_SMMMIDALW - \brief cFE Cfg Param \link #CFE_SB_MAX_MSG_IDS \endlink */ - - uint32 PipesInUse;/**< \cfetlmmnemonic \SB_SMPIU - \brief Number of pipes currently in use */ - uint32 PeakPipesInUse;/**< \cfetlmmnemonic \SB_SMPPIU - \brief Peak number of pipes since last reboot */ - uint32 MaxPipesAllowed;/**< \cfetlmmnemonic \SB_SMMPALW - \brief cFE Cfg Param \link #CFE_SB_MAX_PIPES \endlink */ - - uint32 MemInUse;/**< \cfetlmmnemonic \SB_SMBMIU - \brief Memory bytes currently in use for SB msg transfers */ - uint32 PeakMemInUse;/**< \cfetlmmnemonic \SB_SMPBMIU - \brief Peak memory bytes in use for SB msg transfers */ - uint32 MaxMemAllowed;/**< \cfetlmmnemonic \SB_SMMBMALW - \brief cFE Cfg Param \link #CFE_SB_BUF_MEMORY_BYTES \endlink */ - - uint32 SubscriptionsInUse;/**< \cfetlmmnemonic \SB_SMSIU - \brief Number of current subscriptions */ - uint32 PeakSubscriptionsInUse;/**< \cfetlmmnemonic \SB_SMPSIU - \brief Peak number of subscriptions */ - uint32 MaxSubscriptionsAllowed;/**< \cfetlmmnemonic \SB_SMMSALW - \brief product of \link #CFE_SB_MAX_MSG_IDS \endlink - and \link #CFE_SB_MAX_DEST_PER_PKT \endlink */ - - uint32 SBBuffersInUse;/**< \cfetlmmnemonic \SB_SMSBBIU - \brief Number of SB message buffers currently in use */ - uint32 PeakSBBuffersInUse;/**< \cfetlmmnemonic \SB_SMPSBBIU - \brief Max number of SB message buffers in use */ - - uint32 MaxPipeDepthAllowed;/**< \cfetlmmnemonic \SB_SMMPDALW - \brief cFE Cfg Param \link #CFE_SB_MAX_PIPE_DEPTH \endlink */ - CFE_SB_PipeDepthStats_t PipeDepthStats[CFE_SB_MAX_PIPES];/**< \cfetlmmnemonic \SB_SMPDS - \brief Pipe Depth Statistics #CFE_SB_PipeDepthStats_t*/ -} CFE_SB_StatMsg_Payload_t; - -typedef struct{ - CFE_SB_TlmHdr_t Hdr;/**< \brief cFE Software Bus Telemetry Message Header */ - CFE_SB_StatMsg_Payload_t Payload; -} CFE_SB_StatMsg_t; - - -/** -** \brief SB Routing File Entry -** -** Structure of one element of the routing information in response to #CFE_SB_SEND_ROUTING_INFO_CC -*/ -typedef struct{ - CFE_SB_MsgId_t MsgId;/**< \brief Message Id portion of the route */ - CFE_SB_PipeId_t PipeId;/**< \brief Pipe Id portion of the route */ - uint8 State;/**< \brief Route Enabled or Disabled */ - uint16 MsgCnt;/**< \brief Number of msgs with this MsgId sent to this PipeId */ - char AppName[OS_MAX_API_NAME];/**< \brief Pipe Depth Statistics */ - char PipeName[OS_MAX_API_NAME];/**< \brief Pipe Depth Statistics */ - }CFE_SB_RoutingFileEntry_t; - - -/** -** \brief SB Map File Entry -** -** Structure of one element of the map information in response to #CFE_SB_SEND_MAP_INFO_CC -*/ -typedef struct{ - uint16 MsgId;/**< \brief Message Id which has been subscribed to */ - uint16 Index;/**< \brief Routing table index where pipe destinations are found */ -}CFE_SB_MsgMapFileEntry_t; - - -/** -** \cfesbtlm SB Subscription Report Packet -** -** This structure defines the pkt sent by SB when a subscription or -** a request to unsubscribe is received while subscription reporting is enabled. -** By default subscription reporting is disabled. This feature is intended to be -** used primarily by Software Bus Networking Application (SBN) -** -** \sa #CFE_SB_ENABLE_SUB_REPORTING_CC, #CFE_SB_DISABLE_SUB_REPORTING_CC -*/ -typedef struct { - - uint8 SubType;/**< \brief Subscription or Unsubscription */ - CFE_SB_MsgId_t MsgId;/**< \brief MsgId subscribed or unsubscribe to */ - CFE_SB_Qos_t Qos;/**< \brief Quality of Service, used only for interprocessor communication */ - CFE_SB_PipeId_t Pipe;/**< \brief Destination pipe id to send above msg id */ - -} CFE_SB_SubRprtMsg_Payload_t; - -typedef struct{ - CFE_SB_TlmHdr_t Hdr;/**< \brief cFE Software Bus Telemetry Message Header */ - CFE_SB_SubRprtMsg_Payload_t Payload; -} CFE_SB_SubRprtMsg_t; - - -/** -** \brief SB Previous Subscriptions Entry -** -** This structure defines an entry used in the CFE_SB_PrevSubsPkt_t -** Intended to be used primarily by Software Bus Networking Application (SBN) -** -** Used in structure definition #CFE_SB_PrevSubMsg_t -*/ -typedef struct { - - CFE_SB_MsgId_t MsgId;/**< \brief MsgId portion of the subscription */ - CFE_SB_Qos_t Qos;/**< \brief Qos portion of the subscription */ - CFE_SB_PipeId_t Pipe;/**< \brief PipeId portion of the subscription */ - -}CFE_SB_SubEntries_t; - - -/** -** \cfesbtlm SB Previous Subscriptions Packet -** -** This structure defines the pkt(s) sent by SB that contains a list of all current -** subscriptions. This pkt is generated on cmd and intended to be used primarily by -** the Software Bus Networking Application (SBN). Typically, when the cmd is received -** there are more subscriptions than can fit in one pkt. The complete list of -** subscriptions is sent via a series of segmented pkts. -*/ -typedef struct { - - uint32 PktSegment;/**< \brief Pkt number(starts at 1) in the series */ - uint32 TotalSegments;/**< \brief Total number of pkts needed to complete the request */ - uint32 Entries;/**< \brief Number of entries in the pkt */ - CFE_SB_SubEntries_t Entry[CFE_SB_SUB_ENTRIES_PER_PKT];/**< \brief Array of #CFE_SB_SubEntries_t entries */ -} CFE_SB_PrevSubMsg_Payload_t; - -typedef struct{ - CFE_SB_TlmHdr_t Hdr;/**< \brief cFE Software Bus Telemetry Message Header */ - CFE_SB_PrevSubMsg_Payload_t Payload; -} CFE_SB_PrevSubMsg_t; - - -#endif /* _cfe_sb_msg_ */ -/*****************************************************************************/ diff --git a/src/components/interface/cFE/cfe_tbl.h b/src/components/interface/cFE/cfe_tbl.h deleted file mode 100644 index ad855dc466..0000000000 --- a/src/components/interface/cFE/cfe_tbl.h +++ /dev/null @@ -1,858 +0,0 @@ -/* -** -** $Id: cfe_tbl.h 1.9 2014/08/24 16:59:51GMT-05:00 sstrege Exp $ -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Title: Table Services API Application Library Header File -** -** Purpose: -** Unit specification for Table services library functions and macros. -** -** Design Notes: -** -** References: -** Flight Software Branch C Coding Standard Version 1.0a -** -** Notes: -** -** $Log: cfe_tbl.h $ -** Revision 1.9 2014/08/24 16:59:51GMT-05:00 sstrege -** Updated CFE_TBL_MAX_FULL_NAME_LEN definition to always fall on 4-byte boundary -** Revision 1.8 2010/10/27 16:34:31EDT dkobe -** Added CRC field to Table Buffer data structure -** Revision 1.7 2010/10/27 13:55:07EDT dkobe -** Added TBL Notification API -** Revision 1.6 2010/10/04 15:24:59EDT jmdagost -** Cleaned up copyright symbol. -** Revision 1.5 2009/05/01 16:38:54EDT dkobe -** Updated documentation for CFE_TBL_Register dealing with Validation functions -** Revision 1.4 2009/05/01 14:26:33EDT dkobe -** Modified return code contents to emphasize success vs failure of API calls -** Revision 1.3 2008/07/29 18:32:18EDT dkobe -** Added CFE_TBL_Modified API -** Revision 1.2 2008/07/29 15:55:19EDT dkobe -** Moved CFE_TBL_DumpToBuffer from cfe_tbl_internal.c to cfe_tbl_api.c -** Revision 1.1 2008/04/17 08:05:24EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.13 2007/05/23 11:22:00EDT David Kobe (dlkobe) -** Added doxygen formatting -** Revision 1.12 2007/04/28 14:48:57EDT dlkobe -** Baseline Implementation of Critical Tables -** Revision 1.11 2007/03/28 15:18:17EST rjmcgraw -** Moved file related defines from cfe_tbl.h to cfe_fs.h -** Revision 1.10 2006/11/03 15:41:43EST dlkobe -** Modified cfe_tbl.h so that the CFE_TBL_OPT_USR_DEF_ADDR -** macro includes the CFE_TBL_OPT_DUMP_ONLY option -** -**/ - -#ifndef _cfe_tbl_ -#define _cfe_tbl_ - -/********************* Include Files ************************/ -#include "common_types.h" /* Basic Data Types */ -#include "cfe_time.h" -#include "osconfig.h" - -/******************* Macro Definitions ***********************/ -#define CFE_TBL_OPT_BUFFER_MSK (0x0001) -#define CFE_TBL_OPT_SNGL_BUFFER (0x0000) -#define CFE_TBL_OPT_DBL_BUFFER (0x0001) - -#define CFE_TBL_OPT_LD_DMP_MSK (0x0002) -#define CFE_TBL_OPT_LOAD_DUMP (0x0000) -#define CFE_TBL_OPT_DUMP_ONLY (0x0002) - -#define CFE_TBL_OPT_USR_DEF_MSK (0x0004) -#define CFE_TBL_OPT_NOT_USR_DEF (0x0000) -#define CFE_TBL_OPT_USR_DEF_ADDR (0x0006) /**< \brief NOTE: Automatically includes #CFE_TBL_OPT_DUMP_ONLY option */ - -#define CFE_TBL_OPT_CRITICAL_MSK (0x0008) -#define CFE_TBL_OPT_NOT_CRITICAL (0x0000) -#define CFE_TBL_OPT_CRITICAL (0x0008) - -#define CFE_TBL_OPT_DEFAULT (CFE_TBL_OPT_SNGL_BUFFER | CFE_TBL_OPT_LOAD_DUMP) - -/** Computation for maximum length allowed for a table name.
-** NOTE: "+2" is for NULL Character and "." (i.e. - "AppName.TblName") */ -#define CFE_TBL_MAX_FULL_NAME_LEN_COMP (CFE_TBL_MAX_NAME_LENGTH + OS_MAX_API_NAME + 2) -/* Ensure the table name falls on a 4-byte boundary */ -#define CFE_TBL_MAX_FULL_NAME_LEN (((CFE_TBL_MAX_FULL_NAME_LEN_COMP + 3)/4)*4) - -#define CFE_TBL_BAD_TABLE_HANDLE (CFE_TBL_Handle_t) 0xFFFF - -/****************** Data Type Definitions *********************/ - -typedef int32 (*CFE_TBL_CallbackFuncPtr_t)(void *TblPtr); - -typedef int16 CFE_TBL_Handle_t; - -typedef enum -{ - CFE_TBL_SRC_FILE = 0, /**< When this option is selected, the \c SrcDataPtr - will be interpreted as a pointer to a null - terminated character string. The string should - specify the full path and filename of the file - containing the initial data contents of the table. */ - CFE_TBL_SRC_ADDRESS /**< When this option is selected, the \c SrcDataPtr will - be interpreted as a pointer to a memory location - that is the beginning of the initialization data - for loading the table OR, in the case of a "user defined" - dump only table, the address of the active table itself. - The block of memory is assumed to be of the same size - specified in the #CFE_TBL_Register function Size parameter. */ -} CFE_TBL_SrcEnum_t; - -typedef struct -{ - uint32 Size; /**< \brief Size, in bytes, of Table */ - uint32 NumUsers; /**< \brief Number of Apps with access to the table */ - uint32 FileCreateTimeSecs; /**< \brief File creation time from last file loaded into table */ - uint32 FileCreateTimeSubSecs; /**< \brief File creation time from last file loaded into table */ - uint32 Crc; /**< \brief Most recently calculated CRC by TBL services on table contents */ - CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \brief Time when Table was last updated */ - boolean TableLoadedOnce; /**< \brief Flag indicating whether table has been loaded once or not */ - boolean DumpOnly; /**< \brief Flag indicating Table is NOT to be loaded */ - boolean DblBuffered; /**< \brief Flag indicating Table has a dedicated inactive buffer */ - boolean UserDefAddr; /**< \brief Flag indicating Table address was defined by Owner Application */ - boolean Critical; /**< \brief Flag indicating Table contents are maintained in a CDS */ - char LastFileLoaded[OS_MAX_PATH_LEN]; /**< \brief Filename of last file loaded into table */ -} CFE_TBL_Info_t; - -/*************************** Function Prototypes ******************************/ -/** -** \brief Register a table with cFE to obtain Table Management Services -** -** \par Description -** When an application is created and initialized, it is responsible for creating its table images via -** the TBL API. The application must inform the Table Service of the table name, table size and selection -** of optional table features. -** -** \par Assumptions, External Events, and Notes: -** Note: This function call can block. Therefore, interrupt service routines should NOT create -** their own tables. An application should create any table(s) and provide the handle(s) -** to the interrupt service routine. -** -** \param[in] TblHandlePtr a pointer to a #CFE_TBL_Handle_t type variable that will be assigned the -** table's handle. The table handle is required for other API calls when -** accessing the data contained in the table. -** -** \param[in] Name The application-specific name. This name will be combined with the name of the -** application to produce a processor specific name of the form -** "ApplicationName.TableName". The processor specific name will be used in commands -** for modifying or viewing the contents of the table. -** -** \param[in] Size The size, in bytes, of the table to be created. This is the size that will be -** allocated as a shared memory resource between the Table Management Service and -** the calling application. -** -** \param[in] TblOptionFlags Flag bits indicating selected options for table. A bitwise OR of the following -** option flags: -** \arg #CFE_TBL_OPT_DEFAULT - The default setting for table options is a -** combination of #CFE_TBL_OPT_SNGL_BUFFER and -** #CFE_TBL_OPT_LOAD_DUMP. See below for a -** description of these two options. This option -** is mutually exclusive with the -** #CFE_TBL_OPT_DBL_BUFFER, #CFE_TBL_OPT_DUMP_ONLY -** and #CFE_TBL_OPT_USR_DEF_ADDR options. -** \arg #CFE_TBL_OPT_SNGL_BUFFER - When this option is selected, the table will use -** a shared session table for performing table -** modifications and a memory copy from the session -** table to the "active" table buffer will occur -** when the table is updated. This is the preferred -** option since it will minimize memory usage. -** This option is mutually exclusive with the -** #CFE_TBL_OPT_DBL_BUFFER option -** \arg #CFE_TBL_OPT_DBL_BUFFER - When this option is selected, two instances of -** the table are created. One is considered the -** "active" table and the other the "inactive" table. -** Whenever table modifications occur, they do not -** require the use of a common session table. -** Modifications occur in the "inactive" buffer. -** Then, when it is time to update the table, -** the pointer to the "active" table is changed to -** point to the "inactive" buffer thus making it -** the new "active" buffer. This feature is most -** useful for time critical applications (ie - -** interrupt service routines, etc). This option is -** mutually exclusive with the -** #CFE_TBL_OPT_SNGL_BUFFER and #CFE_TBL_OPT_DEFAULT -** option. -** \arg #CFE_TBL_OPT_LOAD_DUMP - When this option is selected, the Table Service -** is allowed to perform all operations on the -** specified table. This option is mutually -** exclusive with the #CFE_TBL_OPT_DUMP_ONLY option. -** \arg #CFE_TBL_OPT_DUMP_ONLY - When this option is selected, the Table Service -** will not perform table loads to this table. This -** does not prevent, however, a task from writing -** to the table via an address obtained with the -** #CFE_TBL_GetAddress API function. This option is -** mutually exclusive with the #CFE_TBL_OPT_LOAD_DUMP -** and #CFE_TBL_OPT_DEFAULT options. If the Application wishes -** to specify their own block of memory as the Dump Only table, -** they need to also include the #CFE_TBL_OPT_USR_DEF_ADDR option -** explained below. -** \arg #CFE_TBL_OPT_NOT_USR_DEF - When this option is selected, Table Services allocates -** memory for the table and, in the case of a double buffered -** table, it allocates the same amount of memory again for the -** second buffer. This option is mutually exclusive with -** the #CFE_TBL_OPT_USR_DEF_ADDR option. -** \arg #CFE_TBL_OPT_USR_DEF_ADDR- When this option is selected, the Table Service -** will not allocate memory for the table. Table Services -** will require the Application to identify the location of the -** active table buffer via the #CFE_TBL_Load function. This -** option implies the #CFE_TBL_OPT_DUMP_ONLY and the -** #CFE_TBL_OPT_SNGL_BUFFER options and is mutually -** exclusive of the #CFE_TBL_OPT_DBL_BUFFER option. -** \arg #CFE_TBL_OPT_CRITICAL- When this option is selected, the Table Service -** will automatically allocate space in the Critical Data Store (CDS) -** for the table and insure that the contents in the CDS are the same -** as the contents of the currently active buffer for the table. -** This option is mutually exclusive of the #CFE_TBL_OPT_USR_DEF_ADDR -** and #CFE_TBL_OPT_DUMP_ONLY options. It should also be noted that -** the use of this option with double buffered tables will prevent -** the update of the double buffered table from being quick and -** it could be blocked. Therefore, critical tables should not be -** updated by Interrupt Service Routines. -** -** \param[in] TblValidationFuncPtr is a pointer to a function that will be executed in the context of the Table -** Management Service when the contents of a table need to be validated. If set -** to NULL, then the Table Management Service will assume any data is valid. If -** the value is not NULL, it must be a pointer to a function with the following -** prototype:
-** int32 CallbackFunc(void *TblPtr);
-** where
-** TblPtr will be a pointer to the table data that is to be verified. When the -** function returns #CFE_SUCCESS, the data is considered valid and ready for a commit. -** When the function returns a negative value, the data is considered invalid and an -** Event Message will be issued containing the returned value. If the function should -** return a positive number, the table is considered invalid and the return code is -** considered invalid. Validation functions \b must return either #CFE_SUCCESS or a negative -** number (whose value is at the developer's discretion). The validation function -** will be executed in the Application's context so that Event Messages describing the -** validation failure are possible from within the function. -** -** \param[out] *TblHandlePtr Handle used to identify table to cFE when performing Table operations. -** This value is returned at the address specified by TblHandlePtr. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_TBL_INFO_RECOVERED_TBL \retdesc \copydoc CFE_TBL_INFO_RECOVERED_TBL \endcode -** \retcode \retdesc

\endcode -** \retcode #CFE_TBL_ERR_DUPLICATE_DIFF_SIZE \retdesc \copydoc CFE_TBL_ERR_DUPLICATE_DIFF_SIZE \endcode -** \retcode #CFE_TBL_ERR_DUPLICATE_NOT_OWNED \retdesc \copydoc CFE_TBL_ERR_DUPLICATE_NOT_OWNED \endcode -** \retcode #CFE_TBL_ERR_REGISTRY_FULL \retdesc \copydoc CFE_TBL_ERR_REGISTRY_FULL \endcode -** \retcode #CFE_TBL_ERR_HANDLES_FULL \retdesc \copydoc CFE_TBL_ERR_HANDLES_FULL \endcode -** \retcode #CFE_TBL_ERR_INVALID_SIZE \retdesc \copydoc CFE_TBL_ERR_INVALID_SIZE \endcode -** \retcode #CFE_TBL_ERR_INVALID_NAME \retdesc \copydoc CFE_TBL_ERR_INVALID_NAME \endcode -** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode -** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \endreturns -** -** \sa #CFE_TBL_Unregister, #CFE_TBL_Share -**/ -int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, /* Returned Handle */ - const char *Name, /* Application specific name */ - uint32 Size, /* Size, in bytes, of table */ - uint16 TblOptionFlags, /* Tbl Options Settings */ - CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr ); /* Ptr to func that validates tbl */ - -/*****************************************************************************/ -/** -** \brief Obtain handle of table registered by another application -** -** \par Description -** After a table has been created, other applications can gain access -** to that table via the table handle. In order for two or more -** applications to share a table, the applications that do not create -** the table must obtain the handle using this function. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] TblHandlePtr A pointer to a #CFE_TBL_Handle_t type variable -** that will be assigned the table's handle. The -** table handle is required for other API calls -** when accessing the data contained in the table. -** -** \param[in] TblName The processor specific name of the table. It is important to note -** that the processor specific table name is different from the table -** name specified in the #CFE_TBL_Register API call. The processor -** specific table name includes the name of the application that created -** the table. The name would be of the form "ApplicationName.TableName". -** An example of this would be "ACS.TamParams" for a table called "TamParams" -** that was registered by the application called "ACS". -** -** \param[out] *TblHandlePtr Handle used to identify table to cFE when performing Table operations. -** This value is returned at the address specified by TblHandlePtr. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode \retdesc

\endcode -** \retcode #CFE_TBL_ERR_HANDLES_FULL \retdesc \copydoc CFE_TBL_ERR_HANDLES_FULL \endcode -** \retcode #CFE_TBL_ERR_INVALID_NAME \retdesc \copydoc CFE_TBL_ERR_INVALID_NAME \endcode -** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode -** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \endreturns -** -** \sa #CFE_TBL_Unregister, #CFE_TBL_Register -** -******************************************************************************/ -int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, /* Returned Handle */ - const char *TblName ); - -/*****************************************************************************/ -/** -** \brief Unregister a previously registered table and free associated resources -** -** \par Description -** When an application is being removed from the system, it should -** unregister those tables that it created. The application should -** call this function as a part of its cleanup process. The table -** will be removed from memory once all table addresses referencing -** it have been released. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, -** that identifies the Table to be unregistered. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode \retdesc

\endcode -** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode -** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode -** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode -** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \endreturns -** -** \sa #CFE_TBL_Share, #CFE_TBL_Register -** -******************************************************************************/ -int32 CFE_TBL_Unregister ( CFE_TBL_Handle_t TblHandle ); - -/*****************************************************************************/ -/** -** \brief Load a specified table with data from specified source -** -** \par Description -** Once an application has created a table (#CFE_TBL_Register), it must -** provide the values that initialize the contents of that table. The -** application accomplishes this with one of two different TBL API calls. -** This function call initializes the table with values that are held -** in a data structure. -** -** \par Assumptions, External Events, and Notes: -** This function call can block. Therefore, interrupt service routines -** should NOT initialize their own tables. An application should initialize -** any table(s) prior to providing the handle(s) to the interrupt service routine. -** -** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that -** identifies the Table to be loaded. -** -** \param[in] SrcType Flag indicating the nature of the given \c SrcDataPtr below. -** This value can be any one of the following: -** \arg #CFE_TBL_SRC_FILE - \copydoc CFE_TBL_SRC_FILE -** \arg #CFE_TBL_SRC_ADDRESS - \copydoc CFE_TBL_SRC_ADDRESS -** -** \param[in] SrcDataPtr Pointer to either a character string specifying a filename or -** a memory address of a block of binary data to be loaded into a table or, -** if the table was registered with the #CFE_TBL_OPT_USR_DEF_ADDR option, -** the address of the active table buffer. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_TBL_WARN_SHORT_FILE \retdesc \copydoc CFE_TBL_WARN_SHORT_FILE \endcode -** \retcode #CFE_TBL_WARN_PARTIAL_LOAD \retdesc \copydoc CFE_TBL_WARN_PARTIAL_LOAD \endcode -** \retcode \retdesc

\endcode -** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode -** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode -** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode -** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \retcode #CFE_TBL_ERR_DUMP_ONLY \retdesc \copydoc CFE_TBL_ERR_DUMP_ONLY \endcode -** \retcode #CFE_TBL_ERR_ILLEGAL_SRC_TYPE \retdesc \copydoc CFE_TBL_ERR_ILLEGAL_SRC_TYPE \endcode -** \retcode #CFE_TBL_ERR_LOAD_IN_PROGRESS \retdesc \copydoc CFE_TBL_ERR_LOAD_IN_PROGRESS \endcode -** \retcode #CFE_TBL_ERR_NO_BUFFER_AVAIL \retdesc \copydoc CFE_TBL_ERR_NO_BUFFER_AVAIL \endcode -** \retcode #CFE_TBL_ERR_FILE_NOT_FOUND \retdesc \copydoc CFE_TBL_ERR_FILE_NOT_FOUND \endcode -** \retcode #CFE_TBL_ERR_FILE_TOO_LARGE \retdesc \copydoc CFE_TBL_ERR_FILE_TOO_LARGE \endcode -** \retcode #CFE_TBL_ERR_BAD_CONTENT_ID \retdesc \copydoc CFE_TBL_ERR_BAD_CONTENT_ID \endcode -** \retcode #CFE_TBL_ERR_PARTIAL_LOAD \retdesc \copydoc CFE_TBL_ERR_PARTIAL_LOAD \endcode -** \endreturns -** -** \sa #CFE_TBL_Update, #CFE_TBL_Validate, #CFE_TBL_Manage -** -******************************************************************************/ -int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, - CFE_TBL_SrcEnum_t SrcType, - const void *SrcDataPtr ); - -/*****************************************************************************/ -/** -** \brief Update contents of a specified table, if an update is pending -** -** \par Description -** An application is \b required to perform a periodic check for an update -** for all the tables that it creates. Typically, the application that -** created the table would call this function at the start or conclusion -** of any routine processing cycle or at regular intervals. To determine -** whether an update is pending prior to making this call, the Application -** can use the #CFE_TBL_GetStatus API first. If a table update is pending, -** it will take place during this function call. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that -** identifies the Table to be updated. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_TBL_INFO_NO_UPDATE_PENDING \retdesc \copydoc CFE_TBL_INFO_NO_UPDATE_PENDING \endcode -** \retcode \retdesc

\endcode -** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode -** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode -** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode -** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \endreturns -** -** \sa #CFE_TBL_Load, #CFE_TBL_Validate, #CFE_TBL_Manage -** -******************************************************************************/ -int32 CFE_TBL_Update( CFE_TBL_Handle_t TblHandle ); - -/*****************************************************************************/ -/** -** \brief Obtain the current address of the contents of the specified table -** -** \par Description -** When a table has been created and initialized, it is available to -** any application that can identify it with its unique handle. In -** order to view the data contained in the table, an application must -** call this function or #CFE_TBL_GetAddresses. -** -** \par Assumptions, External Events, and Notes: -** -# This call can be a blocking call when the table is not double buffered -** and is shared with another application of lower priority that just happens -** to be in the middle of a table update of the specific table. If this occurs, -** the application performing the table update will automatically have its -** priority elevated in order to release the resource as soon as possible. -** -# An application must always release the returned table address using the -** #CFE_TBL_ReleaseAddress or #CFE_TBL_ReleaseAddresses function prior to -** either a #CFE_TBL_Update call or any blocking call (e.g. - pending on software -** bus message, etc). Table updates cannot occur while table addresses have not -** been released. -** -** \param[in] TblPtr The address of a pointer that will be loaded with the address of -** the first byte of the table. This pointer can then be typecast -** by the calling application to the appropriate table data structure. -** -** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that -** identifies the Table whose address is to be returned. -** -** \param[out] *TblPtr Address of the first byte of data associated with the specified table. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_TBL_INFO_UPDATED \retdesc \copydoc CFE_TBL_INFO_UPDATED \endcode -** \retcode \retdesc

\endcode -** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode -** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode -** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode -** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \retcode #CFE_TBL_ERR_UNREGISTERED \retdesc \copydoc CFE_TBL_ERR_UNREGISTERED \endcode -** \retcode #CFE_TBL_ERR_NEVER_LOADED \retdesc \copydoc CFE_TBL_ERR_NEVER_LOADED \endcode -** \endreturns -** -** \sa #CFE_TBL_ReleaseAddress, #CFE_TBL_GetAddresses, #CFE_TBL_ReleaseAddresses -** -******************************************************************************/ -int32 CFE_TBL_GetAddress( void **TblPtr, - CFE_TBL_Handle_t TblHandle ); - -/*****************************************************************************/ -/** -** \brief Release previously obtained pointer to the contents of the specified table -** -** \par Description -** Each application is \b required to release a table address obtained through -** the #CFE_TBL_GetAddress function. -** -** \par Assumptions, External Events, and Notes: -** An application must always release the returned table address using the -** #CFE_TBL_ReleaseAddress function prior to either a #CFE_TBL_Update call -** or any blocking call (e.g. - pending on software bus message, etc). -** Table updates cannot occur while table addresses have not been released. -** -** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that -** identifies the Table whose address is to be released. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_TBL_INFO_UPDATED \retdesc \copydoc CFE_TBL_INFO_UPDATED \endcode -** \retcode \retdesc

\endcode -** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode -** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode -** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode -** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \retcode #CFE_TBL_ERR_NEVER_LOADED \retdesc \copydoc CFE_TBL_ERR_NEVER_LOADED \endcode -** \endreturns -** -** \sa #CFE_TBL_GetAddress, #CFE_TBL_GetAddresses, #CFE_TBL_ReleaseAddresses -** -******************************************************************************/ -int32 CFE_TBL_ReleaseAddress( CFE_TBL_Handle_t TblHandle ); - -/*****************************************************************************/ -/** -** \brief Obtain the current addresses of an array of specified tables -** -** \par Description -** When a table has been created and initialized, it is available to -** any application that can identify it with its unique handle. In -** order to view the data contained in the table, an application must -** call this function or #CFE_TBL_GetAddresses. -** -** \par Assumptions, External Events, and Notes: -** -# This call can be a blocking call when the table is not double buffered -** and is shared with another application of lower priority that just happens -** to be in the middle of a table update of the specific table. If this occurs, -** the application performing the table update will automatically have its -** priority elevated in order to release the resource as soon as possible. -** -# An application must always release the returned table address using the -** #CFE_TBL_ReleaseAddress or #CFE_TBL_ReleaseAddresses function prior to -** either a #CFE_TBL_Update call or any blocking call (e.g. - pending on software -** bus message, etc). Table updates cannot occur while table addresses have not -** been released. -** -** \param[in] TblPtrs Array of Pointers to variables that calling Application -** wishes to hold the start addresses of the Tables. -** -** \param[in] NumTables Size of TblPtrs and TblHandles arrays. -** -** \param[in] TblHandles Array of Table Handles, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, -** of those tables whose start addresses are to be obtained. -** -** \param[out] *TblPtrs Array of addresses of the first byte of data associated with the -** specified tables. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_TBL_INFO_UPDATED \retdesc \copydoc CFE_TBL_INFO_UPDATED \endcode -** \retcode \retdesc

\endcode -** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode -** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode -** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode -** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \retcode #CFE_TBL_ERR_UNREGISTERED \retdesc \copydoc CFE_TBL_ERR_UNREGISTERED \endcode -** \retcode #CFE_TBL_ERR_NEVER_LOADED \retdesc \copydoc CFE_TBL_ERR_NEVER_LOADED \endcode -** \endreturns -** -** \sa #CFE_TBL_GetAddress, #CFE_TBL_ReleaseAddress, #CFE_TBL_ReleaseAddresses -** -******************************************************************************/ -int32 CFE_TBL_GetAddresses( void **TblPtrs[], - uint16 NumTables, - const CFE_TBL_Handle_t TblHandles[] ); - -/*****************************************************************************/ -/** -** \brief Release the addresses of an array of specified tables -** -** \par Description -** Each application is \b required to release a table address obtained through -** the #CFE_TBL_GetAddress function. -** -** \par Assumptions, External Events, and Notes: -** An application must always release the returned table address using the -** #CFE_TBL_ReleaseAddress function prior to either a #CFE_TBL_Update call -** or any blocking call (e.g. - pending on software bus message, etc). -** Table updates cannot occur while table addresses have not been released. -** -** \param[in] NumTables Size of TblHandles array. -** -** \param[in] TblHandles Array of Table Handles, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, -** of those tables whose start addresses are to be released. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_TBL_INFO_UPDATED \retdesc \copydoc CFE_TBL_INFO_UPDATED \endcode -** \retcode \retdesc

\endcode -** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode -** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode -** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode -** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \retcode #CFE_TBL_ERR_NEVER_LOADED \retdesc \copydoc CFE_TBL_ERR_NEVER_LOADED \endcode -** \endreturns -** -** \sa #CFE_TBL_GetAddress, #CFE_TBL_ReleaseAddress, #CFE_TBL_GetAddresses -** -******************************************************************************/ -int32 CFE_TBL_ReleaseAddresses( uint16 NumTables, - const CFE_TBL_Handle_t TblHandles[] ); - -/*****************************************************************************/ -/** -** \brief Perform steps to validate the contents of a table image. -** -** \par Description -** An application is \b required to perform a periodic check for an update -** or a validation request for all the tables that it creates. Typically, -** the application that created the table would call this function at the -** start or conclusion of any routine processing cycle. To determine whether -** a validation request is pending prior to making this call, the Application -** can use the #CFE_TBL_GetStatus API first. If a table validation is pending, -** the Application would call this function to perform the necessary actions. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that -** identifies the Table to be managed. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_TBL_INFO_NO_VALIDATION_PENDING \retdesc \copydoc CFE_TBL_INFO_NO_VALIDATION_PENDING \endcode -** \retcode \retdesc

\endcode -** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode -** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode -** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode -** \endreturns -** -** \sa #CFE_TBL_Update, #CFE_TBL_Manage, #CFE_TBL_Load -** -******************************************************************************/ -int32 CFE_TBL_Validate( CFE_TBL_Handle_t TblHandle ); - -/*****************************************************************************/ -/** -** \brief Perform standard operations to maintain a table. -** -** \par Description -** An application is \b required to perform a periodic check for an update -** or a validation request for all the tables that it creates. Typically, -** the application that created the table would call this function at the -** start or conclusion of any routine processing cycle. If a table update -** or validation request is pending, this function would perform either or -** both before returning. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that -** identifies the Table to be managed. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_TBL_INFO_UPDATED \retdesc \copydoc CFE_TBL_INFO_UPDATED \endcode -** \retcode \retdesc

\endcode -** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode -** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode -** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode -** \endreturns -** -** \sa #CFE_TBL_Update, #CFE_TBL_Validate, #CFE_TBL_Load, #CFE_TBL_DumpToBuffer -** -******************************************************************************/ -int32 CFE_TBL_Manage( CFE_TBL_Handle_t TblHandle ); - -/*****************************************************************************/ -/** -** \brief Obtain current status of pending actions for a table. -** -** \par Description -** An application is \b required to perform a periodic check for an update -** or a validation request for all the tables that it creates. Typically, -** the application that created the table would call this function at the -** start or conclusion of any routine processing cycle. If a table update -** or validation request is pending, the Application should follow up with -** a call to #CFE_TBL_Update or #CFE_TBL_Validate respectively. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that -** identifies the Table to be managed. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_TBL_INFO_UPDATE_PENDING \retdesc \copydoc CFE_TBL_INFO_UPDATE_PENDING \endcode -** \retcode #CFE_TBL_INFO_VALIDATION_PENDING \retdesc \copydoc CFE_TBL_INFO_VALIDATION_PENDING \endcode -** \retcode #CFE_TBL_INFO_DUMP_PENDING \retdesc \copydoc CFE_TBL_INFO_DUMP_PENDING \endcode -** \retcode \retdesc

\endcode -** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode -** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode -** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode -** \endreturns -** -** \sa #CFE_TBL_Manage, #CFE_TBL_Update, #CFE_TBL_Validate, #CFE_TBL_GetInfo -** -******************************************************************************/ -int32 CFE_TBL_GetStatus( CFE_TBL_Handle_t TblHandle ); - - -/*****************************************************************************/ -/** -** \brief Obtain characteristics/information of/about a specified table. -** -** \par Description -** This API provides the registry information associated with the specified -** table. The function fills the given data structure with the data found -** in the Table Registry. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] TblInfoPtr A pointer to a CFE_TBL_Info_t data structure that is to be populated -** with table characteristics and information. -** -** \param[in] TblName The processor specific name of the table. It is important to note -** that the processor specific table name is different from the table -** name specified in the #CFE_TBL_Register API call. The processor -** specific table name includes the name of the application that created -** the table. The name would be of the form "ApplicationName.TableName". -** An example of this would be "ACS.TamParams" for a table called "TamParams" -** that was registered by the application called "ACS". -** -** \param[out] *TblInfoPtr Description of the tables characteristics and registry information stored in -** the #CFE_TBL_Info_t data structure format. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode \retdesc

\endcode -** \retcode #CFE_TBL_ERR_INVALID_NAME \retdesc \copydoc CFE_TBL_ERR_INVALID_NAME \endcode -** \endreturns -** -** \sa #CFE_TBL_GetStatus -** -******************************************************************************/ -int32 CFE_TBL_GetInfo( CFE_TBL_Info_t *TblInfoPtr, const char *TblName ); - -/*****************************************************************************/ -/** -** \brief Copies the contents of a Dump Only Table to a shared buffer -** -** \par Description -** Copies contents of a Dump Only table to a shared buffer so that it -** can be written to a file by the Table Services routine. This function -** is called by the Application that owns the table in response to a #CFE_TBL_INFO_DUMP_PENDING -** status obtained via #CFE_TBL_GetStatus. -** -** \par Assumptions, External Events, and Notes: -** -# If the table does not have a dump pending status, nothing will occur (no error, no dump) -** -# Applications may wish to use this function in lieu of #CFE_TBL_Manage for their Dump Only tables -** -** \param[in] TblHandle Handle of Table to be dumped. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode \retdesc

\endcode -** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode -** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode -** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode -** \endreturns -** -** \sa #CFE_TBL_Manage -** -******************************************************************************/ -int32 CFE_TBL_DumpToBuffer( CFE_TBL_Handle_t TblHandle ); - -/*****************************************************************************/ -/** -** \brief Notify cFE Table Services that table contents have been modified by the Application -** -** \par Description -** This API notifies Table Services that the contents of the specified table has been -** modified by the Application. This notification is important when a table has been -** registered as "Critical" because Table Services can then update the contents of the -** table kept in the Critical Data Store. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] TblHandle Handle of Table that was modified. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode \retdesc

\endcode -** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode -** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode -** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode -** \endreturns -** -** \sa #CFE_TBL_Manage -** -******************************************************************************/ -int32 CFE_TBL_Modified( CFE_TBL_Handle_t TblHandle ); - - -/*****************************************************************************/ -/** -** \brief Instruct cFE Table Services to notify Application via message when table requires management -** -** \par Description -** This API instructs Table Services to send a message to the calling Application -** whenever the specified table requires management by the application. This feature -** allows applications to avoid polling table services via the #CFE_TBL_Manage call -** to determine whether a table requires updates, validation, etc. This API should -** be called following the #CFE_TBL_Register API whenever the owning application requires -** this feature. -** -** \par Assumptions, External Events, and Notes: -** - Only the application that owns the table is allowed to register a notification message -** -** \param[in] TblHandle Handle of Table with which the message should be associated. -** -** \param[in] MsgId Message ID to be used in notification message sent by Table Services. -** -** \param[in] CommandCode Command Code value to be placed in secondary header of message -** sent by Table Services. -** -** \param[in] Parameter Application defined value to be passed as a parameter in the -** message sent by Table Services. Suggested use includes an application's -** table index that allows the same MsgId and Command Code to be used for -** all table management notifications. -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode \retdesc

\endcode -** \retcode #CFE_ES_ERR_APPNAME \retdesc \copydoc CFE_ES_ERR_APPNAME \endcode -** \retcode #CFE_ES_ERR_BUFFER \retdesc \copydoc CFE_ES_ERR_BUFFER \endcode -** \retcode #CFE_TBL_ERR_BAD_APP_ID \retdesc \copydoc CFE_TBL_ERR_BAD_APP_ID \endcode -** \retcode #CFE_TBL_ERR_NO_ACCESS \retdesc \copydoc CFE_TBL_ERR_NO_ACCESS \endcode -** \retcode #CFE_TBL_ERR_INVALID_HANDLE \retdesc \copydoc CFE_TBL_ERR_INVALID_HANDLE \endcode -** \endreturns -** -** \sa #CFE_TBL_Register -** -******************************************************************************/ -int32 CFE_TBL_NotifyByMessage(CFE_TBL_Handle_t TblHandle, uint32 MsgId, uint16 CommandCode, uint32 Parameter); - -#endif /* _cfe_tbl_ */ diff --git a/src/components/interface/cFE/cfe_tbl_events.h b/src/components/interface/cFE/cfe_tbl_events.h deleted file mode 100644 index 661d1bc7f4..0000000000 --- a/src/components/interface/cFE/cfe_tbl_events.h +++ /dev/null @@ -1,1082 +0,0 @@ -/* -** -** $Id: cfe_tbl_events.h 1.9 2014/08/19 13:38:15GMT-05:00 sstrege Exp $ -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Title: Table Services API Event ID Header File -** -** Purpose: -** Identifies event codes for event messages issued by Table Services. -** -** Design Notes: -** -** References: -** Flight Software Branch C Coding Standard Version 1.0a -** -** Notes: -** -** $Log: cfe_tbl_events.h $ -** Revision 1.9 2014/08/19 13:38:15GMT-05:00 sstrege -** Fixed doxygen warning -** Revision 1.8 2011/12/28 14:00:18EST lwalling -** Add definition for CFE_TBL_SPACECRAFT_ID_ERR_EID and CFE_TBL_PROCESSOR_ID_ERR_EID -** Revision 1.7 2011/11/14 17:58:05EST lwalling -** Event EID mentioned in previous log entry should have been CFE_TBL_LOAD_EXCEEDS_SIZE_ERR_EID -** Revision 1.6 2011/11/14 17:42:30EST lwalling -** Modified event text and argument list for CFE_TBL_FILE_INCOMPLETE_ERR_EID -** Revision 1.5 2010/10/27 13:53:54EDT dkobe -** Added error event for Notification Message send failure -** Revision 1.4 2010/10/25 15:01:12EDT jmdagost -** Corrected bad apostrophe in prologue. -** Revision 1.3 2010/10/04 15:24:56EDT jmdagost -** Cleaned up copyright symbol. -** Revision 1.2 2009/05/01 12:41:44EDT dkobe -** Corrected a few doxygen comments -** Revision 1.1 2008/04/17 08:05:24EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.28 2007/07/11 11:51:44EDT David Kobe (dlkobe) -** Corrected erroneously assigned Event ID for CFE_TBL_ASSUMED_VALID_INF_EID -** Revision 1.27 2007/07/07 09:22:29EDT dlkobe -** Added event (CFE_TBL_LOAD_PENDING_ERR_EID) for attempt to load pending load table -** Revision 1.26 2007/07/07 07:53:35EDT dlkobe -** Added CFE_TBL_ASSUMED_VALID_INF_EID event message -** Revision 1.25 2007/06/02 10:10:12EDT dlkobe -** Added doxygen comments for User's Guides -** Revision 1.24 2007/05/25 16:24:50EDT dlkobe -** Continued updating doxygen comments -** Revision 1.23 2007/05/23 11:21:58EDT dlkobe -** Added doxygen formatting -** Revision 1.22 2007/05/15 11:18:08EDT rjmcgraw -** DCR78:11 Removed event CFE_TBL_EXIT_ERR_EID -** Revision 1.21 2007/05/04 15:54:39EDT dlkobe -** Added event messages associated with deleting a critical table's CDS -** Revision 1.20 2007/03/16 14:59:41EST dlkobe -** Using file version 1.14 and applying all changes since to avoid corrupted versions. -** -** -**/ - -#ifndef _cfe_tbl_events_ -#define _cfe_tbl_events_ - -/******************* Macro Definitions ***********************/ -/* -** Event message ID's -*/ - -/** \name Informational Event Message IDs */ -/** \{ */ -/** \brief 'Task Initialized' -** \event 'Task Initialized' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always automatically issued when the Table Services -** Task completes its Initialization. -**/ -#define CFE_TBL_INIT_INF_EID 1 - -/** \name Command Response Informational Event Message IDs */ -/** \{ */ - -/** \brief 'No-op command' -** \event 'No-op command' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always automatically issued in response -** to a cFE Table Services \link #CFE_TBL_NOOP_CC NO-OP command \endlink -**/ -#define CFE_TBL_NOOP_INF_EID 10 - -/** \brief 'Reset Counters command' -** \event 'Reset Counters command' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always automatically issued in response -** to a cFE Table Services \link #CFE_TBL_RESET_CC Reset Counters command \endlink -**/ -#define CFE_TBL_RESET_INF_EID 11 - -/** \brief 'Successful load of '\%s' into '\%s' working buffer' -** \event 'Successful load of '\%s' into '\%s' working buffer' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always generated after a successful execution of -** a cFE Table Services \link #CFE_TBL_LOAD_CC Load Table command \endlink -**/ -#define CFE_TBL_FILE_LOADED_INF_EID 12 - -/** \brief 'Successfully overwrote '\%s' with Table '\%s'' -** \event 'Successfully overwrote '\%s' with Table '\%s'' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always generated after a successful execution of -** a cFE Table Services \link #CFE_TBL_DUMP_CC Dump Table command \endlink where -** the command specified target filename was the same as a file already present -** in the onboard filesystem. If the specified file did not exist, the event -** message would have been #CFE_TBL_WRITE_DUMP_INF_EID. -**/ -#define CFE_TBL_OVERWRITE_DUMP_INF_EID 13 - -/** \brief 'Successfully dumped Table '\%s' to '\%s'' -** \event 'Successfully dumped Table '\%s' to '\%s'' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always generated after a successful execution of -** a cFE Table Services \link #CFE_TBL_DUMP_CC Dump Table command \endlink where -** the command specified target filename was a currently non-existent file. If -** the file did already exist, the event message would have been -** #CFE_TBL_OVERWRITE_DUMP_INF_EID. -**/ -#define CFE_TBL_WRITE_DUMP_INF_EID 14 - -/** \brief 'Successfully overwrote '\%s' with Table Registry' -** \event 'Successfully overwrote '\%s' with Table Registry' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is always generated after a successful execution of -** a cFE Table Services \link #CFE_TBL_DUMP_REG_CC Dump Table Registry command \endlink where -** the command specified target filename was the same as a file already present -** in the onboard filesystem. If the specified file did not exist, the event -** message would have been #CFE_TBL_WRITE_REG_DUMP_INF_EID. -**/ -#define CFE_TBL_OVERWRITE_REG_DUMP_INF_EID 15 - -/** \brief 'Tbl Services issued validation request for '\%s'' -** \event 'Tbl Services issued validation request for '\%s'' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon successful execution of -** a cFE Table Services \link #CFE_TBL_VALIDATE_CC Validate Table command \endlink. -** It should be noted, however, that this Event Message does NOT indicate completion of -** the Table Validation. It is ONLY indicating that the appropriate flag has been -** set to NOTIFY the table's owning Application that a Validation has been requested. -** Completion of the Validation is indicated by either the #CFE_TBL_VALIDATION_INF_EID or -** #CFE_TBL_VALIDATION_ERR_EID event messages. -**/ -#define CFE_TBL_VAL_REQ_MADE_INF_EID 16 - -/** \brief 'Tbl Services notifying App that '\%s' has a load pending' -** \event 'Tbl Services notifying App that '\%s' has a load pending' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon successful execution of -** a cFE Table Services \link #CFE_TBL_ACTIVATE_CC Activate Table command \endlink. -** It should be noted, however, that this Event Message does NOT indicate completion of -** the Table Activation. It is ONLY indicating that the appropriate flag has been -** set to NOTIFY the table's owning Application that an Update has been requested. -** Completion of the Update is indicated by either the #CFE_TBL_UPDATE_SUCCESS_INF_EID or -** #CFE_TBL_UPDATE_ERR_EID event messages. -**/ -#define CFE_TBL_LOAD_PEND_REQ_INF_EID 17 - -/** \brief 'Table Registry entry for '\%s' will be telemetered' -** \event 'Table Registry entry for '\%s' will be telemetered' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is generated upon successful execution of -** a cFE Table Services \link #CFE_TBL_TLM_REG_CC Telemeter Table Registry Entry command \endlink. -** Subsequent Table Services Housekeeping Telemetry should contain the desired Table Registry Entry data. -**/ -#define CFE_TBL_TLM_REG_CMD_INF_EID 18 - -/** \brief 'Table Load Aborted for '\%s'' -** \event 'Table Load Aborted for '\%s'' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated upon successful execution of -** a cFE Table Services \link #CFE_TBL_ABORT_LOAD_CC Abort Table Load command \endlink. -**/ -#define CFE_TBL_LOAD_ABORT_INF_EID 21 - -/** \brief 'Successfully dumped Table Registry to '\%s':Size=\%d,Entries=\%d' -** \event 'Successfully dumped Table Registry to '\%s':Size=\%d,Entries=\%d' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is always generated after a successful execution of -** a cFE Table Services \link #CFE_TBL_DUMP_REG_CC Dump Table Registry command \endlink where -** the command specified target filename was a currently non-existent file. If -** the file did already exist, the event message would have been -** #CFE_TBL_OVERWRITE_REG_DUMP_INF_EID. -**/ -#define CFE_TBL_WRITE_REG_DUMP_INF_EID 22 - -/** \brief 'Tbl Services assumes '\%s' is valid. No Validation Function has been registered' -** \event 'Tbl Services assumes '\%s' is valid. No Validation Function has been registered' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated when Table Services has received a Validation Command -** for a table that never specified a Validation Function when it was registered via the -** #CFE_TBL_Register API. -**/ -#define CFE_TBL_ASSUMED_VALID_INF_EID 23 -/** \} */ - - -/** \name Command Error Event Message IDs */ -/** \{ */ -/** \brief 'Invalid message ID -- ID = 0x\%X' -** \event 'Invalid message ID -- ID = 0x\%X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a message has arrived on -** the cFE Table Services Application's Message Pipe that has a -** Message ID that is neither #CFE_TBL_SEND_HK_MID or #CFE_TBL_CMD_MID. -** Most likely, the cFE Software Bus routing table has become corrupt -** and is sending messages targeted for other Applications to the cFE -** Table Services Application. -** -** The \c ID field in the event message identifies -** the message ID (in hex) that was found in the message. -**/ -#define CFE_TBL_MID_ERR_EID 50 - -/** \brief 'Invalid command code -- ID = 0x\%X, CC = \%d' -** \event 'Invalid command code -- ID = 0x\%X, CC = \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a message with the #CFE_TBL_CMD_MID -** message ID has arrived but whose Command Code is not one of the command -** codes specified in \link #CFE_TBL_NOOP_CC cfe_tbl_msg.h \endlink. This -** problem is most likely to occur when: -** -# A Message ID meant for another Application became corrupted and was -** set equal to #CFE_TBL_CMD_MID. -** -# The Command Code field in the Message became corrupted. -** -# The command database at the ground station has been corrupted. -** -** The \c ID field in the event message specifies the Message ID (in hex) and the -** \c CC field specifies the Command Code (in decimal) found in the message. -**/ -#define CFE_TBL_CC1_ERR_EID 51 - -/** \brief 'Invalid cmd pkt -- ID = 0x\%X, CC = \%d, Len = \%d' -** \event 'Invalid cmd pkt -- ID = 0x\%X, CC = \%d, Len = \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a message with the #CFE_TBL_CMD_MID -** message ID has arrived but whose packet length does not match the expected -** length for the specified command code. -** -** The \c ID field in the event message specifies the Message ID (in hex), the \c CC field -** specifies the Command Code (in decimal) and \c Len specifies the message Length (in decimal) -** found in the message. -**/ -#define CFE_TBL_LEN_ERR_EID 52 - -/** \brief 'Unable to open file '\%s' for table load, Status = 0x\%08X' -** \event 'Unable to open file '\%s' for table load, Status = 0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of a -** \link #CFE_TBL_LOAD_CC Load Table command \endlink when -** the specified file containing the table image to be loaded -** cannot be opened. Possible causes for this are: -** -** -# The filename was misspelled -** -# The path to the file was incorrect -** -# The length of the filename and/or path exceeds the -** allowable length (see #OS_MAX_PATH_LEN and #OS_MAX_FILE_NAME, respectively) -** -** The \c Status field in the event message indicates the error code returned by the #OS_open -** API. -**/ -#define CFE_TBL_FILE_ACCESS_ERR_EID 53 - -/** \brief 'Unable to read std header for '\%s', Status = 0x\%08X' -** \event 'Unable to read std header for '\%s', Status = 0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a read failure occurs during the reading of the -** \link #CFE_FS_Header_t cFE Standard File Header \endlink of a table image file specified -** either by an Application calling the #CFE_TBL_Load API or in response to a command to -** Table Services requesting a table image file be loaded into an inactive buffer. -** -** The \c Status field of the event message contains the error code returned by #CFE_FS_ReadHeader. -**/ -#define CFE_TBL_FILE_STD_HDR_ERR_EID 54 - -/** \brief 'Unable to read tbl header for '\%s', Status = 0x\%08X' -** \event 'Unable to read tbl header for '\%s', Status = 0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a read failure occurs during the reading of the -** \link #CFE_TBL_File_Hdr_t cFE Table File Secondary Header \endlink of a table image file specified -** either by an Application calling the #CFE_TBL_Load API or in response to a command to -** Table Services requesting a table image file be loaded into an inactive buffer. -** -** The \c Status field of the event message contains the error code returned by #OS_read. -**/ -#define CFE_TBL_FILE_TBL_HDR_ERR_EID 55 - -/** \brief 'Unable to send Hk Packet (Status=0x\%08X)' -** \event 'Unable to send Hk Packet (Status=0x\%08X)' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when failure occurs while attempting to send the -** Housekeeping Message over the Software Bus. -** -** The \c Status field of the event message contains the error code returned by #CFE_SB_SendMsg. -**/ -#define CFE_TBL_FAIL_HK_SEND_ERR_EID 56 - -/** \brief 'Unable to locate '\%s' in Table Registry' -** \event 'Unable to locate '\%s' in Table Registry' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a command that specifies a table name -** has a table name that is not found in the Table Registry. Most likely causes -** for this are: -** -# Table name was misspelled in the command. -** -# The Application that Registered the Table has either failed to run or -** has been terminated thus removing the Table from the Registry. -** -# The Table Registry has become corrupted. -**/ -#define CFE_TBL_NO_SUCH_TABLE_ERR_EID 57 - -/** \brief 'File '\%s' is not a cFE file type, ContentType = 0x\%08X' -** \event 'File '\%s' is not a cFE file type, ContentType = 0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when either an Application calls the #CFE_TBL_Load API -** or a Table Load command has been received and the specified file has a \link #CFE_FS_Header_t -** cFE Standard File Header \endlink whose \link #CFE_FS_Header_t::ContentType Content Type \endlink -** is not equal to the expected #CFE_FS_FILE_CONTENT_ID. Most likely causes for this are: -** -# The specified file is not a cFE compatible file. -** -# The specified file has been created with bad "endianess" (headers should always conform to -** a big endian format). -** -# The specified file has become corrupted. -** -** The \c ContentType field specified in the event message contains the content type that was found -** in the specified file. -**/ -#define CFE_TBL_FILE_TYPE_ERR_EID 58 - -/** \brief 'File subtype for '\%s' is wrong. Subtype = 0x\%08X' -** \event 'File subtype for '\%s' is wrong. Subtype = 0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when either an Application calls the #CFE_TBL_Load API -** or a Table Load command has been received and the specified file has a \link #CFE_FS_Header_t -** cFE Standard File Header \endlink whose \link #CFE_FS_Header_t::SubType Sub Type \endlink -** is not equal to the expected #CFE_FS_TBL_IMG_SUBTYPE. Most likely causes for this are: -** -# The specified file is not a cFE table image file. -** -# The specified file has been created with bad "endianess" (headers should always conform to -** a big endian format). -** -# The specified file has become corrupted. -** -** The \c SubType field specified in the event message contains the sub type that was found -** in the specified file. -**/ -#define CFE_TBL_FILE_SUBTYPE_ERR_EID 59 - -/** \brief 'No working buffers available for table '\%s'' -** \event 'No working buffers available for table '\%s'' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when either a Table Load Command for a Single Buffered Table -** or a Table Dump Command for a Dump Only Table has been sent AND there are no Shared Buffers -** available to hold either the load image or the dump image. To free a Shared Buffer, either -** a previously loaded table image must be activated or aborted OR the operator has to wait for -** previously dumped Dump Only tables have had a chance to be written to a file (which occurs -** whenever the cFE Table Services receives a Housekeeping Request). -**/ -#define CFE_TBL_NO_WORK_BUFFERS_ERR_EID 60 - -/** \brief 'Internal Error (Status=0x\%08X)' -** \event 'Internal Error (Status=0x\%08X)' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Load command was issued and the cFE Table Services -** is unable to allocate a working table buffer for an unexpected reason. -** -** The \c Status field provides the return status from the function that was to provide a working buffer. -**/ -#define CFE_TBL_INTERNAL_ERROR_ERR_EID 61 - -/** \brief 'Error creating dump file '\%s', Status=0x\%08X' -** \event 'Error creating dump file '\%s', Status=0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Dump or Table Registry Dump command was -** received and the cFE Table Services is unable to create the specified file. -** -** The \c Status field provides the return status from the #OS_creat function call. -**/ -#define CFE_TBL_CREATING_DUMP_FILE_ERR_EID 62 - -/** \brief 'Error writing cFE File Header to '\%s', Status=0x\%08X' -** \event 'Error writing cFE File Header to '\%s', Status=0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Dump or Table Registry Dump command was -** received and the cFE Table Services is unable to write the standard cFE File Header -** to the specified file. -** -** The \c Status field provides the return status from the #CFE_FS_WriteHeader function call. -**/ -#define CFE_TBL_WRITE_CFE_HDR_ERR_EID 63 - -/** \brief 'Error writing Tbl image File Header to '\%s', Status=0x\%08X' -** \event 'Error writing Tbl image File Header to '\%s', Status=0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Dump command was received and the -** cFE Table Services is unable to write the standard cFE Table Image Header to the specified file. -** -** The \c Status field provides the return status from the #OS_write function call. -**/ -#define CFE_TBL_WRITE_TBL_HDR_ERR_EID 64 - -/** \brief 'Error writing Tbl image to '\%s', Status=0x\%08X' -** \event 'Error writing Tbl image to '\%s', Status=0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Dump command was received and the -** cFE Table Services is unable to write the contents of the specified Table image to -** the specified file. -** -** The \c Status field provides the return status from the #OS_write function call. -**/ -#define CFE_TBL_WRITE_TBL_IMG_ERR_EID 65 - -/** \brief 'No Inactive Buffer for Table '\%s' present' -** \event 'No Inactive Buffer for Table '\%s' present' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Dump or a Table Validate command for an -** Inactive Table Buffer was received and there isn't an Inactive Table Buffer associated -** with the specified Table. -**/ -#define CFE_TBL_NO_INACTIVE_BUFFER_ERR_EID 66 - -/** \brief 'Too many Table Validations have been requested' -** \event 'Too many Table Validations have been requested' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Validate command was received and there are -** no more free Validation Result Blocks available. The number of simultaneous validations that -** can be pending is specified by the configuration parameter #CFE_TBL_MAX_NUM_VALIDATIONS -** which is found in the cfe_platform_cfg.h file. -** -** Validation Commands lock one of the Validation Result Blocks upon receipt of the validation -** command until the result of the Validation, performed by the table's owning Application, has -** been reported in a Table Services Housekeeping Request Message. -**/ -#define CFE_TBL_TOO_MANY_VALIDATIONS_ERR_EID 67 - -/** \brief 'Error writing Registry to '\%s', Status=0x\%08X' -** \event 'Error writing Registry to '\%s', Status=0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Registry Dump command was received and the -** cFE Table Services is unable to write the entire contents of the Table Registry to -** the specified file. -** -** The \c Status field provides the return status from the #OS_write function call. -**/ -#define CFE_TBL_WRITE_TBL_REG_ERR_EID 68 - -/** \brief 'Cannot abort load of '\%s'. No load started.' -** \event 'Cannot abort load of '\%s'. No load started.' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Abort Load command is received and the command specified -** table is not currently in the process of being loaded. -**/ -#define CFE_TBL_LOAD_ABORT_ERR_EID 69 - -/** \brief 'Cannot activate table '\%s'. No Inactive image available' -** \event 'Cannot activate table '\%s'. No Inactive image available' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Activate Table command is received and the command specified -** table does not currently have an inactive buffer associated with it. -**/ -#define CFE_TBL_ACTIVATE_ERR_EID 70 - -/** \brief 'Incomplete load of '\%s' into '\%s' working buffer' -** \event 'Incomplete load of '\%s' into '\%s' working buffer' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Load Table command is received and the Table Services -** is unable to load the number of bytes specified in the Table Image Header of the command -** specified file from the file into the Inactive Buffer. -**/ -#define CFE_TBL_FILE_INCOMPLETE_ERR_EID 71 - -/** \brief 'Cannot load '\%s' (\%d) at offset \%d in '\%s' (\%d)' -** \event 'Cannot load '\%s' (\%d) at offset \%d in '\%s' (\%d)' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Load Table command is received and the Table Header in -** the specified Table Image file identifies a number of bytes with a specified starting offset -** that would exceed the size of the specified table. For example, if a table had 10 bytes and -** the Table Header indicated that the Table Image in the file contains 7 bytes that starts at -** offset 5, then the data content would have exceeded the 10 byte limit of the table. -** -** The numbers in parenthesis in the event message text indicate the data size (in bytes) for -** the specified load file and the registered size for the specified table. -**/ -#define CFE_TBL_LOAD_EXCEEDS_SIZE_ERR_EID 72 - -/** \brief 'Table Hdr in '\%s' indicates no data in file' -** \event 'Table Hdr in '\%s' indicates no data in file' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Load Table command is received and the Table Header in -** the specified Table Image file claims the file contains no data. -**/ -#define CFE_TBL_ZERO_LENGTH_LOAD_ERR_EID 73 - -/** \brief ''\%s' has partial load for uninitialized table '\%s'' -** \event ''\%s' has partial load for uninitialized table '\%s'' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Load Table command is received and the Table Header in -** the specified Table Image file indicates the starting offset for the table is non-zero and the -** table has never been previously, completely loaded. Partial Table loads are only allowed after -** the table has had a successful load. -**/ -#define CFE_TBL_PARTIAL_LOAD_ERR_EID 74 - -/** \brief 'File '\%s' has more data than Tbl Hdr indicates (\%d)' -** \event 'File '\%s' has more data than Tbl Hdr indicates (\%d)' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Load Table command is received and Table Services is -** able to locate more data in the specified Table Image file than the Table Header claims is present. -**/ -#define CFE_TBL_FILE_TOO_BIG_ERR_EID 75 - -/** \brief 'Too many Dump Only Table Dumps have been requested' -** \event 'Too many Dump Only Table Dumps have been requested' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Dump command for a Dump-Only Table was received and there are -** no more free Dump Only Control Blocks available. The number of simultaneous Dump Only Tables that -** can be pending is specified by the configuration parameter #CFE_TBL_MAX_SIMULTANEOUS_LOADS which -** is found in the cfe_platform_cfg.h file. -**/ -#define CFE_TBL_TOO_MANY_DUMPS_ERR_EID 76 - -/** \brief 'A dump for '\%s' is already pending' -** \event 'A dump for '\%s' is already pending' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Dump command for a Dump-Only Table was received and -** Table Services hasn't finished processing the previous Table Dump command for the same Table. -**/ -#define CFE_TBL_DUMP_PENDING_ERR_EID 77 - -/** \brief 'Illegal attempt to activate dump-only table '\%s'' -** \event 'Illegal attempt to activate dump-only table '\%s'' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Activate command for a Dump-Only Table was received. -** By definition, Dump-Only tables are not allowed to be loaded with any new data. -**/ -#define CFE_TBL_ACTIVATE_DUMP_ONLY_ERR_EID 78 - -/** \brief 'Attempted to load DUMP-ONLY table '\%s' from '\%s'' -** \event 'Attempted to load DUMP-ONLY table '\%s' from '\%s'' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Load command for a Dump-Only Table was received. -** By definition, Dump-Only tables are not allowed to be loaded with any new data. -**/ -#define CFE_TBL_LOADING_A_DUMP_ONLY_ERR_EID 79 - -/** \brief 'Cmd for Table '\%s' had illegal buffer parameter (0x\%08X)' -** \event 'Cmd for Table '\%s' had illegal buffer parameter (0x\%08X)' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when either a Table Validate command or a Table Dump Command -** contains a buffer identifier that does not equal either of the valid values -** (see #CFE_TBL_DumpCmd_t::ActiveTblFlag or #CFE_TBL_ValidateCmd_t::ActiveTblFlag) -** -** The parameter in the Event Message indicates (in hex) the value found for the ActiveTblFlag in the command. -**/ -#define CFE_TBL_ILLEGAL_BUFF_PARAM_ERR_EID 80 - -/** \brief 'Cannot activate table '\%s'. Inactive image not Validated' -** \event 'Cannot activate table '\%s'. Inactive image not Validated' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Activate command is received specifying -** a Table Image that has not been Validated. If a table has a validation function associated with it -** (as defined by the owning Application when the Table is first Registered), then the Inactive Image -** MUST be successfully Validated prior to Activation. -**/ -#define CFE_TBL_UNVALIDATED_ERR_EID 81 - -/** \brief ''\%s' found in Table Registry. CDS cannot be deleted until table is unregistered' -** \event ''\%s' found in Table Registry. CDS cannot be deleted until table is unregistered' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Delete Critical Data Store command is received specifying -** a Table Image that is still registered. Critical Table Images cannot be removed from the CDS until the -** table is first removed from the Registry. Unload the owning application and try again. -**/ -#define CFE_TBL_IN_REGISTRY_ERR_EID 82 - -/** \brief 'Table '\%s' is in Critical Table Registry but CDS is not tagged as a table' -** \event 'Table '\%s' is in Critical Table Registry but CDS is not tagged as a table' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Delete Critical Data Store command is received specifying -** a CDS name for a Critical Data Store that is NOT a critical table image. To delete CDSs that are not -** Critical Table Images, the Executive Services command #CFE_ES_DELETE_CDS_CC must be used. -**/ -#define CFE_TBL_NOT_CRITICAL_TBL_ERR_EID 83 - -/** \brief 'Table '\%s' is not found in Critical Table Registry' -** \event 'Table '\%s' is not found in Critical Table Registry' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Delete Critical Data Store command is received specifying -** a table name that cannot be found in the Critical Table Registry. If a Critical Data Store exists with -** the specified name, then the Critical Table Registry has somehow gotten out of sync with the CDS. -** Otherwise, the likely cause of this error is a misspelled table name in the command. -**/ -#define CFE_TBL_NOT_IN_CRIT_REG_ERR_EID 84 - -/** \brief 'Unable to locate '\%s' in CDS Registry' -** \event 'Unable to locate '\%s' in CDS Registry' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a Table Delete Critical Data Store command is received specifying -** a table name that WAS found in the Critical Table Registry but its associated entry in the Critical Data -** Store Registry was not found. Somehow the two entities have become out of synch. -**/ -#define CFE_TBL_CDS_NOT_FOUND_ERR_EID 85 - -/** \brief 'Error while deleting '\%s' from CDS, See SysLog.(Err=0x\%08X)' -** \event 'Error while deleting '\%s' from CDS, See SysLog.(Err=0x\%08X)' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an unexpected error was encountered during the deletion of the CDS. -** The System Log should have more precise information on the nature of the error. -**/ -#define CFE_TBL_CDS_DELETE_ERR_EID 86 - -/** \brief 'CDS '\%s' owning app is still active' -** \event 'CDS '\%s' owning app is still active' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an attempt is made to delete a CDS while an application with the -** same name as the CDS Prefix is still registered in the system. Owning applications must not be active -** before an associated CDS can be deleted. -**/ -#define CFE_TBL_CDS_OWNER_ACTIVE_ERR_EID 87 - -/** \brief 'Attempted to load table '\%s' while previous load is still pending' -** \event 'Attempted to load table '\%s' while previous load is still pending' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an attempt is made to load a table while a previous load is still -** pending. The most likely cause of this is the owning application is waiting for an appropriate time to -** load the table with the specified contents. In order to override this load, the user would be required -** to issue the \link #CFE_TBL_ABORT_LOAD_CC Abort Load Command \endlink. -**/ -#define CFE_TBL_LOADING_PENDING_ERR_EID 88 - -/** \brief 'Manage Notification Pkt Error(MsgId=0x\%08X, CC=0x\%04X, Param=0x\%08X, Status=0x\%08X)' -** \event 'Manage Notification Pkt Error(MsgId=0x\%08X, CC=0x\%04X, Param=0x\%08X, Status=0x\%08X)' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when a table management notification message -** fails to be sent via the software bus. -** -** The \c MsgId is the message ID of the table management notification message that was attempted to be sent, -** the \c CC is the command code, the \c Param is the application specified command parameter and the \c Status -** is the error code returned by the #CFE_SB_SendMsg API call. -**/ -#define CFE_TBL_FAIL_NOTIFY_SEND_ERR_EID 89 -/** \} */ - -/** \name API Informational Event Message IDs */ -/** \{ */ - -/** \brief 'Successfully loaded '\%s' from '\%s'' -** \event 'Successfully loaded '\%s' from '\%s'' -** -** \par Type: DEBUG (the first time) and INFORMATION (normally) -** -** \par Cause: -** -** This event message is generated when a Table is successfully updated by its owning Application -** with the contents of the Application specified file or memory area. This Event Message only -** appears when an Application successfully calls the #CFE_TBL_Load API. -**/ -#define CFE_TBL_LOAD_SUCCESS_INF_EID 35 - -/** \brief '\%s validation successful for Inactive '\%s'' -** \event '\%s validation successful for Inactive '\%s'' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated when a Table Image is successfully validated by its owning -** Application via the Validation function specified by the owning Application when the table -** was first registered. -**/ -#define CFE_TBL_VALIDATION_INF_EID 36 - -/** \brief '\%s Successfully Updated '\%s'' -** \event '\%s Successfully Updated '\%s'' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated when a Table's Active Buffer is successfully updated with the contents -** of its Inactive Buffer. -**/ -#define CFE_TBL_UPDATE_SUCCESS_INF_EID 37 - -/** \brief 'Successfully removed '\%s' from CDS' -** \event 'Successfully removed '\%s' from CDS' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated when a Critical Table's CDS has been successfully deleted. -**/ -#define CFE_TBL_CDS_DELETED_INFO_EID 38 -/** \} */ - - - -/** \name API Error Event Message IDs */ -/** \{ */ -/** \brief '\%s Failed to Register '\%s', Status=0x\%08X' -** \event '\%s Failed to Register '\%s', Status=0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Application calls #CFE_TBL_Register unsuccessfully. -** -** The \c Status field of the Event Message can be used to identify the reason for the failure -** by looking it up in the cfe_error.h file -**/ -#define CFE_TBL_REGISTER_ERR_EID 90 - -/** \brief '\%s Failed to Share '\%s', Status=0x\%08X' -** \event '\%s Failed to Share '\%s', Status=0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Application calls #CFE_TBL_Share unsuccessfully. -** -** The \c Status field of the Event Message can be used to identify the reason for the failure -** by looking it up in the cfe_error.h file -**/ -#define CFE_TBL_SHARE_ERR_EID 91 - -/** \brief '\%s Failed to Unregister '\%s', Status=0x\%08X' -** \event '\%s Failed to Unregister '\%s', Status=0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Application calls #CFE_TBL_Unregister unsuccessfully. -** -** The \c Status field of the Event Message can be used to identify the reason for the failure -** by looking it up in the cfe_error.h file -**/ -#define CFE_TBL_UNREGISTER_ERR_EID 92 - -/** \brief '\%s Failed to Load '\%s' from \%s, Status=0x\%08X" -** \event '\%s Failed to Load '\%s' from \%s, Status=0x\%08X" -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Application calls #CFE_TBL_Load unsuccessfully. -** -** The \c Status field of the Event Message can be used to identify the reason for the failure -** by looking it up in the cfe_error.h file -**/ -#define CFE_TBL_LOAD_ERR_EID 93 - -/** \brief '\%s Failed to Load '\%s' (Invalid Source Type)" -** \event '\%s Failed to Load '\%s' (Invalid Source Type)" -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Application calls #CFE_TBL_Load with a bad value for -** the \c SrcType parameter. The \c SrcType must be one of the values specified by #CFE_TBL_SrcEnum_t. -**/ -#define CFE_TBL_LOAD_TYPE_ERR_EID 94 - -/** \brief '\%s Failed to Update '\%s', Status=0x\%08X" -** \event '\%s Failed to Update '\%s', Status=0x\%08X" -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Application calls #CFE_TBL_Update (or, via an internal call, -** the #CFE_TBL_Manage) API and the Table fails to properly update. -** -** The \c Status parameter in the Event Message can be used to identify the reason for the failure -** by looking it up in the cfe_error.h file. -**/ -#define CFE_TBL_UPDATE_ERR_EID 95 - -/** \brief '\%s validation failed for Inactive '\%s', Status=0x\%08X" -** \event '\%s validation failed for Inactive '\%s', Status=0x\%08X" -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Application calls #CFE_TBL_Validate (or, via an internal call, -** the #CFE_TBL_Manage) API and the Table fails its Validation. -** -** The \c Status parameter in the Event Message contains the status code returned by the Table's -** Validation function as defined by the owning Application when the Table was Registered. -**/ -#define CFE_TBL_VALIDATION_ERR_EID 96 - -/** \brief 'Unable to verify Spacecraft ID for '\%s', ID = 0x\%08X' -** \event 'Unable to verify Spacecraft ID for '\%s', ID = 0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when either an Application calls the #CFE_TBL_Load API or a Table -** Load command has been received and the specified table file has failed Spacecraft ID validation. -** Verification of Spacecraft ID in table files is enabled/disabled via #CFE_TBL_VALID_SCID_COUNT, -** defined in the platform configuration header file. This event message can only be generated if -** #CFE_TBL_VALID_SCID_COUNT has a non-zero value and the table file has a \link #CFE_FS_Header_t -** cFE Standard File Header \endlink whose \link #CFE_FS_Header_t::SpacecraftID Spacecraft ID \endlink -** does not match one of the values defined for Spacecraft ID verification in the platform config file. -** The most likely causes for this error are: -** -# The specified table file is not intended for this spacecraft. -** -# The specified table file has been created with bad "endianess" (headers should always conform to -** a big endian format). -** -# The specified table file has become corrupted. -** -# The definition for #CFE_TBL_VALID_SCID_COUNT is not large enough to include all of the valid -** Spacecraft ID entries in the platform config file. -** -# There is no entry for this Spacecraft ID in the platform config file list of valid Spacecraft ID's. -** -** The \c ID field specified in the event message contains the Spacecraft ID that was found -** in the specified table file. -**/ -#define CFE_TBL_SPACECRAFT_ID_ERR_EID 97 - -/** \brief 'Unable to verify Processor ID for '\%s', ID = 0x\%08X' -** \event 'Unable to verify Processor ID for '\%s', ID = 0x\%08X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when either an Application calls the #CFE_TBL_Load API or a Table -** Load command has been received and the specified table file has failed Processor ID validation. -** Verification of Processor ID in table files is enabled/disabled via #CFE_TBL_VALID_PRID_COUNT, -** defined in the platform configuration header file. This event message can only be generated if -** #CFE_TBL_VALID_PRID_COUNT has a non-zero value and the table file has a \link #CFE_FS_Header_t -** cFE Standard File Header \endlink whose \link #CFE_FS_Header_t::ProcessorID Processor ID \endlink -** does not match one of the values defined for Processor ID verification in the platform config file. -** The most likely causes for this error are: -** -# The specified table file is not intended for this processor. -** -# The specified table file has been created with bad "endianess" (headers should always conform to -** a big endian format). -** -# The specified table file has become corrupted. -** -# The definition for #CFE_TBL_VALID_PRID_COUNT is not large enough to include all of the valid -** Processor ID entries in the platform config file. -** -# There is no entry for this Processor ID in the platform config file list of valid Processor ID's. -** -** The \c ID field specified in the event message contains the Processor ID that was found -** in the specified table file. -**/ -#define CFE_TBL_PROCESSOR_ID_ERR_EID 98 - -/** \} */ - - - -#endif /* _cfe_tbl_events_ */ - -/************************/ -/* End of File Comment */ -/************************/ diff --git a/src/components/interface/cFE/cfe_tbl_filedef.h b/src/components/interface/cFE/cfe_tbl_filedef.h deleted file mode 100644 index 32cd4aa814..0000000000 --- a/src/components/interface/cFE/cfe_tbl_filedef.h +++ /dev/null @@ -1,122 +0,0 @@ -/* -** -** $Id: cfe_tbl_filedef.h 1.6 2014/08/26 16:41:40GMT-05:00 sstrege Exp $ -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Title: ELF2CFETBL Utility Header File for Table Images -** -** Purpose: -** This header file provides a data structure definition and macro definition -** required in source code that is intended to be compiled into a cFE compatible -** Table Image file. -** -** Design Notes: -** -** Typically, a user would include this file in a ".c" file that contains nothing -** but a desired instantiation of values for a table image along with the macro -** defined below. After compilation, the resultant elf file can be processed using -** the 'elf2cfetbl' utility to generate a file that can be loaded onto a cFE flight -** system and successfully loaded into a table using the cFE Table Services. -** -** References: -** Flight Software Branch C Coding Standard Version 1.0a -** -** Notes: -** -** $Log: cfe_tbl_filedef.h $ -** Revision 1.6 2014/08/26 16:41:40GMT-05:00 sstrege -** Updated CFE_TBL_FILDEF_MAX_NAME_LEN to be set equal to CFE_TBL_MAX_FULL_NAME_LEN -** Revision 1.5 2014/06/03 10:35:05EDT lwalling -** Updated CFE_TBL_FILEDEF macro to include reference to OS_USED macro -** Revision 1.4 2010/11/15 10:00:47EST dkobe -** Modified definition of CFE_TBL_FileDef_t to ensure longword alignment -** Revision 1.3 2010/10/25 15:01:11EDT jmdagost -** Corrected bad apostrophe in prologue. -** Revision 1.2 2010/10/04 15:24:57EDT jmdagost -** Cleaned up copyright symbol. -** Revision 1.1 2008/04/17 08:05:25EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.1.1.2 2006/11/17 16:46:55EST David Kobe (dlkobe) -** Updated with Doxygen formatted comments -*/ - -/* -** Ensure that header is included only once... -*/ -#ifndef _cfe_tbl_filedef_ -#define _cfe_tbl_filedef_ - -#include "cfe.h" - -/* CFE_TBL_MAX_FULL_NAME_LEN is defined in cfe_tbl.h and includes alignment bytes */ -#define CFE_TBL_FILDEF_MAX_NAME_LEN (CFE_TBL_MAX_FULL_NAME_LEN) - -/* Compute number of additional bytes needed to make */ -/* CFE_FS_HDR_DESC_MAX_LEN rounded up to nearest longword boundary */ -#define CFE_TBL_FILEDEF_FS_HDR_ALIGN32 (CFE_FS_HDR_DESC_MAX_LEN - ((CFE_FS_HDR_DESC_MAX_LEN/4)*4)) - -/* Allocate enough space for maximum table description length plus alignment bytes */ -#define CFE_TBL_FILDEF_FS_HDR_LEN (CFE_FS_HDR_DESC_MAX_LEN + CFE_TBL_FILEDEF_FS_HDR_ALIGN32) - -/* Compute number of additional bytes needed to make */ -/* OS_MAX_FILE_NAME rounded up to nearest longword boundary */ -#define CFE_TBL_FILEDEF_OS_FILE_ALIGN32 (OS_MAX_FILE_NAME - ((OS_MAX_FILE_NAME/4)*4)) - -/* Allocate enough space for maximum file name length plus alignment bytes */ -#define CFE_TBL_FILDEF_OS_FILE_LEN (OS_MAX_FILE_NAME + CFE_TBL_FILEDEF_OS_FILE_ALIGN32) - -typedef struct -{ - uint32 Reserved; /**< Future Use: NumTblSegments in File? */ - uint32 Offset; /**< Byte Offset at which load should commence */ - uint32 NumBytes; /**< Number of bytes to load into table */ - char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< Fully qualified name of table to load */ -} CFE_TBL_File_Hdr_t; - - -typedef struct -{ - char ObjectName[64]; /**< \brief Name of instantiated variable that contains desired table image */ - char TableName[CFE_TBL_FILDEF_MAX_NAME_LEN]; /**< \brief Name of Table as defined onboard */ - char Description[CFE_TBL_FILDEF_FS_HDR_LEN]; /**< \brief Description of table image that is included in cFE File Header */ - char TgtFilename[CFE_TBL_FILDEF_OS_FILE_LEN]; /**< \brief Default filename to be used for output of elf2cfetbl utility */ - uint32 ObjectSize; /**< \brief Size, in bytes, of instantiated object */ -} CFE_TBL_FileDef_t; - -/** The CFE_TBL_FILEDEF macro can be used to simplify the declaration of a table image when using the elf2cfetbl utility. -** An example of the source code and how this macro would be used is as follows: \code - - #include "cfe_tbl_filedef.h" - - typedef struct - { - int Int1; - int Int2; - int Int3; - char Char1; - } MyTblStruct_t; - - MyTblStruct_t MyTblStruct = { 0x01020304, 0x05060708, 0x090A0B0C, 0x0D }; - - CFE_TBL_FILEDEF(MyTblStruct, MyApp.TableName, Table Utility Test Table, MyTblDefault.bin ) - -\endcode -*/ - -#define CFE_TBL_FILEDEF(ObjName, TblName, Desc, Filename) static OS_USED CFE_TBL_FileDef_t CFE_TBL_FileDef={#ObjName, #TblName, #Desc, #Filename, sizeof(ObjName)}; - -/*************************************************************************/ - -#endif /* _cfe_tbl_filedef_ */ - -/************************/ -/* End of File Comment */ -/************************/ diff --git a/src/components/interface/cFE/cfe_tbl_msg.h b/src/components/interface/cFE/cfe_tbl_msg.h deleted file mode 100644 index a612091faa..0000000000 --- a/src/components/interface/cFE/cfe_tbl_msg.h +++ /dev/null @@ -1,851 +0,0 @@ -/* -** $Id: cfe_tbl_msg.h 1.9 2014/08/19 13:49:24GMT-05:00 sstrege Exp $ -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Purpose: cFE Table Services (TBL) SB message definitions header file -** -** Author: D.Kobe/Hammers -** -** Notes: -** -** $Log: cfe_tbl_msg.h $ -** Revision 1.9 2014/08/19 13:49:24GMT-05:00 sstrege -** Fixed doxygen warning -** Revision 1.8 2014/06/09 18:27:05EDT lwalling -** Removed pad bytes from TBL housekeeping packet -** Revision 1.7 2014/06/09 10:30:25EDT lwalling -** Add LastTableLoaded to TBL housekeeping structure -** Revision 1.6 2010/10/27 16:33:44EDT dkobe -** Added CRC to Registry Entry Telemetry Message -** Revision 1.5 2010/10/27 13:54:24EDT dkobe -** Added command message data structure for TBL notification messages -** Revision 1.4 2010/10/25 15:01:11EDT jmdagost -** Corrected bad apostrophe in prologue. -** Revision 1.3 2010/10/04 15:24:58EDT jmdagost -** Cleaned up copyright symbol. -** Revision 1.2 2008/12/08 12:07:10EST dkobe -** Updates to correct doxygen errors -** Revision 1.1 2008/04/17 08:05:25EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.20 2007/09/27 15:53:53EDT David Kobe (dlkobe) -** Added relevant "See Also" doxygen comment references. -** Revision 1.19 2007/07/05 15:39:17EDT dlkobe -** Added Critical Table Flag to Tbl Registry Record Tlm Command -** Revision 1.18 2007/06/07 13:07:46EDT dlkobe -** Added Command and Telemetry doxygen comments to TIME, EVS and SB -** Revision 1.17 2007/06/02 10:10:11EDT dlkobe -** Added doxygen comments for User's Guides -** Revision 1.16 2007/05/25 16:24:49EDT dlkobe -** Continued updating doxygen comments -** Revision 1.14 2007/05/16 15:13:39EDT dlkobe -** Added MemPoolHandle members to HK packet -** Revision 1.13 2007/05/04 15:55:06EDT dlkobe -** Added Delete CDS Command -** Revision 1.12 2006/11/10 15:14:35GMT-05:00 dlkobe -** Updated comments to conform with doxygen -** Revision 1.11 2006/10/31 12:21:44GMT-05:00 dlkobe -** Removed all references to the TBL_MOD_DUMP_ONLY option command -** -*/ - -/* -** Ensure that header is included only once... -*/ -#ifndef _cfe_tbl_msg_ -#define _cfe_tbl_msg_ - -/* -** Required header files... -*/ -#include "cfe.h" - -/*************************************************************************/ - -/* -** Table task command packet command codes -*/ -/** \name Table Services Command Codes */ -/** \{ */ - -/** \cfetblcmd Table No-Op -** -** \par Description -** This command performs no other function than to increment the -** command execution counter. The command may be used to verify -** general aliveness of the Table Services task. -** -** \cfecmdmnemonic \TBL_NOOP -** -** \par Command Structure -** #CFE_TBL_NoArgsCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TBL_CMDPC - command execution counter will -** increment -** - The #CFE_TBL_NOOP_INF_EID informational event message will -** be generated -** -** \par Error Conditions -** There are no error conditions for this command. If the Table -** Services receives the command, the event is sent (although it -** may be filtered by EVS) and the counter is incremented -** unconditionally. -** -** \par Criticality -** None -** -** \sa -*/ -#define CFE_TBL_NOOP_CC 0 - -/** \cfetblcmd Table Reset Counters -** -** \par Description -** This command resets the following counters within the Table -** Services housekeeping telemetry: -** - Command Execution Counter (\TBL_CMDPC) -** - Command Error Counter (\TBL_CMDEC) -** - Successful Table Validations Counter (\TBL_VALSUCCESSCTR) -** - Failed Table Validations Counter (\TBL_VALFAILEDCTR) -** - Number of Table Validations Requested (\TBL_VALREQCTR) -** -** \cfecmdmnemonic \TBL_RESETCTRS -** -** \par Command Structure -** #CFE_TBL_NoArgsCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \TBL_CMDPC - command execution counter will -** increment -** - The #CFE_TBL_RESET_INF_EID debug event message will be -** generated -** -** \par Error Conditions -** There are no error conditions for this command. If the Table -** Services receives the command, the event is sent (although it -** may be filtered by EVS) and the counter is incremented -** unconditionally. -** -** \par Criticality -** This command is not inherently dangerous. However, it is -** possible for ground systems and on-board safing procedures -** to be designed such that they react to changes in the counter -** values that are reset by this command. -** -** \sa -*/ -#define CFE_TBL_RESET_CC 1 - -/** \cfetblcmd Load Table -** -** \par Description -** This command loads the contents of the specified file into -** an inactive buffer for the table specified within the file. -** -** \cfecmdmnemonic \TBL_LOAD -** -** \par Command Structure -** #CFE_TBL_LoadCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with -** the following telemetry: -** - \b \c \TBL_CMDPC - command execution counter will -** increment -** - The #CFE_TBL_FILE_LOADED_INF_EID informational event message -** will be generated -** -** \par Error Conditions -** This command can fail for the following reasons: -** - Table name found in table image file's table header is not found -** in table registry (ie - The table associated with the table image -** in the file has not been registered by an application). -** - The table image file's header indicates the file contains 'x' -** number of bytes of data but the file contains less. -** - No working buffers are available for the load. This would indicate -** that too many single-buffered table loads are in progress at the same -** time. -** - The table image file's header indicates the data to be loaded is -** beyond the size of the table. Either the number of bytes in the -** file are too many or the starting offset into the table is too high. -** - The table image file's header indicates there is no data in the -** file (ie - Number of bytes to load is zero). -** - An attempt is being made to load an uninitialized table with a file -** containing only a partial table image. -** - The table image file was unable to be opened. Either the file does -** not exist at the specified location, the filename is in error, or -** the file system has been corrupted. -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \TBL_CMDEC - command error counter will increment -** - Command specific error event messages are issued for all error cases -** -** \par Criticality -** This command is not inherently dangerous. It is performing the first -** step of loading a table and can be aborted (using the Abort Table Load -** command described below) without affecting the contents of the active -** table image. -** -** \sa #CFE_TBL_DUMP_CC, #CFE_TBL_VALIDATE_CC, #CFE_TBL_ACTIVATE_CC, #CFE_TBL_ABORT_LOAD_CC -*/ -#define CFE_TBL_LOAD_CC 2 - -/** \cfetblcmd Dump Table -** -** \par Description -** This command will cause the Table Services to put the contents -** of the specified table buffer into the command specified file. -** -** \cfecmdmnemonic \TBL_DUMP -** -** \par Command Structure -** #CFE_TBL_DumpCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TBL_CMDPC - command execution counter will -** increment -** - Either the #CFE_TBL_OVERWRITE_DUMP_INF_EID OR the -** #CFE_TBL_WRITE_DUMP_INF_EID informational event message will -** be generated -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - A single buffered table's inactive buffer was requested to be -** dumped and no such buffer is currently allocated. -** - Error occurred during write operation to file. Possible causes -** might be insufficient space in the file system or the filename -** or file path is improperly specified. -** - The specified table name was not found in the table registry. -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \TBL_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases -** -** \par Criticality -** This command is not inherently dangerous. It will create a new -** file in the file system and could, if performed repeatedly without -** sufficient file management by the operator, fill the file system. -** -** \sa #CFE_TBL_LOAD_CC, #CFE_TBL_VALIDATE_CC, #CFE_TBL_ACTIVATE_CC, #CFE_TBL_ABORT_LOAD_CC -*/ -#define CFE_TBL_DUMP_CC 3 - -/** \cfetblcmd Validate Table -** -** \par Description -** This command will cause Table Services to calculate the Data Integrity -** Value for the specified table and to notify the owning application that -** the table's validation function should be executed. The results of both -** the Data Integrity Value computation and the validation function are -** reported in Table Services Housekeeping Telemetry. -** -** \cfecmdmnemonic \TBL_VALIDATE -** -** \par Command Structure -** #CFE_TBL_ValidateCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the following -** telemetry: -** - \b \c \TBL_CMDPC - command execution counter will increment -** - \b \c \TBL_VALREQCTR - table validation request counter will increment -** - \b \c \TBL_LASTVALCRC - calculated data integrity value will be updated -** - The #CFE_TBL_VAL_REQ_MADE_INF_EID debug event message (indicating the -** application is being notified of a validation request) -** -** If the specified table has an associated validation function, then the -** following telemetry will also change: -** - Either \b \c \TBL_VALSUCCESSCTR OR \b \c \TBL_VALFAILEDCTR will -** increment -** - \b \c \TBL_VALCOMPLTDCTR - table validations performed counter will -** increment -** - \b \c \TBL_LASTVALS - table validation function return status will -** update -** - The #CFE_TBL_VALIDATION_INF_EID informational event message (indicating the -** validation function return status) will be generated -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - A single buffered table's inactive buffer was requested to be dumped -** and no such buffer is currently allocated. -** - Too many validations have been requested simultaneously. The operator -** must wait for one or more applications to perform their table validation -** functions before trying again. -** - The specified table name was not found in the table registry. -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \TBL_CMDEC - command error counter will increment -** - Command specific error event message are issued for all error cases -** -** \par Criticality -** The success or failure of a table validation does not have any immediate -** impact on table contents. The results are sent to the operator in telemetry -** and the operator must determine whether the results are acceptable and send a -** command to activate the validated table image. -** -** \sa #CFE_TBL_LOAD_CC, #CFE_TBL_DUMP_CC, #CFE_TBL_ACTIVATE_CC, #CFE_TBL_ABORT_LOAD_CC -*/ -#define CFE_TBL_VALIDATE_CC 4 - -/** \cfetblcmd Activate Table -** -** \par Description -** This command will cause Table Services to notify a table's owner -** that an update is pending. The owning application will then update -** the contents of the active table buffer with the contents of the -** associated inactive table buffer at a time of their convenience. -** -** \cfecmdmnemonic \TBL_ACTIVATE -** -** \par Command Structure -** #CFE_TBL_ActivateCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TBL_CMDPC - command execution counter will -** increment -** - The #CFE_TBL_UPDATE_SUCCESS_INF_EID informational event message -** will be generated -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - A single buffered table's inactive buffer was requested to be -** dumped and no such buffer is currently allocated. -** - The specified table name was not found in the table registry. -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \TBL_CMDEC - command error counter will increment -** - Command specific error event message are issued for all -** error cases -** -** \par Criticality -** This command will cause the contents of the specified table to be -** updated with the contents in the inactive table buffer. -** -** \sa #CFE_TBL_LOAD_CC, #CFE_TBL_DUMP_CC, #CFE_TBL_VALIDATE_CC, #CFE_TBL_ABORT_LOAD_CC -*/ -#define CFE_TBL_ACTIVATE_CC 5 - -/** \cfetblcmd Dump Table Registry -** -** \par Description -** This command will cause Table Services to write some of the -** contents of the Table Registry to the command specified file. -** This allows the operator to see the current state and configuration -** of all tables that have been registered with the cFE. -** -** \cfecmdmnemonic \TBL_WRITEREG2FILE -** -** \par Command Structure -** #CFE_TBL_DumpRegCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TBL_CMDPC - command execution counter will -** increment -** - The generation of either #CFE_TBL_OVERWRITE_REG_DUMP_INF_EID -** or #CFE_TBL_WRITE_REG_DUMP_INF_EID debug event messages -** - The specified file should appear (or be updated) at the -** specified location in the file system -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - Error occurred during write operation to file. Possible -** causes might be insufficient space in the file system -** or the filename or file path is improperly specified. -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \TBL_CMDEC - command error counter will increment -** - An Error specific event message -** -** \par Criticality -** This command is not inherently dangerous. It will create a new -** file in the file system and could, if performed repeatedly without -** sufficient file management by the operator, fill the file system. -** -** \sa #CFE_TBL_TLM_REG_CC -*/ -#define CFE_TBL_DUMP_REG_CC 6 - -/** \cfetblcmd Telemeter One Table Registry Entry -** -** \par Description -** This command will cause Table Services to telemeter the contents -** of the Table Registry for the command specified table. -** -** \cfecmdmnemonic \TBL_TLMREG -** -** \par Command Structure -** #CFE_TBL_TlmRegCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TBL_CMDPC - command execution counter will increment -** - Receipt of a Table Registry Info Packet (see #CFE_TBL_TblRegPacket_t) -** - The #CFE_TBL_TLM_REG_CMD_INF_EID debug event message will -** be generated -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The specified table name was not found in the table registry. -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \TBL_CMDEC - command error counter will increment -** - Error specific event message -** -** \par Criticality -** This command is not inherently dangerous. It will generate -** additional telemetry. -** -** \sa #CFE_TBL_DUMP_REG_CC -*/ -#define CFE_TBL_TLM_REG_CC 7 - -/** \cfetblcmd Delete Critical Table from Critical Data Store -** -** \par Description -** This command will delete the Critical Data Store (CDS) associated -** with the specified Critical Table. Note that any table still -** present in the Table Registry is unable to be deleted from -** the Critical Data Store. All Applications that are accessing -** the critical table must release and unregister their access -** before the CDS can be deleted. -** -** \cfecmdmnemonic \TBL_DELETECDS -** -** \par Command Structure -** #CFE_TBL_DelCDSCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TBL_CMDPC - command execution counter will -** increment -** - The #CFE_TBL_CDS_DELETED_INFO_EID informational event message -** will be generated -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The specified table name was not found in the critical data -** store registry -** - The specified table name WAS found in the table registry (all -** registrations/sharing of the table must be unregistered before -** the table's CDS can be deleted) -** - The table's owning application is still active -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \TBL_CMDEC - command error counter will increment -** - Error specific event message -** -** \par Criticality -** This command will cause the loss of the specified table's contents -** before the owning Application was terminated. -** -** \sa #CFE_ES_DUMP_CDS_REG_CC, #CFE_ES_DELETE_CDS_CC -*/ -#define CFE_TBL_DELETE_CDS_CC 8 - -/** \cfetblcmd Abort Table Load -** -** \par Description -** This command will cause Table Services to discard the contents of -** a table buffer that was previously loaded with the data in a file -** as specified by a Table Load command. For single buffered tables, -** the allocated shared working buffer is freed and becomes available -** for other Table Load commands. -** -** \cfecmdmnemonic \TBL_LOADABORT -** -** \par Command Structure -** #CFE_TBL_AbortLdCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TBL_CMDPC - command execution counter will increment -** - The #CFE_TBL_LOAD_ABORT_INF_EID informational event message -** is generated -** - If the load was aborted for a single buffered table, the -** \b \c \TBL_NUMFREESHRBUF telemetry point should increment -** -** \par Error Conditions -** This command may fail for the following reason(s): -** - The specified table name was not found in the table registry. -** - The specified table did not have a load in progress to be aborted. -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \TBL_CMDEC - command error counter will increment -** - Error specific event message -** -** \par Criticality -** This command will cause the loss of data put into an inactive table buffer. -** -** \sa #CFE_TBL_LOAD_CC, #CFE_TBL_DUMP_CC, #CFE_TBL_VALIDATE_CC, #CFE_TBL_ACTIVATE_CC -*/ -#define CFE_TBL_ABORT_LOAD_CC 9 -/** \} */ - -/* -** Validate Command Buffer Selection Parameters -*/ -/** \name Validate and Dump Command Buffer Selection Parameters */ -/** \{ */ -#define CFE_TBL_INACTIVE_BUFFER 0 -#define CFE_TBL_ACTIVE_BUFFER 1 -/** \} */ - -/*************************************************************************/ - -/********************************/ -/* Command Message Data Formats */ -/********************************/ -/** -** \brief Generic "no arguments" command -** -** This command structure is used for commands that do not have any parameters. -** This includes: -** -# The Housekeeping Request Message -** -# The No-Op Command (For details, see #CFE_TBL_NOOP_CC) -** -# The Reset Counters Command (For details, see #CFE_TBL_RESET_CC) -*/ -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - -} CFE_TBL_NoArgsCmd_t; - -/** -** \brief Load Table Command -** -** For command details, see #CFE_TBL_LOAD_CC -** -**/ -typedef struct -{ - char LoadFilename[OS_MAX_PATH_LEN]; /**< \brief Filename (and path) of data to be loaded */ - /**< ASCII Character string containing full path - filename for file to be loaded */ -} CFE_TBL_LoadCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_TBL_LoadCmd_Payload_t Payload; -} CFE_TBL_LoadCmd_t; - -/** -** \brief Dump Table Command -** -** For command details, see #CFE_TBL_DUMP_CC -*/ -typedef struct -{ - uint16 ActiveTblFlag; /**< \brief #CFE_TBL_INACTIVE_BUFFER=Inactive Table, - #CFE_TBL_ACTIVE_BUFFER=Active Table */ - /**< Selects either the "Inactive" - (#CFE_TBL_INACTIVE_BUFFER) buffer or the - "Active" (#CFE_TBL_ACTIVE_BUFFER) buffer - to be dumped */ - char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Full name of table to be dumped */ - /**< ASCII string containing full table name - identifier of table to be dumped */ - char DumpFilename[OS_MAX_PATH_LEN]; /**< \brief Full Filename where data is to be written */ - /**< ASCII string containing full path of filename - where data is to be dumped */ -} CFE_TBL_DumpCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_TBL_DumpCmd_Payload_t Payload; -} CFE_TBL_DumpCmd_t; - -/** -** \brief Validate Table Command -** -** For command details, see #CFE_TBL_VALIDATE_CC -*/ -typedef struct -{ - uint16 ActiveTblFlag; /**< \brief #CFE_TBL_INACTIVE_BUFFER=Inactive Table, - #CFE_TBL_ACTIVE_BUFFER=Active Table */ - /**< Selects either the "Inactive" - (#CFE_TBL_INACTIVE_BUFFER) buffer or the - "Active" (#CFE_TBL_ACTIVE_BUFFER) buffer - to be validated */ - char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Full Name of Table to be validated */ - /**< ASCII string containing full table name - identifier of table to be validated */ -} CFE_TBL_ValidateCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_TBL_ValidateCmd_Payload_t Payload; -} CFE_TBL_ValidateCmd_t; - -/** -** \brief Activate Table Command -** -** For command details, see #CFE_TBL_ACTIVATE_CC -*/ -typedef struct -{ - char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Full Name of Table to be activated */ - /**< ASCII string containing full table name - identifier of table to be activated */ -} CFE_TBL_ActivateCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_TBL_ActivateCmd_Payload_t Payload; -} CFE_TBL_ActivateCmd_t; - -/** -** \brief Dump Registry Command -** -** For command details, see #CFE_TBL_DUMP_REG_CC -*/ -typedef struct -{ - char DumpFilename[OS_MAX_PATH_LEN]; /**< \brief Full Filename where dumped data is to be - written */ - /**< ASCII string containing full path of filename - where registry is to be dumped */ -} CFE_TBL_DumpRegCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_TBL_DumpRegCmd_Payload_t Payload; -} CFE_TBL_DumpRegCmd_t; - -/** -** \brief Telemeter Table Registry Entry Command -** -** For command details, see #CFE_TBL_TLM_REG_CC -*/ -typedef struct -{ - char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Full Name of Table whose registry entry - is to be telemetered */ - /**< ASCII string containing full table name - identifier of table whose registry entry is - to be telemetered via #CFE_TBL_TblRegPacket_t */ -} CFE_TBL_TlmRegCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_TBL_TlmRegCmd_Payload_t Payload; -} CFE_TBL_TlmRegCmd_t; - -/** -** \brief Delete Critical Table CDS Command -** -** For command details, see #CFE_TBL_DELETE_CDS_CC -*/ -typedef struct -{ - char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Full Name of Table whose CDS is - to be deleted */ - /**< ASCII string containing full table name - identifier of a critical table whose - CDS is to be deleted */ -} CFE_TBL_DelCDSCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_TBL_DelCDSCmd_Payload_t Payload; -} CFE_TBL_DelCDSCmd_t; - -/** -** \brief Abort Load Command -** -** For command details, see #CFE_TBL_ABORT_LOAD_CC -*/ -typedef struct -{ - char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Full Name of Table whose load is to be aborted */ - /**< ASCII string containing full table name - identifier of a table whose load is to be aborted */ -} CFE_TBL_AbortLdCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_TBL_AbortLdCmd_Payload_t Payload; -} CFE_TBL_AbortLdCmd_t; - - -/*************************************************************************/ -/******************************************/ -/* Generated Command Message Data Formats */ -/******************************************/ -/** -** \brief Table Management Notification Message -** -** \par Description -** Whenever an application that owns a table calls the #CFE_TBL_NotifyByMessage API -** following the table registration, Table services will generate the following -** command message with the application specified message ID, command code and -** parameter whenever the table requires management (e.g. - loads and validations). -*/ -typedef struct -{ - uint32 Parameter; /**< \brief Application specified command parameter */ -} CFE_TBL_NotifyCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; /**< \brief cFE Software Bus Command Message Header */ - CFE_TBL_NotifyCmd_Payload_t Payload; -} CFE_TBL_NotifyCmd_t; - -/*************************************************************************/ -/**********************************/ -/* Telemetry Message Data Formats */ -/**********************************/ -/** -** \cfetbltlm Table Services Housekeeping Packet -**/ -typedef struct -{ - /* - ** Task command interface counters... - */ - uint8 CmdCounter; /**< \cfetlmmnemonic \TBL_CMDPC - \brief Count of valid commands received */ - uint8 ErrCounter; /**< \cfetlmmnemonic \TBL_CMDEC - \brief Count of invalid commands received */ - - /* - ** Table Registry Statistics - */ - uint16 NumTables; /**< \cfetlmmnemonic \TBL_NUMTABLES - \brief Number of Tables Registered */ - uint16 NumLoadPending; /**< \cfetlmmnemonic \TBL_NUMUPDATESPEND - \brief Number of Tables pending on Applications for their update */ - - /* - ** Last Table Validation Results - */ - uint16 ValidationCtr; /**< \cfetlmmnemonic \TBL_VALCOMPLTDCTR - \brief Number of completed table validations */ - uint32 LastValCrc; /**< \cfetlmmnemonic \TBL_LASTVALCRC - \brief Data Integrity Value computed for last table validated */ - int32 LastValStatus; /**< \cfetlmmnemonic \TBL_LASTVALS - \brief Returned status from validation function for last table validated */ - boolean ActiveBuffer; /**< \cfetlmmnemonic \TBL_LASTVALBUF - \brief Indicator of whether table buffer validated was 0=Inactive, 1=Active */ - char LastValTableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \cfetlmmnemonic \TBL_LASTVALTBLNAME - \brief Name of last table validated */ - uint8 SuccessValCtr; /**< \cfetlmmnemonic \TBL_VALSUCCESSCTR - \brief Total number of successful table validations */ - uint8 FailedValCtr; /**< \cfetlmmnemonic \TBL_VALFAILEDCTR - \brief Total number of unsuccessful table validations */ - uint8 NumValRequests; /**< \cfetlmmnemonic \TBL_VALREQCTR - \brief Number of times Table Services has requested validations from Apps */ - - /* - ** Ground system interface information - */ - uint8 NumFreeSharedBufs; /**< \cfetlmmnemonic \TBL_NUMFREESHRBUF - \brief Number of free Shared Working Buffers */ - uint8 ByteAlignPad1; /**< \cfetlmmnemonic \TBL_BYTEALIGNPAD1 - \brief Spare byte to ensure longword alignment */ - CFE_ES_MemHandle_t MemPoolHandle; /**< \cfetlmmnemonic \TBL_MEMPOOLHANDLE - \brief Handle to TBL's memory pool */ - CFE_TIME_SysTime_t LastUpdateTime; /**< \cfetlmmnemonic \TBL_LASTUPDTIME - \brief Time of last table update */ - char LastUpdatedTbl[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \cfetlmmnemonic \TBL_LASTUPDTBLNAME - \brief Name of the last table updated */ - char LastFileLoaded[OS_MAX_PATH_LEN]; /**< \cfetlmmnemonic \TBL_LASTFILELOADED - \brief Path and Name of last table image file loaded */ - char LastFileDumped[OS_MAX_PATH_LEN]; /**< \cfetlmmnemonic \TBL_LASTFILEDUMPED - \brief Path and Name of last file dumped to */ - char LastTableLoaded[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \cfetlmmnemonic \TBL_LASTTABLELOADED - \brief Name of the last table loaded */ -} CFE_TBL_HkPacket_Payload_t; - -typedef struct -{ - uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; /**< \brief cFE Software Bus Telemetry Message Header */ - CFE_TBL_HkPacket_Payload_t Payload; -} CFE_TBL_HkPacket_t; - - -/** -** \cfetbltlm Table Registry Info Packet -**/ -typedef struct -{ - uint32 Size; /**< \cfetlmmnemonic \TBL_SIZE - \brief Size, in bytes, of Table */ - uint32 Crc; /**< \cfetlmmnemonic \TBL_CRC - \brief Most recently calculated CRC of Table */ - cpuaddr ActiveBufferAddr; /**< \cfetlmmnemonic \TBL_ACTBUFADD - \brief Address of Active Buffer */ - cpuaddr InactiveBufferAddr; /**< \cfetlmmnemonic \TBL_IACTBUFADD - \brief Address of Inactive Buffer */ - cpuaddr ValidationFuncPtr; /**< \cfetlmmnemonic \TBL_VALFUNCPTR - \brief Ptr to Owner App's function that validates tbl contents */ - CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \cfetlmmnemonic \TBL_TIMELASTUPD - \brief Time when Table was last updated */ - uint32 FileCreateTimeSecs; /**< \cfetlmmnemonic \TBL_FILECSECONDS - \brief File creation time from last file loaded into table */ - uint32 FileCreateTimeSubSecs; /**< \cfetlmmnemonic \TBL_FILECSUBSECONDS - \brief File creation time from last file loaded into table */ - boolean TableLoadedOnce; /**< \cfetlmmnemonic \TBL_LOADEDONCE - \brief Flag indicating whether table has been loaded once or not */ - boolean LoadPending; /**< \cfetlmmnemonic \TBL_UPDATEPNDNG - \brief Flag indicating an inactive buffer is ready to be copied */ - boolean DumpOnly; /**< \cfetlmmnemonic \TBL_DUMPONLY - \brief Flag indicating Table is NOT to be loaded */ - boolean DblBuffered; /**< \cfetlmmnemonic \TBL_DBLBUFFERED - \brief Flag indicating Table has a dedicated inactive buffer */ - char Name[CFE_TBL_MAX_FULL_NAME_LEN];/**< \cfetlmmnemonic \TBL_NAME - \brief Processor specific table name */ - char LastFileLoaded[OS_MAX_PATH_LEN];/**< \cfetlmmnemonic \TBL_LASTFILEUPD - \brief Filename of last file loaded into table */ - char OwnerAppName[OS_MAX_API_NAME]; /**< \cfetlmmnemonic \TBL_OWNERAPP - \brief Name of owning application */ - boolean Critical; /**< \cfetlmmnemonic \TBL_CRITICAL - \brief Indicates whether table is Critical or not */ - uint8 ByteAlign4; /**< \cfetlmmnemonic \TBL_SPARE4 - \brief Spare byte to maintain byte alignment */ -} CFE_TBL_TblRegPacket_Payload_t; - -typedef struct -{ - uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; /**< \brief cFE Software Bus Telemetry Message Header */ - CFE_TBL_TblRegPacket_Payload_t Payload; -} CFE_TBL_TblRegPacket_t; - -/*************************************************************************/ - -#endif /* _cfe_tbl_msg_ */ - -/************************/ -/* End of File Comment */ -/************************/ diff --git a/src/components/interface/cFE/cfe_time.h b/src/components/interface/cFE/cfe_time.h deleted file mode 100644 index 3362ac5349..0000000000 --- a/src/components/interface/cFE/cfe_time.h +++ /dev/null @@ -1,939 +0,0 @@ -/* -** $Id: cfe_time.h 1.6 2014/08/17 17:23:30GMT-05:00 sstrege Exp $ -** -** Purpose: cFE Time Services (TIME) library API header file -** -** Author: S.Walling/Microtel -** -** Notes: -** -** $Log: cfe_time.h $ -** Revision 1.6 2014/08/17 17:23:30GMT-05:00 sstrege -** Fixed doxygen compiler warnings. -** Revision 1.5 2011/11/30 15:10:46EST jmdagost -** Replaced ifdef/ifndef preprocessor tests with if...==TRUE/if...!=TRUE tests -** Revision 1.4 2008/12/08 12:07:21EST dkobe -** Updates to correct doxygen errors -** Revision 1.3 2008/08/07 09:17:43EDT dkobe -** Doxygen comments corrected for CFE_TIME_RegisterSynchCallback -** and CFE_TIME_UnregisterSynchCallback -** Revision 1.2 2008/08/06 22:42:28EDT dkobe -** Added CFE_TIME_RegisterSynchCallback, CFE_TIME_UnregisterSynchCallback and CFE_TIME_CleanUpApp -** Revision 1.1 2008/04/17 08:05:25EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.9 2007/05/23 11:22:00EDT David Kobe (dlkobe) -** Added doxygen formatting -** Revision 1.8 2007/03/07 12:03:35EST njyanchik -** There were errors in the previous change package, so I fixed them -** Revision 1.7 2007/03/07 10:43:45EST njyanchik -** I made a new API called CFE_TIME_GetClockInfo that is functionally equivilant to CFE_TIME_GetStateFlags. The reason I made a new function is because this function -** will get changed in a future DCR (3191). -** Revision 1.5 2006/11/21 15:58:50EST rjmcgraw -** Added #define CFE_TIME_PRINTED_STRING_SIZE 24 -** Revision 1.4 2006/11/09 15:25:04EST wfmoleski -** Modified the function prototypes for ExternalMET, ExternalGPS and ExternalTime from int32 to void. -** Revision 1.3 2006/05/04 09:29:00EDT njyanchik -** Added MET to default spacecraft time conversion -** API is CFE_TIME_SysTime_t CFE_TIME_MET2SCTime (CFE_TIME_SysTime_t METTime) -** Revision 1.2 2005/07/21 15:28:21EDT lswalling -** Add Time print API function -** Revision 1.1 2005/06/09 10:57:51EDT rperera -** Initial revision -*/ - -/* -** Ensure that header is included only once... -*/ -#ifndef _cfe_time_ -#define _cfe_time_ - - -/* -** Required header files... -*/ -#include "common_types.h" - - -/* -** Defines -*/ -#define CFE_TIME_PRINTED_STRING_SIZE 24 /**< \brief Required size of buffer to be passed into #CFE_TIME_Print (includes null terminator) */ - -/* -** Type definition (system time)... -*/ -/** -** \brief Data structure used to hold system time values -** -** \par Description -** The #CFE_TIME_SysTime_t data structure is used to hold time -** values. Time is referred to as the elapsed time (in seconds -** and subseconds) since a specified epoch time. The subseconds -** field contains the number of 2^(-32) second intervals that have -** elapsed since the epoch. -** -*/ -typedef struct -{ - uint32 Seconds; /**< \brief Number of seconds since epoch */ - uint32 Subseconds; /**< \brief Number of subseconds since epoch (LSB = 2^(-32) seconds) */ -} CFE_TIME_SysTime_t; - -/* -** Type definition (clock state)... -*/ -/** -** \brief Enumerated types identifying the quality of the current time -** -** \par Description -** The #CFE_TIME_ClockState_t enumerations identify the three recognized states of the current time. -** If the clock has never been successfully synchronized with the primary onboard clock source, the -** time is conisdered to be #CFE_TIME_INVALID. If the time is currently synchronized (i.e. - the -** primary synchronization mechanism has not been dropped for any significant amount of time), then -** the current time is considered to be #CFE_TIME_VALID. If the time had, at some point in the past, -** been synchronized, but the synchronization with the primary onboard clock has since been lost, then -** the time is considered to be #CFE_TIME_FLYWHEEL. Since different clocks drift at different rates -** from one another, the accuracy of the time while in #CFE_TIME_FLYWHEEL is dependent upon the time -** spent in that state. -*/ -typedef enum -{ - CFE_TIME_INVALID = -1, /**< The spacecraft time has not been set since the last clock - ** reset. Times returned by clock routines have no relationship - ** to any ground-based time reference. - */ - CFE_TIME_VALID = 0, /**< The spacecraft time has been set at least once since the last - ** clock reset, and it is synchronized with the primary on-board - ** time base. Times returned by clock routines can be trusted. - */ - CFE_TIME_FLYWHEEL = 1 /**< The spacecraft time has been set at least once since the last - ** clock reset, but it is not currently synchronized with the - ** primary on-board time base. Times returned by clock routines - ** are a "best guess" based on a non-optimal oscillator. - */ -} CFE_TIME_ClockState_t; - -/* -** Type definition (time comparison results)... -*/ -/** -** \brief Enumerated types identifying the relative relationships of two times -** -** \par Description -** Since time fields contain numbers that are relative to an epoch time, then it is possible for a time value -** to be "negative". This can lead to some confusion about what relationship exists between two time values. -** To resolve this confusion, the cFE provides the API #CFE_TIME_Compare which returns these enumerated values. -*/ -typedef enum -{ - CFE_TIME_A_LT_B = -1, /**< \brief The first specified time is considered to be before the second specified time */ - CFE_TIME_EQUAL = 0, /**< \brief The two specified times are considered to be equal */ - CFE_TIME_A_GT_B = 1 /**< \brief The first specified time is considered to be after the second specified time */ -} CFE_TIME_Compare_t; - -/* -** Type definition (time portion the ES Reset data structure) -*/ -/** -** \brief Time related variables that are maintained through a Processor Reset -** -** \par Description -** The #CFE_TIME_ResetVars_t data structure contains those variables that are maintained -** in an area of memory that is not cleared during a Processor Reset. This allows the -** cFE Time Service to maintain time to the best of its ability after a Processor Reset. -*/ -typedef struct -{ - uint32 Signature; /**< \brief Data validation signature used to verify data structure contents*/ - int16 LeapSeconds; /**< \brief Leap seconds value */ - uint16 ClockSignal; /**< \brief Current clock signal selection */ - CFE_TIME_SysTime_t CurrentMET; /**< \brief Current Mission Elapsed Time (MET) */ - CFE_TIME_SysTime_t CurrentSTCF; /**< \brief Current Spacecraft Time Correlation Factor (STCF) */ - CFE_TIME_SysTime_t CurrentDelay; /**< \brief Current time client delay value */ - -} CFE_TIME_ResetVars_t; - -/** -** \brief Time Synchronization Callback Function Ptr Type -** -** \par Description -** Applications that wish to get direct notification of the receipt of the cFE Time Synchronization signal -** (typically a 1 Hz signal), must register a callback function with the following prototype via the -** #CFE_TIME_RegisterSynchCallback API. -*/ -typedef int32 (*CFE_TIME_SynchCallbackPtr_t)(void); - -/* -** Function prototypes (get time)... -*/ -/*****************************************************************************/ -/** -** \brief Get the current spacecraft time -** -** \par Description -** This routine returns the current spacecraft time. The time returned -** is either TAI (no leap seconds) or UTC (including leap seconds). This choice -** is made in the mission configuration file by defining either #CFE_TIME_CFG_DEFAULT_TAI -** or #CFE_TIME_CFG_DEFAULT_UTC as TRUE at compile time. To maintain re-usability -** across missions, most applications should be using this function -** (or #CFE_TIME_GetTime) rather than the specific routines for getting UTC/TAI directly. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** \retcode #CFE_TIME_SysTime_t \retdesc The current spacecraft time \endcode -** \endreturns -** -** \sa #CFE_TIME_GetTAI, #CFE_TIME_GetUTC, #CFE_TIME_GetMET, -** #CFE_TIME_GetMETseconds, #CFE_TIME_GetMETsubsecs -** -******************************************************************************/ -CFE_TIME_SysTime_t CFE_TIME_GetTime(void); /* returns default time (see default time selection above) */ - -/*****************************************************************************/ -/** -** \brief Get the current TAI time -** -** \par Description -** This routine returns the current TAI time to the caller. TAI is an -** international time standard that does not include leap seconds. -** This routine should only be used in situations where TAI is absolutely -** required. Applications that call #CFE_TIME_GetTAI() may not be portable -** to all missions. Maintenance of correct TAI in flight is not guaranteed -** under all mission operations scenarios. To maintain re-usability across -** missions, most applications should be using #CFE_TIME_GetTime(), rather -** than the specific routines for getting UTC/TAI directly. -** -** \par Assumptions, External Events, and Notes: -** -# The "TAI" time returned is referenced to the mission-defined time epoch, -** which may or may not be the same as the standard TAI epoch. -** -# Even though TAI does not include leap seconds, the time returned by this -** function can still jump forward or backward without warning when the -** spacecraft clock is set or adjusted by operators. Applications using -** this function must be able to handle these time discontinuities gracefully. -** -** \returns -** \retcode #CFE_TIME_SysTime_t \retdesc The current TAI time \endcode -** \endreturns -** -** \sa #CFE_TIME_GetTime, #CFE_TIME_GetUTC, #CFE_TIME_GetMET, -** #CFE_TIME_GetMETseconds, #CFE_TIME_GetMETsubsecs -** -******************************************************************************/ -CFE_TIME_SysTime_t CFE_TIME_GetTAI(void); /* returns time computed as TAI (MET + STCF) */ - -/*****************************************************************************/ -/** -** \brief Get the current UTC time -** -** \par Description -** This routine returns the current UTC time to the caller. This routine -** should only be used in situations where UTC is absolutely required. -** Applications that call #CFE_TIME_GetUTC() may not be portable to all -** missions. Maintenance of correct UTC in flight is not guaranteed under -** all mission operations scenarios. If UTC is maintained in flight, it will -** jump backwards occasionally due to leap second adjustments. To maintain -** re-usability across missions, most applications should be using -** #CFE_TIME_GetTime(), rather than the specific routines for getting -** UTC/TAI directly. -** -** \par Assumptions, External Events, and Notes: -** Note: The "UTC" time returned is referenced to the mission-defined time epoch, -** which may or may not be the same as the standard UTC epoch. -** -** \returns -** \retcode #CFE_TIME_SysTime_t \retdesc The current UTC time \endcode -** \endreturns -** -** \sa #CFE_TIME_GetTime, #CFE_TIME_GetTAI, #CFE_TIME_GetMET, -** #CFE_TIME_GetMETseconds, #CFE_TIME_GetMETsubsecs -** -******************************************************************************/ -CFE_TIME_SysTime_t CFE_TIME_GetUTC(void); /* returns time computed as UTC (MET + STCF - Leap Seconds) */ - -/*****************************************************************************/ -/** -** \brief Convert specified MET into Spacecraft Time -** -** \par Description -** This function returns Spacecraft Time given MET. Note that Spacecraft -** Time is returned as either UTC or TAI depeneding on whether the mission -** configuration parameter #CFE_TIME_CFG_DEFAULT_UTC or #CFE_TIME_CFG_DEFAULT_TAI -** was set to TRUE at compile time. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] METTime The MET to be converted. -** -** \returns -** \retcode #CFE_TIME_SysTime_t \retdesc Spacecraft Time (UTC or TAI) corresponding to the specified MET \endcode -** \endreturns -** -** \sa #CFE_TIME_GetMET, #CFE_TIME_GetMETseconds, #CFE_TIME_GetMETsubsecs, -** #CFE_TIME_Sub2MicroSecs, #CFE_TIME_Micro2SubSecs, #CFE_TIME_CFE2FSSeconds, #CFE_TIME_FS2CFESeconds -** -******************************************************************************/ -CFE_TIME_SysTime_t CFE_TIME_MET2SCTime (CFE_TIME_SysTime_t METTime); /* returns given MET time as the default spacecraft time */ - -/* -** Function prototypes (get parts of time)... -*/ - -/*****************************************************************************/ -/** -** \brief Get the current value of the spacecraft time correction factor (STCF). -** -** \par Description -** This routine returns the current value of the spacecraft time correction -** factor. This is the delta time between the MET and the TAI time. -** Applications cannot set or adjust the STCF; that can only be done -** through ground commands. However, science applications may want to -** include the STCF in their data products to aid in time correlation -** during downstream science data processing. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** \retcode #CFE_TIME_SysTime_t \retdesc The current STCF \endcode -** \endreturns -** -** \sa #CFE_TIME_GetLeapSeconds, #CFE_TIME_GetClockState, #CFE_TIME_GetClockInfo -** -******************************************************************************/ -CFE_TIME_SysTime_t CFE_TIME_GetSTCF(void); /* returns STCF (does not include leap seconds calculation) */ - -/*****************************************************************************/ -/** -** \brief Get the current value of the Mission Elapsed Time (MET). -** -** \par Description -** This routine returns the current mission-elapsed time (MET). MET is -** usually derived from a hardware-based clock that is not adjusted -** during normal operations. Callers of this routine should not assume -** that the MET return value has any specific relationship to any -** ground-based time standard. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** \retcode #CFE_TIME_SysTime_t \retdesc The current MET \endcode -** \endreturns -** -** \sa #CFE_TIME_GetTime, #CFE_TIME_GetTAI, #CFE_TIME_GetUTC, -** #CFE_TIME_GetMETseconds, #CFE_TIME_GetMETsubsecs, #CFE_TIME_MET2SCTime -** -******************************************************************************/ -CFE_TIME_SysTime_t CFE_TIME_GetMET(void); /* returns MET (both seconds and sub-seconds) */ - - -/*****************************************************************************/ -/** -** \brief Get the current seconds count of the mission-elapsed time. -** -** \par Description -** This routine is the same as #CFE_TIME_GetMET(), except that it -** returns only the integer seconds portion of the MET time. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** \retstmt The current MET seconds \endstmt -** \endreturns -** -** \sa #CFE_TIME_GetTime, #CFE_TIME_GetTAI, #CFE_TIME_GetUTC, #CFE_TIME_GetMET, -** #CFE_TIME_GetMETsubsecs, #CFE_TIME_MET2SCTime -** -******************************************************************************/ -uint32 CFE_TIME_GetMETseconds(void); /* returns MET "seconds" portion of current time */ - -/*****************************************************************************/ -/** -** \brief Get the current sub-seconds count of the mission-elapsed time. -** -** \par Description -** This routine is the same as #CFE_TIME_GetMET(), except that it -** returns only the integer sub-seconds portion of the MET time. -** Each count is equal to 2^(-32) seconds. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** \retstmt The current MET sub-seconds \endstmt -** \endreturns -** -** \sa #CFE_TIME_GetTime, #CFE_TIME_GetTAI, #CFE_TIME_GetUTC, #CFE_TIME_GetMET, -** #CFE_TIME_GetMETseconds, #CFE_TIME_MET2SCTime -** -******************************************************************************/ -uint32 CFE_TIME_GetMETsubsecs(void); /* returns MET "sub-seconds" portion of current time */ - -/*****************************************************************************/ -/** -** \brief Get the current value of the leap seconds counter. -** -** \par Description -** This routine returns the current value of the leap seconds counter. -** This is the delta seconds between international atomic time (TAI) -** and universal coordinated time (UTC). Applications cannot set or -** adjust the leap seconds; that can only be done through ground commands. -** However, science applications may want to include the leap seconds -** counter in their data products to aid in time correlation during -** downstream science data processing. Note that some mission operations -** teams do not maintain the leap seconds count, preferring to adjust the -** STCF instead. Users of this function should check with their mission -** ops team to see how they are planning to handle leap seconds. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** \retstmt The current leap seconds. \endstmt -** \endreturns -** -** \sa #CFE_TIME_GetSTCF, #CFE_TIME_GetClockState, #CFE_TIME_GetClockInfo -** -******************************************************************************/ -int16 CFE_TIME_GetLeapSeconds(void); /* returns Leap Seconds portion of current time */ - -/* -** Function prototypes (get time status)... -*/ - -/*****************************************************************************/ -/** -** \brief Get the current state of the spacecraft clock. -** -** \par Description -** This routine returns the spacecraft clock state. Applications that -** are highly dependent on valid time may want to call this routine -** before taking actions based on the times returned by the various -** clock routines -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** \retcode #CFE_TIME_ClockState_t \retdesc The current spacecraft clock state \endcode -** \endreturns -** -** \sa #CFE_TIME_GetSTCF, #CFE_TIME_GetLeapSeconds, #CFE_TIME_GetClockInfo -** -******************************************************************************/ -CFE_TIME_ClockState_t CFE_TIME_GetClockState(void); /* returns current spacecraft clock state */ - -/*****************************************************************************/ -/** -** \brief Provides information about the spacecraft clock. -** -** \par Description -** This routine returns information on the spacecraft clock in a bit mask. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** \retstmt Spacecraft clock information. To extract the information from the -** returned value, the following masks can be used as in the following:
-** if ((ReturnValue & CFE_TIME_FLAG_xxxxxx) == CFE_TIME_FLAG_xxxxxx) then -** the following definition of the \c CFE_TIME_FLAG_xxxxxx is true.
\endstmt -** \retcode #CFE_TIME_FLAG_CLKSET \retdesc \copydoc CFE_TIME_FLAG_CLKSET \endcode -** \retcode #CFE_TIME_FLAG_FLYING \retdesc \copydoc CFE_TIME_FLAG_FLYING \endcode -** \retcode #CFE_TIME_FLAG_SRCINT \retdesc \copydoc CFE_TIME_FLAG_SRCINT \endcode -** \retcode #CFE_TIME_FLAG_SIGPRI \retdesc \copydoc CFE_TIME_FLAG_SIGPRI \endcode -** \retcode #CFE_TIME_FLAG_SRVFLY \retdesc \copydoc CFE_TIME_FLAG_SRVFLY \endcode -** \retcode #CFE_TIME_FLAG_CMDFLY \retdesc \copydoc CFE_TIME_FLAG_CMDFLY \endcode -** \retcode #CFE_TIME_FLAG_ADDADJ \retdesc \copydoc CFE_TIME_FLAG_ADDADJ \endcode -** \retcode #CFE_TIME_FLAG_ADD1HZ \retdesc \copydoc CFE_TIME_FLAG_ADD1HZ \endcode -** \retcode #CFE_TIME_FLAG_ADDTCL \retdesc \copydoc CFE_TIME_FLAG_ADDTCL \endcode -** \retcode #CFE_TIME_FLAG_SERVER \retdesc \copydoc CFE_TIME_FLAG_SERVER \endcode -** \retcode #CFE_TIME_FLAG_GDTONE \retdesc \copydoc CFE_TIME_FLAG_GDTONE \endcode -** \retcode #CFE_TIME_FLAG_UNUSED \retdesc \copydoc CFE_TIME_FLAG_UNUSED \endcode -** \endreturns -** -** \sa #CFE_TIME_GetSTCF, #CFE_TIME_GetLeapSeconds, #CFE_TIME_GetClockState -** -******************************************************************************/ -uint16 CFE_TIME_GetClockInfo(void); /* returns clock information */ - - -/* -** Function prototypes (add/subtract/compare time)... -*/ - -/*****************************************************************************/ -/** -** \brief Adds two time values -** -** \par Description -** This routine adds the two specified times and returns the result. -** Normally, at least one of the input times should be a value representing -** a delta time. Adding two absolute times together will not cause an error, -** but the result will probably be meaningless. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] Time1 The first time to be added. -** -** \param[in] Time2 The second time to be added. -** -** \returns -** \retstmt The sum of the two times, in the #CFE_TIME_SysTime_t format described above. -** If the sum is greater than the maximum value that can be stored in a -** #CFE_TIME_SysTime_t, the result will roll over (this is not considered an error). \endstmt -** \endreturns -** -** \sa #CFE_TIME_Subtract, #CFE_TIME_Compare -** -******************************************************************************/ -CFE_TIME_SysTime_t CFE_TIME_Add(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Time2); /* (Time1 + Time2) */ - -/*****************************************************************************/ -/** -** \brief Subtracts two time values -** -** \par Description -** This routine subtracts time2 from time1 and returns the result. The -** time values can represent either absolute or delta times, but not all -** combinations make sense. -** - AbsTime - AbsTime = DeltaTime -** - AbsTime - DeltaTime = AbsTime -** - DeltaTime - DeltaTime = DeltaTime -** - DeltaTime - AbsTime = garbage -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] Time1 The base time. -** -** \param[in] Time2 The time to be subtracted from the base time. -** -** \returns -** \retstmt The result of subtracting the two times, in the #CFE_TIME_SysTime_t -** format. If the subtraction results in an underflow, the result will -** roll over (this is not considered an error). \endstmt -** \endreturns -** -** \sa #CFE_TIME_Add, #CFE_TIME_Compare -** -******************************************************************************/ -CFE_TIME_SysTime_t CFE_TIME_Subtract(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Time2); /* (Time1 - Time2) */ - -/*****************************************************************************/ -/** -** \brief Compares two time values -** -** \par Description -** This routine compares two time values to see which is "greater". It -** is important that applications use this function rather than trying -** to directly compare the component pieces of times. This function will -** handle roll-over cases seamlessly, which may not be intuitively obvious. -** The cFE's internal representation of time "rolls over" when the 32 bit -** seconds count reaches 0xFFFFFFFF. Also, subtracting a delta time from -** an absolute time close to the epoch could result in "roll under". The -** strange cases that result from these situations can be handled by defining -** the comparison function for times as follows: -** Plot the two times on the circumference of a circle where 0 is at the -** top and 0x80000000 is at the bottom. If the shortest arc from time A -** to time B runs clockwise around the circle, then time A is less than -** time B. If the shortest arc from A to B runs counter-clockwise, then -** time A is greater than time B. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] TimeA The first time to compare. -** -** \param[in] TimeB The second time to compare. -** -** \returns -** \retstmt The result of comparing the two times, one of: \endstmt -** \retcode #CFE_TIME_EQUAL \retdesc \copydoc CFE_TIME_EQUAL \endcode -** \retcode #CFE_TIME_A_GT_B \retdesc \copydoc CFE_TIME_A_GT_B \endcode -** \retcode #CFE_TIME_A_LT_B \retdesc \copydoc CFE_TIME_A_LT_B \endcode -** \endreturns -** -** \sa #CFE_TIME_Add, #CFE_TIME_Subtract -** -******************************************************************************/ -CFE_TIME_Compare_t CFE_TIME_Compare(CFE_TIME_SysTime_t TimeA, CFE_TIME_SysTime_t TimeB); /* (TimeA <=> TimeB) */ - -/* -** Function prototypes (convert sub-seconds)... -*/ - -/*****************************************************************************/ -/** -** \brief Converts a sub-seconds count to an equivalent number of microseconds -** -** \par Description -** This routine converts from a sub-seconds count -** (each tick is 1 / 2^32 seconds) to microseconds (each tick is 1e-06 seconds). -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] SubSeconds The sub-seconds count to convert. -** -** \returns -** \retstmt The equivalent number of microseconds. \endstmt -** \endreturns -** -** \sa #CFE_TIME_MET2SCTime, #CFE_TIME_Micro2SubSecs, -** #CFE_TIME_CFE2FSSeconds, #CFE_TIME_FS2CFESeconds -** -******************************************************************************/ -uint32 CFE_TIME_Sub2MicroSecs(uint32 SubSeconds); /* convert sub-seconds (1/2^32) to micro-seconds (1/1000000) */ - -/*****************************************************************************/ -/** -** \brief Converts a number of microseconds to an equivalent sub-seconds count. -** -** \par Description -** This routine converts from microseconds (each tick is 1e-06 seconds) -** to a subseconds count (each tick is 1 / 2^32 seconds). -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] MicroSeconds The sub-seconds count to convert. -** -** \returns -** \retstmt The equivalent number of subseconds. If the number of microseconds -** passed in is greater than one second, (i.e. > 999,999), the return -** value is equal to \c 0xffffffff. \endstmt -** \endreturns -** -** \sa #CFE_TIME_MET2SCTime, #CFE_TIME_Sub2MicroSecs, -** #CFE_TIME_CFE2FSSeconds, #CFE_TIME_FS2CFESeconds -** -******************************************************************************/ -uint32 CFE_TIME_Micro2SubSecs(uint32 MicroSeconds); /* convert micro-seconds (1/1000000) to sub-seconds (1/2^32) */ - -/* -** Function prototypes (convert cFE and file system time formats)... -*/ - -/*****************************************************************************/ -/** -** \brief Converts cFE seconds into the File System's seconds -** -** \par Description -** File systems use specific time epochs for their time tagging of files. -** Since spacecraft systems rarely use an epoch that matches a particular -** file system, this function provides a mechanism to translate a given -** spacecraft time (in seconds) to the file system's time. The conversion -** is controlled by the configuration parameter #CFE_TIME_FS_FACTOR which -** is set equal to the number of seconds between the spacecraft's epoch and -** the file system's epoch. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] SecondsCFE The spacecraft time, in seconds, to be converted. -** -** \returns -** \retstmt The equivalent time, in seconds, for the file system. \endstmt -** \endreturns -** -** \sa #CFE_TIME_MET2SCTime, #CFE_TIME_Sub2MicroSecs, #CFE_TIME_Micro2SubSecs, -** #CFE_TIME_FS2CFESeconds -** -******************************************************************************/ -uint32 CFE_TIME_CFE2FSSeconds(uint32 SecondsCFE); - -/*****************************************************************************/ -/** -** \brief Converts a file system's seconds into cFE seconds -** -** \par Description -** File systems use specific time epochs for their time tagging of files. -** Since spacecraft systems rarely use an epoch that matches a particular -** file system, this function provides a mechanism to translate a file -** system time (in seconds) into the spacecraft time (in seconds). The -** conversion is controlled by the configuration parameter #CFE_TIME_FS_FACTOR -** which is set equal to the number of seconds between the spacecraft's epoch and -** the file system's epoch. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] SecondsFS The file system time, in seconds, to be converted. -** -** \returns -** \retstmt The equivalent time, in seconds, for the spacecraft. \endstmt -** \endreturns -** -** \sa #CFE_TIME_MET2SCTime, #CFE_TIME_Sub2MicroSecs, #CFE_TIME_Micro2SubSecs, -** #CFE_TIME_CFE2FSSeconds -** -******************************************************************************/ -uint32 CFE_TIME_FS2CFESeconds(uint32 SecondsFS); - -/* -** Function prototypes (convert time to string)... -*/ - -/*****************************************************************************/ -/** -** \brief Print a time value as a string -** -** \par Description -** This routine prints the specified time to the specified string buffer -** in the following format:

-** \c yyyy-ddd-hh:mm:ss.xxxxx\\0

-** where: -** - \c yyyy = year -** - \c ddd = Julian day of the year -** - \c hh = hour of the day (0 to 23) -** - \c mm = minute (0 to 59) -** - \c ss = second (0 to 59) -** - \c xxxxx = subsecond formatted as a decimal fraction (1/4 second = 0.25000) -** - \c \\0 = trailing null -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] PrintBuffer Pointer to a character array of at least -** #CFE_TIME_PRINTED_STRING_SIZE characters in length -** -** \param[in] TimeToPrint The time to print into the character array. -** -** \param[out] *PrintBuffer The time as a character string as described above. -** -** \sa -** -******************************************************************************/ -void CFE_TIME_Print(char *PrintBuffer, CFE_TIME_SysTime_t TimeToPrint); - -/* -** Function prototypes (1hz tone signal processor)... -*/ - -/*****************************************************************************/ -/** -** \brief Provides the 1 Hz signal from an external source -** -** \par Description -** This routine provides a method for cFE TIME software to be notified -** of the occurance of the 1Hz tone signal without knowledge of the -** specific hardware design. Regardless of the source of the tone, -** this routine should be called as soon as possible after detection -** to allow cFE TIME software the opportunity to latch the local clock -** as close as possible to the instant of the tone. -** -** \par Assumptions, External Events, and Notes: -** - This routine may be called directly from within the context of an -** interrupt handler. -** -** \sa #CFE_TIME_ExternalMET, #CFE_TIME_ExternalGPS, #CFE_TIME_ExternalTime -** -******************************************************************************/ -void CFE_TIME_ExternalTone(void); /* OK to call from ISR */ - -/* -** Function prototypes (external time source)... -** -** If a Time Server has been configured to accept external time -** data, then one of the following functions will be enabled. -** -** If the Time Server has also been commanded to use the external -** time data (as opposed to getting time data from a local MET) -** then the Time Server will use the external data in computing -** time. -** -** However, regardless whether the external time data is accepted -** by the Time Server, these functions also act as the signal to -** create and distribute the "time at the tone" command packet. -*/ - - -/*****************************************************************************/ -/** -** \brief Provides the Mission Elapsed Time from an external source -** -** \par Description -** This routine provides a method to provide cFE TIME with MET acquired -** from an external source. There is a presumption that this function -** will be called at the appropriate time (relative to the tone) such -** that this call may be used by cFE TIME as the signal to generate the -** "time at the tone" data command. The "time at the tone" data command -** must arrive within the configuration parameter specified window for -** tone signal and data packet verification.

-** The MET value at the tone "should" have zero subseconds. Although the -** interface accepts non-zero values for sub-seconds, it may be harmful -** to other applications that expect zero subseconds at the moment of the -** tone. Any decision to use non-zero subseconds should be carefully considered. -** -** \par Assumptions, External Events, and Notes: -** - This routine is included in the API only when 3 specific configuration -** parameters are set to TRUE. The first is #CFE_TIME_CFG_SERVER which defines -** this instantiation of cFE TIME as a time server (not a client). The -** second required configuration parameter is #CFE_TIME_CFG_SOURCE which -** enables time source selection commands to the cFE TIME task, and further -** enables configuration definitions for the selected type of external time -** data. The third configuration parameter required for this routine is -** #CFE_TIME_CFG_SRC_MET, which indicates that the external time data consists -** of MET. -** -** \param[in] NewMET The MET value at the next (or previous) 1 Hz tone signal. -** -** \sa #CFE_TIME_ExternalTone, #CFE_TIME_ExternalGPS, #CFE_TIME_ExternalTime -** -******************************************************************************/ -void CFE_TIME_ExternalMET(CFE_TIME_SysTime_t NewMET); - - -/*****************************************************************************/ -/** -** \brief Provide the time from an external source that has data common to GPS receivers. -** -** \par Description -** This routine provides a method to provide cFE TIME with current time -** data acquired from an external source. There is a presumption that -** this function will be called at the appropriate time (relative to the -** tone) such that this call may be used by cFE TIME as the signal to -** generate the "time at the tone" data command. The "time at the tone" -** data command must arrive within the configuration parameter specified -** window for tone signal and data packet verification.

-** Internally, cFE TIME will calculate a new STCF as the difference between -** this new time value and the spacecraft MET value at the tone. This allows -** cFE TIME to always calculate time as the sum of MET and STCF. The value -** of STCF will change only as much as the drift factor between spacecraft -** MET and the external time source. -** -** \par Assumptions, External Events, and Notes: -** - This routine is included in the API only when 3 specific configuration -** parameters are set to TRUE. The first is #CFE_TIME_CFG_SERVER which defines this -** instantiation of cFE TIME as a time server (not a client). The second -** required configuration parameter is #CFE_TIME_CFG_SOURCE which enables -** time source selection commands to the cFE TIME task, and further enables -** configuration definitions for the selected type of external time data. -** The third configuration parameter required for this routine is -** #CFE_TIME_CFG_SRC_GPS, which indicates that the external time data consists -** of a time value relative to a known epoch, plus a leap seconds value. -** -** \param[in] NewTime The MET value at the next (or previous) 1 Hz tone signal. -** -** \param[in] NewLeaps The Leap Seconds value used to calculate time as UTC. -** -** \sa #CFE_TIME_ExternalTone, #CFE_TIME_ExternalMET, #CFE_TIME_ExternalTime -** -******************************************************************************/ -void CFE_TIME_ExternalGPS(CFE_TIME_SysTime_t NewTime, int16 NewLeaps); - - - -/*****************************************************************************/ -/** -** \brief Provide the time from an external source that measures time relative to a known epoch. -** -** \par Description -** This routine provides a method to provide cFE TIME with current time -** data acquired from an external source. There is a presumption that -** this function will be called at the appropriate time (relative to the -** tone) such that this call may be used by cFE TIME as the signal to -** generate the "time at the tone" data command. The "time at the tone" -** data command must arrive within the configuration specified window for -** tone signal and data packet verification.

-** Internally, cFE TIME will calculate a new STCF as the difference between -** this new time value and the spacecraft MET value at the tone. This allows -** cFE TIME to always calculate time as the sum of MET and STCF. The value -** of STCF will change only as much as the drift factor between spacecraft -** MET and the external time source. -** -** \par Assumptions, External Events, and Notes: -** - This routine is included in the API only when 3 specific configuration -** parameters are set to TRUE. The first is #CFE_TIME_CFG_SERVER which defines this -** instanciation of cFE TIME as a time server (not a client). The second -** required configuration parameter is #CFE_TIME_CFG_SOURCE which enables -** time source selection commands to the cFE TIME task, and further enables -** configuration definitions for the selected type of external time data. -** The third configuration parameter required for this routine is -** #CFE_TIME_CFG_SRC_TIME, which indicates that the external time data consists -** of a time value relative to a known epoch. -** -** \param[in] NewTime The MET value at the next (or previous) 1 Hz tone signal. -** -** \sa #CFE_TIME_ExternalTone, #CFE_TIME_ExternalMET, #CFE_TIME_ExternalGPS -** -******************************************************************************/ -void CFE_TIME_ExternalTime(CFE_TIME_SysTime_t NewTime); - -/*****************************************************************************/ -/** -** \brief Registers a callback function that is called whenever time synchronization occurs -** -** \par Description -** This routine passes a callback function pointer for an Application that wishes to -** be notified whenever a legitimate time synchronization signal (typically a 1 Hz) -** is received. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_TIME_TOO_MANY_SYNCH_CALLBACKS \retdesc \copydoc CFE_TIME_TOO_MANY_SYNCH_CALLBACKS \endcode -** \retcode #CFE_ES_ERR_APPID \retdesc \copydoc CFE_ES_ERR_APPID \endcode -** \endreturns -** -** \sa #CFE_TIME_UnregisterSynchCallback -** -******************************************************************************/ -int32 CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr); - - -/*****************************************************************************/ -/** -** \brief Unregisters a callback function that is called whenever time synchronization occurs -** -** \par Description -** This routine removes the specified callback function pointer from the list -** of Callback functions that are called whenever a time synchronization (typically -** the 1Hz signal) is received. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** \retcode #CFE_SUCCESS \retdesc \copydoc CFE_SUCCESS \endcode -** \retcode #CFE_TIME_CALLBACK_NOT_REGISTERED \retdesc \copydoc CFE_TIME_CALLBACK_NOT_REGISTERED \endcode -** \retcode #CFE_ES_ERR_APPID \retdesc \copydoc CFE_ES_ERR_APPID \endcode -** \endreturns -** -** \sa #CFE_TIME_RegisterSynchCallback -** -******************************************************************************/ -int32 CFE_TIME_UnregisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr); - - -/*****************************************************************************/ -/** -** \brief This function should be called from the system PSP layer once per second -** -** \par Description -** Drives the time processing logic from the system PSP layer. This must be called -** once per second based on a hardware interrupt or OS kernel signal. -** -** \par Assumptions, External Events, and Notes: -** This will update the global data structures accordingly, incrementing each -** by the 1Hz amount. -** -** -******************************************************************************/ -void CFE_TIME_Local1HzISR(void); - - -#endif /* _cfe_time_ */ - -/************************/ -/* End of File Comment */ -/************************/ diff --git a/src/components/interface/cFE/cfe_time_events.h b/src/components/interface/cFE/cfe_time_events.h deleted file mode 100644 index 209d3df283..0000000000 --- a/src/components/interface/cFE/cfe_time_events.h +++ /dev/null @@ -1,592 +0,0 @@ -/* -** -** Filename: cfe_time_events.h -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -* -** $Id: cfe_time_events.h 1.5 2011/11/30 15:10:44GMT-05:00 jmdagost Exp $ -** -** Purpose: -** cFE Time Services (Time) Event IDs -** -** Design Notes: -** -** References: -** Flight Software Branch C Coding Standard Version 1.0a -** -** -** $Date: 2011/11/30 15:10:44GMT-05:00 $ -** $Revision: 1.5 $ -** $Log $ -*/ - -#ifndef _cfe_time_events_ -#define _cfe_time_events_ - -/* -** Event message ID's... -*/ -/** \brief 'cFE TIME Initialized' -** \event 'cFE TIME Initialized' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always automatically issued when the Time Services -** Task completes its Initialization. -**/ -#define CFE_TIME_INIT_EID 1 /* start up message "informational" */ - -/** \brief 'No-op command' -** \event 'No-op command' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is always automatically issued in response -** to a cFE Time Services \link #CFE_TIME_NOOP_CC NO-OP command \endlink -**/ -#define CFE_TIME_NOOP_EID 4 /* processed command "informational" */ - -/** \brief 'Reset Counters command' -** \event 'Reset Counters command' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is always automatically issued in response -** to a cFE Time Services \link #CFE_TIME_RESET_CC Reset Counters command \endlink -**/ -#define CFE_TIME_RESET_EID 5 - -/** \brief 'Request diagnostics command' -** \event 'Request diagnostics command' -** -** \par Type: DEBUG -** -** \par Cause: -** -** This event message is always automatically issued in response -** to a cFE Time Services \link #CFE_TIME_DIAG_TLM_CC Request Diagnostics command \endlink -**/ -#define CFE_TIME_DIAG_EID 6 - -/** \brief 'Set Clock State = \%s' -** \event 'Set Clock State = \%s' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated upon successful completion -** of a cFE Time Services \link #CFE_TIME_SET_STATE_CC Set Time State command \endlink -** -** The \c '\%s' field will identify whether the command specified -** \c VALID, \c INVALID, or \c FLYWHEEL. -**/ -#define CFE_TIME_STATE_EID 7 - -/** \brief 'Set Time Source = \%s' -** \event 'Set Time Source = \%s' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated upon successful completion -** of a cFE Time Services \link #CFE_TIME_SET_SOURCE_CC Set Time Source command \endlink -** -** The \c '\%s' field will identify whether the command specified -** \c INTERNAL, or \c EXTERNAL. -**/ -#define CFE_TIME_SOURCE_EID 8 - -/** \brief 'Set Tone Source = \%s' -** \event 'Set Tone Source = \%s' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated upon successful completion -** of a cFE Time Services \link #CFE_TIME_SET_SIGNAL_CC Set Clock Signal command \endlink -** -** The \c '\%s' field will identify whether the command specified -** \c PRIMARY, or \c REDUNDANT. -**/ -#define CFE_TIME_SIGNAL_EID 9 - - -/** \brief 'Set Tone Delay -- secs = \%d, usecs = \%d, ssecs = 0x\%X, dir = \%d' -** \event 'Set Tone Delay -- secs = \%d, usecs = \%d, ssecs = 0x\%X, dir = \%d' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated upon successful completion -** of either a cFE Time Services -** \link #CFE_TIME_ADD_DELAY_CC Add Time Delay \endlink OR a -** \link #CFE_TIME_SUB_DELAY_CC Subtract Time Delay command \endlink -** -** The \c secs field specifies the new delay (in seconds), the \c usecs -** field specifies the delay in micro-seconds, the \c ssecs field is -** the micro-seconds field converted to Spacecraft Time sub-seconds and -** the \c dir field identifies the direction of the delay. The direction -** can be either #CFE_TIME_ADD_ADJUST or #CFE_TIME_SUB_ADJUST. -**/ -#define CFE_TIME_DELAY_EID 11 - -/** \brief 'Set Time -- secs = \%d, usecs = \%d, ssecs = 0x\%X' -** \event 'Set Time -- secs = \%d, usecs = \%d, ssecs = 0x\%X' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated upon successful completion -** of a cFE Time Services \link #CFE_TIME_SET_TIME_CC Set Time command \endlink -** -** The \c secs field specifies the new spacecraft time (in seconds), the \c usecs -** field specifies the spacecraft time micro-seconds, the \c ssecs field is -** the micro-seconds field converted to Spacecraft Time sub-seconds -**/ -#define CFE_TIME_TIME_EID 12 - -/** \brief 'Set MET -- secs = \%d, usecs = \%d, ssecs = 0x\%X' -** \event 'Set MET -- secs = \%d, usecs = \%d, ssecs = 0x\%X' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated upon successful completion -** of a cFE Time Services \link #CFE_TIME_SET_MET_CC Set Mission Elapsed Time command \endlink -** -** The \c secs field specifies the new MET (in seconds), the \c usecs -** field specifies the MET micro-seconds, the \c ssecs field is -** the micro-seconds field converted to Spacecraft Time sub-seconds -**/ -#define CFE_TIME_MET_EID 13 - -/** \brief 'Set STCF -- secs = \%d, usecs = \%d, ssecs = 0x\%X' -** \event 'Set STCF -- secs = \%d, usecs = \%d, ssecs = 0x\%X' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated upon successful completion -** of a cFE Time Services \link #CFE_TIME_SET_STCF_CC Set Spacecraft Time -** Correlation Factor command \endlink -** -** The \c secs field specifies the new STCF (in seconds), the \c usecs -** field specifies the STCF micro-seconds, the \c ssecs field is -** the micro-seconds field converted to Spacecraft Time sub-seconds. -**/ -#define CFE_TIME_STCF_EID 14 - -/** \brief 'STCF Adjust -- secs = \%d, usecs = \%d, ssecs = 0x\%X, dir[1=Positive, 2=Negative] = \%d' -** \event 'STCF Adjust -- secs = \%d, usecs = \%d, ssecs = 0x\%X, dir[1=Positive, 2=Negative] = \%d' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated upon successful completion -** of any of the following cFE Time Services STCF Adjustment Commands: -** - \link #CFE_TIME_ADD_ADJUST_CC Add Single STCF Adjustment command \endlink -** - \link #CFE_TIME_SUB_ADJUST_CC Subtract Single STCF Adjustment command \endlink -** -** The \c secs field specifies the number of seconds the STCF is to be adjusted by, -** the \c usecs field specifies the number of micro-seconds, the \c ssecs field is -** the micro-seconds field converted to Spacecraft Time sub-seconds and the \c dir -** field identifies whether the adjustment was added or subtracted. The direction -** can be either #CFE_TIME_ADD_ADJUST or #CFE_TIME_SUB_ADJUST. -**/ -#define CFE_TIME_DELTA_EID 15 - -/** \brief 'STCF 1Hz Adjust -- secs = \%d, ssecs = 0x\%X, dir = \%d' -** \event 'STCF 1Hz Adjust -- secs = \%d, ssecs = 0x\%X, dir = \%d' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated upon successful completion -** of any of the following cFE Time Services STCF Adjustment Commands: -** - \link #CFE_TIME_ADD_1HZADJ_CC Add STCF Adjustment each second command \endlink -** - \link #CFE_TIME_SUB_1HZADJ_CC Subtract STCF Adjustment each second command \endlink -** -** The \c secs field specifies the number of seconds the STCF is to be adjusted by, -** the \c ssecs field specifies the number of sub-seconds (1/2^32 seconds) the STCF -** is to be adjusted by and the \c dir field identifies whether the adjustment was -** added or subtracted. The direction value can be either #CFE_TIME_ADD_ADJUST or -** #CFE_TIME_SUB_ADJUST. -**/ -#define CFE_TIME_1HZ_EID 16 - -/** \brief 'Set Leap Seconds = \%d' -** \event 'Set Leap Seconds = \%d' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated upon successful completion -** of the \link #CFE_TIME_SET_LEAPS_CC Set Leap Seconds command \endlink -** -** The \c \%d field contains the number of seconds the Spacecraft's Leap Seconds -** has been set to. -**/ -#define CFE_TIME_LEAPS_EID 17 - -/** \brief 'Start FLYWHEEL' -** \event 'Start FLYWHEEL' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated whenever the Time Services enters FLYWHEEL mode. -**/ -#define CFE_TIME_FLY_ON_EID 20 /* flywheel state "informational" */ - -/** \brief 'Stop FLYWHEEL' -** \event 'Stop FLYWHEEL' -** -** \par Type: INFORMATION -** -** \par Cause: -** -** This event message is generated whenever the Time Services exits FLYWHEEL mode. -**/ -#define CFE_TIME_FLY_OFF_EID 21 - -#define CFE_TIME_EXIT_ERR_EID 25 /* task termination "error" */ - -/** \brief 'Invalid message ID -- ID = 0x\%X' -** \event 'Invalid message ID -- ID = 0x\%X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** a message from the software bus that is not one of Time Services -** recognized messages. -** -** The \c ID field specifies, in hex, the message ID of the inappropriately -** received message. -**/ -#define CFE_TIME_ID_ERR_EID 26 /* invalid command packet "error" */ - -/** \brief 'Invalid command code -- ID = 0x\%X, CC = \%d' -** \event 'Invalid command code -- ID = 0x\%X, CC = \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** a message from the software bus that contains a unrecognized command -** code in its header.. -** -** The \c ID field specifies, in hex, the message ID of the message containing -** the unrecognized command code, identified, in decimal, by the \c CC field. -**/ -#define CFE_TIME_CC_ERR_EID 27 - -/** \brief 'Invalid Clock State = 0x\%X' -** \event 'Invalid Clock State = 0x\%X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** a \link #CFE_TIME_SET_STATE_CC Set Clock State Command \endlink -** that contains a desired clock state that is none of the following: -** - #CFE_TIME_INVALID -** - #CFE_TIME_VALID -** - #CFE_TIME_FLYWHEEL -** -** The \c State field specifies, in hex, the state value received -** in the command message. -**/ -#define CFE_TIME_STATE_ERR_EID 30 /* processed command "error" */ - -/** \brief 'Invalid Time Source = 0x\%X' -** \event 'Invalid Time Source = 0x\%X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** a \link #CFE_TIME_SET_SOURCE_CC Set Clock Source Command \endlink -** that contains a desired clock source that is none of the following: -** - #CFE_TIME_USE_INTERN -** - #CFE_TIME_USE_EXTERN -** -** The \c Source field specifies, in hex, the source value received -** in the command message. -**/ -#define CFE_TIME_SOURCE_ERR_EID 31 - -/** \brief 'Invalid Tone Source = 0x\%X' -** \event 'Invalid Tone Source = 0x\%X' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** a \link #CFE_TIME_SET_SIGNAL_CC Set Clock Signal Command \endlink -** that contains a desired clock source that is none of the following: -** - #CFE_TIME_TONE_PRI -** - #CFE_TIME_TONE_RED -** -** The \c Source field specifies, in hex, the signal source value received -** in the command message. -**/ -#define CFE_TIME_SIGNAL_ERR_EID 32 - -/** \brief 'Invalid Tone Delay -- secs = \%d, usecs = \%d' -** \event 'Invalid Tone Delay -- secs = \%d, usecs = \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** either a \link #CFE_TIME_ADD_DELAY_CC Add Tone Delay Command \endlink -** OR a \link #CFE_TIME_SUB_DELAY_CC Subtract Tone Delay Command \endlink -** that contains a microsecond field that is greater than or equal to -** 1000000. -** -** The \c secs field specifies, in decimal, the tone signal delay in seconds -** and the \c usecs field specifies, in decimal, the micro-second delay that -** was in error. -**/ -#define CFE_TIME_DELAY_ERR_EID 33 - -/** \brief 'Invalid Time -- secs = \%d, usecs = \%d' -** \event 'Invalid Time -- secs = \%d, usecs = \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** a \link #CFE_TIME_SET_TIME_CC Set Spacecraft Time Command \endlink -** that contains a microsecond field that is greater than or equal to -** 1,000,000. -** -** The \c secs field specifies, in decimal, the spacecraft time in seconds -** and the \c usecs field specifies, in decimal, the micro-second field of -** the spacecraft time that was in error. -**/ -#define CFE_TIME_TIME_ERR_EID 34 - -/** \brief 'Invalid MET -- secs = \%d, usecs = \%d' -** \event 'Invalid MET -- secs = \%d, usecs = \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** a \link #CFE_TIME_SET_MET_CC Set Mission Elapsed Time Command \endlink -** that contains a microsecond field that is greater than or equal to -** 1,000,000. -** -** The \c secs field specifies, in decimal, the MET in seconds -** and the \c usecs field specifies, in decimal, the micro-second field of -** the MET that was in error. -**/ -#define CFE_TIME_MET_ERR_EID 35 - -/** \brief 'Invalid STCF -- secs = \%d, usecs = \%d' -** \event 'Invalid STCF -- secs = \%d, usecs = \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** a \link #CFE_TIME_SET_STCF_CC Set Spacecraft Time Correlation Factor Command \endlink -** that contains a microsecond field that is greater than or equal to -** 1,000,000. -** -** The \c secs field specifies, in decimal, the STCF in seconds -** and the \c usecs field specifies, in decimal, the micro-second field of -** the STCF that was in error. -**/ -#define CFE_TIME_STCF_ERR_EID 36 - -/** \brief 'Invalid STCF Adjust -- secs = \%d, usecs = \%d, dir[1=Positive, 2=Negative] = \%d' -** \event 'Invalid STCF Adjust -- secs = \%d, usecs = \%d, dir[1=Positive, 2=Negative] = \%d' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** either a \link #CFE_TIME_ADD_ADJUST_CC Add Single STCF Adjustment Command \endlink -** OR a \link #CFE_TIME_SUB_ADJUST_CC Subtract Single STCF Adjustment command \endlink -** that contains a microsecond field that is greater than or equal to -** 1,000,000. -** -** The \c secs field specifies the number of seconds the STCF is to be adjusted by, -** the \c usecs field specifies the number of micro-seconds that was in error, the \c dir -** field identifies whether the adjustment was to be added or subtracted. The direction -** can be either #CFE_TIME_ADD_ADJUST or #CFE_TIME_SUB_ADJUST. -**/ -#define CFE_TIME_DELTA_ERR_EID 37 - -/** (obsolete - unused) -**/ -#define CFE_TIME_1HZ_ERR_EID 38 - -/** \brief 'Set Source commands invalid without CFE_TIME_CFG_SOURCE set to TRUE' -** \event 'Set Source commands invalid without CFE_TIME_CFG_SOURCE set to TRUE' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** a \link #CFE_TIME_SET_SOURCE_CC Set Clock Source Command \endlink -** and the Time Services configuration parameter #CFE_TIME_CFG_SOURCE has -** not been set to TRUE in the cfe_platform_cfg.h file. -**/ -#define CFE_TIME_SOURCE_CFG_EID 40 /* cmd disabled per cfg "error" */ - -/** \brief 'Set Signal commands invalid without CFE_TIME_CFG_SIGNAL set to TRUE' -** \event 'Set Signal commands invalid without CFE_TIME_CFG_SIGNAL set to TRUE' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** a \link #CFE_TIME_SET_SIGNAL_CC Set Clock Signal Command \endlink -** and the Time Services configuration parameter #CFE_TIME_CFG_SIGNAL has -** not been set to TRUE in the cfe_platform_cfg.h file. -**/ -#define CFE_TIME_SIGNAL_CFG_EID 41 - -/** \brief 'Set Delay commands invalid without CFE_TIME_CFG_CLIENT set to TRUE' -** \event 'Set Delay commands invalid without CFE_TIME_CFG_CLIENT set to TRUE' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** either a \link #CFE_TIME_ADD_DELAY_CC Add Tone Delay Command \endlink -** OR a \link #CFE_TIME_SUB_DELAY_CC Subtract Tone Delay Command \endlink -** and the Time Services configuration parameter #CFE_TIME_CFG_CLIENT has -** not been set to TRUE in the cfe_platform_cfg.h file. -**/ -#define CFE_TIME_DELAY_CFG_EID 42 - -/** \brief 'Set Time commands invalid without CFE_TIME_CFG_SERVER set to TRUE' -** \event 'Set Time commands invalid without CFE_TIME_CFG_SERVER set to TRUE' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** a \link #CFE_TIME_SET_TIME_CC Set Spacecraft Time Command \endlink -** and the Time Services configuration parameter #CFE_TIME_CFG_SERVER has -** not been set to TRUE in the cfe_platform_cfg.h file. -**/ -#define CFE_TIME_TIME_CFG_EID 43 - -/** \brief 'Set MET commands invalid without CFE_TIME_CFG_SERVER set to TRUE' -** \event 'Set MET commands invalid without CFE_TIME_CFG_SERVER set to TRUE' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** a \link #CFE_TIME_SET_MET_CC Set Mission Elapsed Time Command \endlink -** and the Time Services configuration parameter #CFE_TIME_CFG_SERVER has -** not been set to TRUE in the cfe_platform_cfg.h file. -**/ -#define CFE_TIME_MET_CFG_EID 44 - -/** \brief 'Set STCF commands invalid without CFE_TIME_CFG_SERVER set to TRUE' -** \event 'Set STCF commands invalid without CFE_TIME_CFG_SERVER set to TRUE' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** a \link #CFE_TIME_SET_STCF_CC Set Spacecraft Time Correlation Factor Command \endlink -** and the Time Services configuration parameter #CFE_TIME_CFG_SERVER has -** not been set to TRUE in the cfe_platform_cfg.h file. -**/ -#define CFE_TIME_STCF_CFG_EID 45 - -/** \brief 'Set Leaps commands invalid without CFE_TIME_CFG_SERVER set to TRUE' -** \event 'Set Leaps commands invalid without CFE_TIME_CFG_SERVER set to TRUE' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** a \link #CFE_TIME_SET_LEAPS_CC Set Leap Seconds Command \endlink -** and the Time Services configuration parameter #CFE_TIME_CFG_SERVER has -** not been set to TRUE in the cfe_platform_cfg.h file. -**/ -#define CFE_TIME_LEAPS_CFG_EID 46 - -/** \brief 'STCF Adjust commands invalid without CFE_TIME_CFG_SERVER set to TRUE' -** \event 'STCF Adjust commands invalid without CFE_TIME_CFG_SERVER set to TRUE' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** either a \link #CFE_TIME_ADD_ADJUST_CC Add Single STCF Adjustment Command \endlink -** OR a \link #CFE_TIME_SUB_ADJUST_CC Subtract Single STCF Adjustment command \endlink -** and the Time Services configuration parameter #CFE_TIME_CFG_SERVER has -** not been set to TRUE in the cfe_platform_cfg.h file. -**/ -#define CFE_TIME_DELTA_CFG_EID 47 - -/** \brief '1Hz Adjust commands invalid without CFE_TIME_CFG_SERVER set to TRUE' -** \event '1Hz Adjust commands invalid without CFE_TIME_CFG_SERVER set to TRUE' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated whenever Time Services receives -** either a \link #CFE_TIME_ADD_1HZADJ_CC Add STCF Adjustment each second Command \endlink -** OR a \link #CFE_TIME_SUB_1HZADJ_CC Subtract STCF Adjustment each second command \endlink -** and the Time Services configuration parameter #CFE_TIME_CFG_SERVER has -** not been set to TRUE in the cfe_platform_cfg.h file. -**/ -#define CFE_TIME_1HZ_CFG_EID 48 - - -#endif /* _cfe_time_events_ */ diff --git a/src/components/interface/cFE/cfe_time_msg.h b/src/components/interface/cFE/cfe_time_msg.h deleted file mode 100644 index 87ac20b2f5..0000000000 --- a/src/components/interface/cFE/cfe_time_msg.h +++ /dev/null @@ -1,1187 +0,0 @@ -/* -** $Id: cfe_time_msg.h 1.6 2011/11/30 15:10:45GMT-05:00 jmdagost Exp $ -** -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -* -** Purpose: cFE Time Services (TIME) SB message definitions header file -** -** Author: S.Walling/Microtel -** -** Notes: -** -** $Log: cfe_time_msg.h $ -** Revision 1.6 2011/11/30 15:10:45GMT-05:00 jmdagost -** Replaced ifdef/ifndef preprocessor tests with if...==TRUE/if...!=TRUE tests -** Revision 1.5 2010/10/25 15:01:13EDT jmdagost -** Corrected bad apostrophe in prologue. -** Revision 1.4 2010/10/04 15:25:01EDT jmdagost -** Cleaned up copyright symbol. -** Revision 1.3 2009/06/08 16:13:08EDT lwalling -** Change 1Hz adjust cmd arg from micro-seconds to sub-seconds -** Revision 1.2 2008/12/08 12:07:17EST dkobe -** Updates to correct doxygen errors -** Revision 1.1 2008/04/17 08:05:26EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.12 2007/09/12 09:46:04EDT David Kobe (dlkobe) -** Added doxygen comments to commands and some configuration parameters -** Revision 1.11 2007/06/07 13:07:49EDT dlkobe -** Added Command and Telemetry doxygen comments to TIME, EVS and SB -** Revision 1.10 2007/05/23 11:22:01EDT dlkobe -** Added doxygen formatting -** Revision 1.9 2007/04/27 12:31:07EDT njyanchik -** I changed EVS and TIME to not have a telemetry counter for SB pipe reads in the main loop. -** Instead, I have added a syslog message to state the problem -** Revision 1.8 2007/04/11 11:02:10EDT njyanchik -** Remove the TaskDelay in the main loop for TIME. I also addeda counterin telemtry that will -** notify the ground of an error in reading the command pipe. -** Revision 1.7 2007/03/07 12:03:37EST njyanchik -** There were errors in the previous change package, so I fixed them -** -*/ - -/* -** Ensure that header is included only once... -*/ -#ifndef _cfe_time_msg_ -#define _cfe_time_msg_ - -/* -** Required header files... -*/ -#include "cfe.h" - -/*************************************************************************/ - -/* -** Time task command packet command codes... -*/ -/** \name Time Services Command Codes */ -/** \{ */ - -/** \cfetimecmd Time No-Op -** -** \par Description -** This command performs no other function than to increment the -** command execution counter. The command may be used to verify -** general aliveness of the Time Services task. -** -** \cfecmdmnemonic \TIME_NOOP -** -** \par Command Structure -** #CFE_TIME_NoArgsCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will increment -** - The #CFE_TIME_NOOP_EID informational event message will be generated -** -** \par Error Conditions -** There are no error conditions for this command. If the Time -** Services receives the command, the event is sent (although it -** may be filtered by EVS) and the counter is incremented -** unconditionally. -** -** \par Criticality -** None -** -** \sa -*/ -#define CFE_TIME_NOOP_CC 0 /* no-op command */ - -/** \cfetimecmd Time Reset Counters -** -** \par Description -** This command resets the following counters within the Time -** Services \link CFE_TIME_HkPacket_t Housekeeping Telemetry \endlink: -** - Command Execution Counter (\TIME_CMDPC) -** - Command Error Counter (\TIME_CMDEC) -** This command also resets the following counters within the -** Time Services \link CFE_TIME_DiagPacket_t Diagnostic Telemetry \endlink: -** - Tone Signal Detected Software Bus Message Counter (\TIME_TSDETCNT) -** - Time at the Tone Data Software Bus Message Counter (\TIME_TATTCNT) -** - Tone Signal/Data Verify Counter (\TIME_VERIFYCNT) -** - Tone Signal/Data Error Counter (\TIME_VERIFYER) -** - Tone Signal Interrupt Counter (\TIME_TSISRCNT) -** - Tone Signal Interrupt Error Counter (\TIME_TSISRERR) -** - Tone Signal Task Counter (\TIME_TSTASKCNT) -** - Local 1 Hz Interrupt Counter (\TIME_1HZISRCNT) -** - Local 1 Hz Task Counter (\TIME_1HZTASKCNT) -** - Reference Time Version Counter (\TIME_VERSIONCNT) -** -** \cfecmdmnemonic \TIME_RESETCTRS -** -** \par Command Structure -** #CFE_TIME_NoArgsCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will increment -** - The #CFE_TIME_RESET_EID informational event message will be generated -** -** \par Error Conditions -** There are no error conditions for this command. If the Time -** Services receives the command, the event is sent (although it -** may be filtered by EVS) and the counter is incremented -** unconditionally. -** -** \par Criticality -** None -** -** \sa -*/ -#define CFE_TIME_RESET_CC 1 /* reset counters */ - -/** \cfetimecmd Request TIME Diagnostic Telemetry -** -** \par Description -** This command requests that the Time Service generate a message -** containing various data values not included in the normal Time -** Service housekeeping message. The command requests only a single -** copy of the diagnostic message. Refer to #CFE_TIME_DiagPacket_t for -** a description of the Time Service diagnostic message contents. -** -** \cfecmdmnemonic \TIME_REQUESTDIAG -** -** \par Command Structure -** #CFE_TIME_NoArgsCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will increment -** - Sequence Counter for #CFE_TIME_DiagPacket_t will increment -** - The #CFE_TIME_DIAG_EID debug event message will be generated -** -** \par Error Conditions -** There are no error conditions for this command. If the Time -** Services receives the command, the event and telemetry is sent -** (although one or both may be filtered by EVS and TO) and the -** counter is incremented unconditionally. -** -** \par Criticality -** None -** -** \sa -*/ -#define CFE_TIME_DIAG_TLM_CC 2 /* request diagnostic hk telemetry */ - -/** \cfetimecmd Set Time Source -** -** \par Description -** This command selects the Time Service clock source. Although the -** list of potential clock sources is mission specific and defined -** via configuration parameters, this command provides a common method -** for switching between the local processor clock and an external -** source for time data.

-** When commanded to accept external time data (GPS, MET, spacecraft -** time, etc.), the Time Server will enable input via an API function -** specific to the configuration definitions for the particular source. -** When commanded to use internal time data, the Time Server will ignore -** the external data. However, the Time Server will continue to use the -** API function as the trigger to generate a "time at the tone" command -** packet regardless of the internal/external command selection.

-** Notes: -** - Operating in FLYWHEEL mode is not considered a choice related -** to clock source, but rather an element of the clock state. See below -** for a description of the #CFE_TIME_SET_STATE_CC command. -** - This command is only valid when the #CFE_TIME_CFG_SOURCE configuration -** parameter in the cfe_platform_cfg.h file has been set to TRUE. -** -** \cfecmdmnemonic \TIME_SETSOURCE -** -** \par Command Structure -** #CFE_TIME_SourceCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will increment -** - \b \c \TIME_SOURCE - Diagnostic Telemetry point will indicate the -** command specified value -** - The #CFE_TIME_SOURCE_EID informational event message will be generated -** -** \par Error Conditions -** - Invalid Source selection -** (a value other than #CFE_TIME_USE_INTERN or #CFE_TIME_USE_EXTERN was specified) -** - Time source selection not allowed on this platform -**

Evidence of failure may be found in the following telemetry: -** - \b \c \TIME_CMDEC - Command Error counter will increment -** - Error specific event message (either #CFE_TIME_SOURCE_CFG_EID or #CFE_TIME_SOURCE_ERR_EID) -** -** \par Criticality -** Although clock source selection is important, this command is not critical. -** -** \sa #CFE_TIME_SET_STATE_CC, #CFE_TIME_SET_SIGNAL_CC -*/ -#define CFE_TIME_SET_SOURCE_CC 3 /* set clock source (int vs ext) */ - -/** \cfetimecmd Set Time State -** -** \par Description -** This command indirectly affects the Time Service on-board determination -** of clock state. Clock state is a combination of factors, most significantly -** whether the spacecraft time has been accurately set, and whether Time Service -** is operating in FLYWHEEL mode.

-** This command may be used to notify the Time Server that spacecraft time is -** now correct, or that time is no longer correct. This information will be -** distributed to Time Clients, and in turn, to any interested sub-systems.

-** Also, this command may be used to force a Time Server or Time Client into -** FLYWHEEL mode. Use of FLYWHEEL mode is mainly for debug purposes although -** in extreme circumstances, it may be of value to force Time Service not to rely -** on normal time updates. Note that when commanded into FLYWHEEL mode, the Time -** Service will remain so until receipt of another "set state" command setting the -** state into a mode other than FLYWHEEL.

-** Note also that setting the clock state to VALID or INVALID on a Time Client that -** is currently getting time updates from the Time Server will have very limited -** effect. As soon as the Time Client receives the next time update, the VALID/INVALID -** selection will be set to that of the Time Server. However, setting a Time Client -** to FLYWHEEL cannot be overridden by the Time Server since the Time Client will -** ignore time updates from the Time Server while in FLYWHEEL mode. -** -** \cfecmdmnemonic \TIME_SETSTATE -** -** \par Command Structure -** #CFE_TIME_StateCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will increment -** - \b \c \TIME_STATEFLG - Housekeeping Telemetry point "may"l indicate the -** command specified value (see above) -** - The #CFE_TIME_STATE_EID informational event message will be generated -** -** \par Error Conditions -** - Invalid State selection -** (a value other than #CFE_TIME_INVALID, #CFE_TIME_VALID or #CFE_TIME_FLYWHEEL was specified) -** - Time source selection not allowed on this platform -**

Evidence of failure may be found in the following telemetry: -** - \b \c \TIME_CMDEC - Command Error counter will increment -** - Error specific event message (#CFE_TIME_STATE_ERR_EID) -** -** \par Criticality -** Setting Time Service into FLYWHEEL mode is not particularly hazardous, as -** the result may be that the calculation of spacecraft time is done using a -** less than optimal timer. However, inappropriately setting the clock state -** to VALID (indicating that spacecraft time is accurate) may result in other -** sub-systems performing incorrect time based calculations. The specific risk -** is dependent upon the behavior of those sub-systems. -** -** \sa #CFE_TIME_SET_SOURCE_CC, #CFE_TIME_SET_SIGNAL_CC -*/ -#define CFE_TIME_SET_STATE_CC 4 /* set clock state */ - -/** \cfetimecmd Add Time to Tone Time Delay -** -** \par Description -** This command is used to factor out a known, predictable latency between the -** Time Server and a particular Time Client. The correction is applied (added) -** to the current time calculation for Time Clients, so this command has no -** meaning for Time Servers. Each Time Client can have a unique latency setting. -** The latency value is a positive number of seconds and microseconds that represent -** the deviation from the time maintained by the Time Server. -** -** \cfecmdmnemonic \TIME_ADDCLOCKLAT -** -** \par Command Structure -** #CFE_TIME_TimeCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will increment -** - \b \c \TIME_LATENTS - Housekeeping Telemetry point indicating command specified values -** - \b \c \TIME_LATENTDIR - Diagnostic Telemetry point indicating commanded latency direction -** - The #CFE_TIME_DELAY_EID informational event message will be generated -** -** \par Error Conditions -** - An invalid number of microseconds was specified (must be less than 1 million) -** - Platorm receiving the command is not a Time Client -**

Evidence of Failure may be found in the following telemetry: -** - \b \c \TIME_CMDEC - command error counter will increment -** - Error specific event messages will be issued (#CFE_TIME_DELAY_CFG_EID or #CFE_TIME_DELAY_ERR_EID) -** -** \par Criticality -** Inappropriately setting the clock may result in other sub-systems performing incorrect -** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. -** -** \sa #CFE_TIME_SUB_DELAY_CC -*/ -#define CFE_TIME_ADD_DELAY_CC 5 /* add tone delay value */ - -/** \cfetimecmd Subtract Time from Tone Time Delay -** -** \par Description -** This command is used to factor out a known, predictable latency between the Time Server -** and a particular Time Client. The correction is applied (subtracted) to the current time -** calculation for Time Clients, so this command has no meaning for Time Servers. Each Time -** Client can have a unique latency setting. The latency value is a positive number of seconds -** and microseconds that represent the deviation from the time maintained by the Time Server.

-** Note that it is unimaginable that the seconds value will ever be anything but zero. -** -** \cfecmdmnemonic \TIME_SUBCLOCKLAT -** -** \par Command Structure -** #CFE_TIME_TimeCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will increment -** - \b \c \TIME_LATENTS - Housekeeping Telemetry point indicating command specified values -** - \b \c \TIME_LATENTDIR - Diagnostic Telemetry point indicating commanded latency direction -** - The #CFE_TIME_DELAY_EID informational event message will be generated -** -** \par Error Conditions -** - An invalid number of microseconds was specified (must be less than 1 million) -** - Platorm receiving the command is not a Time Client -**

Evidence of Failure may be found in the following telemetry: -** - \b \c \TIME_CMDEC - command error counter will increment -** - Error specific event messages will be issued (#CFE_TIME_DELAY_CFG_EID or #CFE_TIME_DELAY_ERR_EID) -** -** \par Criticality -** Inappropriately setting the clock may result in other sub-systems performing incorrect -** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. -** -** \sa #CFE_TIME_ADD_DELAY_CC -*/ -#define CFE_TIME_SUB_DELAY_CC 6 /* sub tone delay value */ - -/** \cfetimecmd Set Spacecraft Time -** -** \par Description -** This command sets the spacecraft clock to a new value, -** regardless of the current setting (time jam). The new time -** value represents the desired offset from the mission-defined -** time epoch and takes effect immediately upon execution of -** this command. Time Service will calculate a new STCF value -** based on the current MET and the desired new time using one -** of the following:

-** If Time Service is configured to compute current time as TAI
-** - STCF = (new time) - (current MET) -** - (current time) = (current MET) + STCF -**

If Time Service is configured to compute current time as UTC -** - STCF = ((new time) - (current MET)) + (Leap Seconds) -** - (current time) = ((curent MET) + STCF) - (Leap Seconds) -** -** \cfecmdmnemonic \TIME_SETCLOCK -** -** \par Command Structure -** #CFE_TIME_TimeCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will increment -** - \b \c \TIME_STCFSECS - Housekeeping Telemetry point indicating newly calculated STCF seconds value -** - \b \c \TIME_STCFSUBSECS - Housekeeping Telemetry point indicating newly calculated STCF subseconds value -** - The #CFE_TIME_TIME_EID informational event message will be generated -** -** \par Error Conditions -** - An invalid number of microseconds was specified (must be less than 1 million) -** - Platorm receiving the command is not a Time Server -**

Evidence of Failure may be found in the following telemetry: -** - \b \c \TIME_CMDEC - command error counter will increment -** - Error specific event messages will be issued (#CFE_TIME_TIME_CFG_EID or #CFE_TIME_TIME_ERR_EID) -** -** \par Criticality -** Inappropriately setting the clock may result in other sub-systems performing incorrect -** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. -** -** \sa #CFE_TIME_SET_MET_CC, #CFE_TIME_SET_STCF_CC, #CFE_TIME_SET_LEAPS_CC -*/ -#define CFE_TIME_SET_TIME_CC 7 /* set time */ - -/** \cfetimecmd Set Mission Elapsed Time -** -** \par Description -** This command sets the Mission Elapsed Timer (MET) to the specified value.

-** Note that the MET (as implemented for cFE Time Service) is a logical representation -** and not a physical timer. Thus, setting the MET is not dependent on whether the -** hardware supports a MET register that can be written to.

-** Note also that Time Service "assumes" that during normal operation, the MET is -** synchronized to the tone signal. Therefore, unless operating in FLYWHEEL mode, -** the sub-seconds portion of the MET will be set to zero at the next tone signal interrupt.

-** The new MET takes effect immediately upon execution of this command. -** -** \cfecmdmnemonic \TIME_SETCLOCKMET -** -** \par Command Structure -** #CFE_TIME_TimeCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will increment -** - \b \c \TIME_METSECS - Housekeeping Telemetry point indicating new MET seconds value -** - \b \c \TIME_METSUBSECS - Housekeeping Telemetry point indicating new MET subseconds value -** - The #CFE_TIME_MET_EID informational event message will be generated -** -** \par Error Conditions -** - An invalid number of microseconds was specified (must be less than 1 million) -** - Platorm receiving the command is not a Time Server -**

Evidence of Failure may be found in the following telemetry: -** - \b \c \TIME_CMDEC - command error counter will increment -** - Error specific event messages will be issued (#CFE_TIME_MET_CFG_EID or #CFE_TIME_MET_ERR_EID) -** -** \par Criticality -** Inappropriately setting the clock may result in other sub-systems performing incorrect -** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. -** -** \sa #CFE_TIME_SET_TIME_CC, #CFE_TIME_SET_STCF_CC, #CFE_TIME_SET_LEAPS_CC -*/ -#define CFE_TIME_SET_MET_CC 8 /* set MET */ - -/** \cfetimecmd Set Spacecraft Time Correlation Factor -** -** \par Description -** This command sets the Spacecraft Time Correlation Factor (STCF) to the specified value. -** This command differs from the previously described SET CLOCK in the nature of the command -** argument. This command sets the STCF value directly, rather than extracting the STCF -** from a value representing the total of MET, STCF and optionally, Leap Seconds. The new -** STCF takes effect immediately upon execution of this command. -** -** \cfecmdmnemonic \TIME_SETCLOCKSTCF -** -** \par Command Structure -** #CFE_TIME_TimeCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will increment -** - \b \c \TIME_STCFSECS - Housekeeping Telemetry point indicating new STCF seconds value -** - \b \c \TIME_STCFSUBSECS - Housekeeping Telemetry point indicating new STCF subseconds value -** - The #CFE_TIME_STCF_EID informational event message will be generated -** -** \par Error Conditions -** - An invalid number of microseconds was specified (must be less than 1 million) -** - Platorm receiving the command is not a Time Server -**

Evidence of Failure may be found in the following telemetry: -** - \b \c \TIME_CMDEC - command error counter will increment -** - Error specific event messages will be issued (#CFE_TIME_STCF_CFG_EID or #CFE_TIME_STCF_ERR_EID) -** -** \par Criticality -** Inappropriately setting the clock may result in other sub-systems performing incorrect -** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. -** -** \sa #CFE_TIME_SET_TIME_CC, #CFE_TIME_SET_MET_CC, #CFE_TIME_SET_LEAPS_CC -*/ -#define CFE_TIME_SET_STCF_CC 9 /* set STCF */ - -/** \cfetimecmd Set Leap Seconds -** -** \par Description -** This command sets the spacecraft Leap Seconds to the specified value. -** Leap Seconds may be positive or negative, and there is no limit to the -** value except, of course, the limit imposed by the 16 bit signed integer -** data type. The new Leap Seconds value takes effect immediately upon -** execution of this command. -** -** \cfecmdmnemonic \TIME_SETCLOCKLEAP -** -** \par Command Structure -** #CFE_TIME_TimeCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will increment -** - \b \c \TIME_LEAPSECS - Housekeeping Telemetry point indicating new Leap seconds value -** - The #CFE_TIME_LEAPS_EID informational event message will be generated -** -** \par Error Conditions -** - Platorm receiving the command is not a Time Server -**

Evidence of Failure may be found in the following telemetry: -** - \b \c \TIME_CMDEC - command error counter will increment -** - Error specific event messages will be issued (#CFE_TIME_LEAPS_CFG_EID) -** -** \par Criticality -** Inappropriately setting the clock may result in other sub-systems performing incorrect -** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. -** -** \sa #CFE_TIME_SET_TIME_CC, #CFE_TIME_SET_MET_CC, #CFE_TIME_SET_STCF_CC -*/ -#define CFE_TIME_SET_LEAPS_CC 10 /* set Leap Seconds */ - -/** \cfetimecmd Add Delta to Spacecraft Time Correlation Factor -** -** \par Description -** This command adjusts the Spacecraft Time Correlation Factor (STCF) by -** adding the specified value. The new STCF takes effect immediately upon -** execution of this command. -** -** \cfecmdmnemonic \TIME_ADDSTCFADJ -** -** \par Command Structure -** #CFE_TIME_TimeCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will increment -** - \b \c \TIME_STCFSECS - Housekeeping Telemetry point indicating new STCF seconds value -** - \b \c \TIME_STCFSUBSECS - Housekeeping Telemetry point indicating new STCF subseconds value -** - The #CFE_TIME_DELTA_EID informational event message will be generated -** -** \par Error Conditions -** - An invalid number of microseconds was specified (must be less than 1 million) -** - Platorm receiving the command is not a Time Server -**

Evidence of Failure may be found in the following telemetry: -** - \b \c \TIME_CMDEC - command error counter will increment -** - Error specific event messages will be issued (#CFE_TIME_DELTA_ERR_EID or #CFE_TIME_DELTA_CFG_EID) -** -** \par Criticality -** Inappropriately setting the clock may result in other sub-systems performing incorrect -** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. -** -** \sa #CFE_TIME_ADD_ADJUST_CC, #CFE_TIME_SUB_ADJUST_CC, #CFE_TIME_ADD_1HZADJ_CC, #CFE_TIME_SUB_1HZADJ_CC -*/ -#define CFE_TIME_ADD_ADJUST_CC 11 /* add one time STCF adjustment */ - -/** \cfetimecmd Subtract Delta from Spacecraft Time Correlation Factor -** -** \par Description -** This command adjusts the Spacecraft Time Correlation Factor (STCF) by subtracting the specified -** value. The new STCF takes effect immediately upon execution of this command. -** -** \cfecmdmnemonic \TIME_SUBSTCFADJ -** -** \par Command Structure -** #CFE_TIME_TimeCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will increment -** - \b \c \TIME_STCFSECS - Housekeeping Telemetry point indicating new STCF seconds value -** - \b \c \TIME_STCFSUBSECS - Housekeeping Telemetry point indicating new STCF subseconds value -** - The #CFE_TIME_DELTA_EID informational event message will be generated -** -** \par Error Conditions -** - An invalid number of microseconds was specified (must be less than 1 million) -** - Platorm receiving the command is not a Time Server -**

Evidence of Failure may be found in the following telemetry: -** - \b \c \TIME_CMDEC - command error counter will increment -** - Error specific event messages will be issued (#CFE_TIME_DELTA_ERR_EID or #CFE_TIME_DELTA_CFG_EID) -** -** \par Criticality -** Inappropriately setting the clock may result in other sub-systems performing incorrect -** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. -** -** \sa #CFE_TIME_ADD_ADJUST_CC, #CFE_TIME_ADD_1HZADJ_CC, #CFE_TIME_SUB_1HZADJ_CC -*/ -#define CFE_TIME_SUB_ADJUST_CC 12 /* subtract one time STCF adjustment */ - -/** \cfetimecmd Add Delta to Spacecraft Time Correlation Factor each 1Hz -** -** \par Description -** This command has been updated to take actual sub-seconds (1/2^32 seconds) -** rather than micro-seconds as an input argument. This change occurred -** after the determination was made that one micro-second is too large an -** increment for a constant 1Hz adjustment.

-** This command continuously adjusts the Spacecraft Time Correlation Factor (STCF) -** every second, by adding the specified value. The adjustment to the STCF is -** applied in the Time Service local 1Hz interrupt handler. As the local 1Hz -** interrupt is not synchronized to the tone signal, one cannot say when the -** adjustment will occur, other than once a second, at about the same time -** relative to the tone.

-** There was some debate about whether the maximum 1Hz clock drift correction -** factor would ever need to exceed some small fraction of a second. But, the -** decision was made to provide the capability to make 1Hz adjustments greater -** than one second and leave it to the ground system to provide mission specific -** limits. -** -** \cfecmdmnemonic \TIME_ADD1HZSTCF -** -** \par Command Structure -** #CFE_TIME_1HzAdjCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will increment -** - \b \c \TIME_STCFSECS - Housekeeping Telemetry point indicating new STCF seconds value -** - \b \c \TIME_STCFSUBSECS - Housekeeping Telemetry point indicating new STCF subseconds value -** - The #CFE_TIME_1HZ_EID informational event message will be generated -** -** \par Error Conditions -** - Platorm receiving the command is not a Time Server -**

Evidence of Failure may be found in the following telemetry: -** - \b \c \TIME_CMDEC - command error counter will increment -** - Error specific event message will be issued (#CFE_TIME_1HZ_CFG_EID) -** -** \par Criticality -** Inappropriately setting the clock may result in other sub-systems performing incorrect -** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. -** -** \sa #CFE_TIME_ADD_ADJUST_CC, #CFE_TIME_SUB_ADJUST_CC, #CFE_TIME_SUB_1HZADJ_CC -*/ -#define CFE_TIME_ADD_1HZADJ_CC 13 /* add 1Hz STCF adjustment */ - -/** \cfetimecmd Subtract Delta from Spacecraft Time Correlation Factor each 1Hz -** -** \par Description -** This command has been updated to take actual sub-seconds (1/2^32 seconds) -** rather than micro-seconds as an input argument. This change occurred -** after the determination was made that one micro-second is too large an -** increment for a constant 1Hz adjustment.

-** This command continuously adjusts the Spacecraft Time Correlation Factor (STCF) -** every second, by subtracting the specified value. The adjustment to the STCF -** is applied in the Time Service local 1Hz interrupt handler. As the local 1Hz -** interrupt is not synchronized to the tone signal, one cannot say when the -** adjustment will occur, other than once a second, at about the same time -** relative to the tone.

-** There was some debate about whether the maximum 1Hz clock drift correction -** factor would ever need to exceed some small fraction of a second. But, the -** decision was made to provide the capability to make 1Hz adjustments greater -** than one second and leave it to the ground system to provide mission specific -** limits. -** -** \cfecmdmnemonic \TIME_SUB1HZSTCF -** -** \par Command Structure -** #CFE_TIME_1HzAdjCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will increment -** - \b \c \TIME_STCFSECS - Housekeeping Telemetry point indicating new STCF seconds value -** - \b \c \TIME_STCFSUBSECS - Housekeeping Telemetry point indicating new STCF subseconds value -** - The #CFE_TIME_1HZ_EID informational event message will be generated -** -** \par Error Conditions -** - Platorm receiving the command is not a Time Server -**

Evidence of Failure may be found in the following telemetry: -** - \b \c \TIME_CMDEC - command error counter will increment -** - Error specific event message will be issued (#CFE_TIME_1HZ_CFG_EID) -** -** \par Criticality -** Inappropriately setting the clock may result in other sub-systems performing incorrect -** time based calculations. The specific risk is dependent upon the behavior of those sub-systems. -** -** \sa #CFE_TIME_ADD_ADJUST_CC, #CFE_TIME_SUB_ADJUST_CC, #CFE_TIME_ADD_1HZADJ_CC -*/ -#define CFE_TIME_SUB_1HZADJ_CC 14 /* subtract 1Hz STCF adjustment */ - - -/** \cfetimecmd Set Tone Signal Source -** -** \par Description -** This command selects the Time Service tone signal source. Although the -** list of potential tone signal sources is mission specific, a common -** choice is the selection of primary or redundant tone signal. The selection -** may be available to both the Time Server and Time Clients, depending on -** hardware configuration.

-** Notes: -** - This command is only valid when the #CFE_TIME_CFG_SIGNAL configuration -** parameter in the cfe_platform_cfg.h file has been set to TRUE. -** -** \cfecmdmnemonic \TIME_SETSIGNAL -** -** \par Command Structure -** #CFE_TIME_SignalCmd_t -** -** \par Command Verification -** Successful execution of this command may be verified with the -** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will -** increment -** - \b \c \TIME_SIGNAL - Diagnostic Telemetry point will indicate the -** command specified value -** - The #CFE_TIME_SIGNAL_EID informational event message will -** be generated -** -** \par Error Conditions -** - Invalid Signal selection -** (a value other than #CFE_TIME_TONE_PRI or #CFE_TIME_TONE_RED was specified) -** - Multiple Tone Signal Sources not available on this platform -**

Evidence of failure may be found in the following telemetry: -** - \b \c \TIME_CMDEC - Command Error counter will increment -** - Error specific event message (either #CFE_TIME_SIGNAL_CFG_EID or #CFE_TIME_SIGNAL_ERR_EID) -** -** \par Criticality -** Although tone signal source selection is important, this command is not critical -** -** \sa #CFE_TIME_SET_STATE_CC, #CFE_TIME_SET_SOURCE_CC -*/ -#define CFE_TIME_SET_SIGNAL_CC 15 /* set clock signal (pri vs red) */ -/** \} */ - -/* -** Clock source command arguments... -*/ -/** \name Clock Source Selection Parameters */ -/** \{ */ -#define CFE_TIME_USE_INTERN 1 -#define CFE_TIME_USE_EXTERN 2 -/** \} */ - -/* -** Clock signal command arguments... -*/ -/** \name Clock Signal Selection Parameters */ -/** \{ */ -#define CFE_TIME_TONE_PRI 1 -#define CFE_TIME_TONE_RED 2 -/** \} */ - -/* -** STCF adjustment direction (for both "one time" and "1Hz" adjustments)... -*/ -/** \name Spacecraft Time Correlation Factor Adjustment Parameters */ -/** \{ */ -#define CFE_TIME_ADD_ADJUST 1 /* add STCF adjustment value */ -#define CFE_TIME_SUB_ADJUST 2 /* subtract STCF adjustment value */ -/** \} */ - -/* -** Fly-wheel status values (are we currently fly-wheeling)... -*/ -/** \name Fly-wheel status values */ -/** \{ */ -#define CFE_TIME_NO_FLY 0 -#define CFE_TIME_IS_FLY 1 -/** \} */ - -/* -** Clock "set" status values (has the clock been set to correct time)... -*/ -/** \name Clock "set" status values */ -/** \{ */ -#define CFE_TIME_NOT_SET 0 -#define CFE_TIME_WAS_SET 1 -/** \} */ - -/* -** Clock "state flag" definitions (state data converted to flags)... -*/ -/** \name Clock "state flag" values */ -/** \{ */ -#define CFE_TIME_FLAG_CLKSET 0x8000 /**< \brief The spacecraft time has been set */ -#define CFE_TIME_FLAG_FLYING 0x4000 /**< \brief This instance of Time Services is flywheeling */ -#define CFE_TIME_FLAG_SRCINT 0x2000 /**< \brief The clock source is set to "internal" */ -#define CFE_TIME_FLAG_SIGPRI 0x1000 /**< \brief The clock signal is set to "primary" */ -#define CFE_TIME_FLAG_SRVFLY 0x0800 /**< \brief The Time Server is in flywheel mode */ -#define CFE_TIME_FLAG_CMDFLY 0x0400 /**< \brief This instance of Time Services was commanded into flywheel mode */ -#define CFE_TIME_FLAG_ADDADJ 0x0200 /**< \brief One time STCF Adjustment is to be done in positive direction */ -#define CFE_TIME_FLAG_ADD1HZ 0x0100 /**< \brief 1 Hz STCF Adjustment is to be done in a positive direction */ -#define CFE_TIME_FLAG_ADDTCL 0x0080 /**< \brief Time Client Latency is applied in a positive direction */ -#define CFE_TIME_FLAG_SERVER 0x0040 /**< \brief This instance of Time Services is a Time Server */ -#define CFE_TIME_FLAG_GDTONE 0x0020 /**< \brief The tone received is good compared to the last tone received */ -#define CFE_TIME_FLAG_UNUSED 0x001F /**< \brief Reserved flags - should be zero */ -/** \} */ - - -/*************************************************************************/ - -/* -** Type definition (generic "no arguments" command)... -*/ -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - -} CFE_TIME_NoArgsCmd_t; - - -/* -** Type definition (leap seconds command)... -*/ -typedef struct -{ - int16 LeapSeconds; -} CFE_TIME_LeapsCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - CFE_TIME_LeapsCmd_Payload_t Payload; -} CFE_TIME_LeapsCmd_t; - - -/* -** Type definition (clock state command)... -*/ -typedef struct -{ - int16 ClockState; /**< \brief #CFE_TIME_INVALID=Spacecraft time has not been accurately set, - #CFE_TIME_VALID=Spacecraft clock has been accurately set, - #CFE_TIME_FLYWHEEL=Force into FLYWHEEL mode */ - /**< Selects the current clock state */ -} CFE_TIME_StateCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - CFE_TIME_StateCmd_Payload_t Payload; -} CFE_TIME_StateCmd_t; - - -/* -** Type definition (time data source command)... -*/ -typedef struct -{ - int16 TimeSource; /**< \brief #CFE_TIME_USE_INTERN=Internal Source, - #CFE_TIME_USE_EXTERN=External Source */ - /**< Selects either the "Internal" and "External" clock source */ -} CFE_TIME_SourceCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - CFE_TIME_SourceCmd_Payload_t Payload; -} CFE_TIME_SourceCmd_t; - - -/* -** Type definition (tone signal source command)... -*/ -typedef struct -{ - int16 ToneSource; /**< \brief #CFE_TIME_TONE_PRI=Primary Source, - #CFE_TIME_TONE_RED=Redundant Source */ - /**< Selects either the "Primary" or "Redundant" tone signal source */ -} CFE_TIME_SignalCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - CFE_TIME_SignalCmd_Payload_t Payload; - -} CFE_TIME_SignalCmd_t; - - -/* -** Type definition (generic "time argument" command)... -*/ -typedef struct -{ - uint32 Seconds; - uint32 MicroSeconds; -} CFE_TIME_TimeCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - CFE_TIME_TimeCmd_Payload_t Payload; -} CFE_TIME_TimeCmd_t; - - -/* -** Type definition (1Hz STCF adjustment "time argument" command)... -*/ -typedef struct -{ - uint32 Seconds; - uint32 Subseconds; - -} CFE_TIME_1HzAdjCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - CFE_TIME_1HzAdjCmd_Payload_t Payload; - -} CFE_TIME_1HzAdjCmd_t; - - -/* -** Type definition (local 1Hz wake-up command)... -*/ -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - -} CFE_TIME_1HzCmd_t; - - -/* -** Type definition (time at the tone signal command)... -*/ -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - -} CFE_TIME_ToneSignalCmd_t; - - -/* -** Type definition ("fake" time at the tone signal command)... -*/ -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - -} CFE_TIME_FakeToneCmd_t; - - -/* -** Type definition (time at the tone data command)... -*/ -typedef struct -{ - CFE_TIME_SysTime_t AtToneMET; /**< \brief MET at time of tone */ - CFE_TIME_SysTime_t AtToneSTCF; /**< \brief STCF at time of tone */ - int16 AtToneLeaps; /**< \brief Leap Seconds at time of tone */ - int16 AtToneState; /**< \brief Clock state at time of tone */ -} CFE_TIME_ToneDataCmd_Payload_t; - -typedef struct -{ - uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; - CFE_TIME_ToneDataCmd_Payload_t Payload; -} CFE_TIME_ToneDataCmd_t; - - -/*************************************************************************/ - -/** -** \cfetimetlm Time Services Housekeeping Packet -**/ -typedef struct -{ - /* - ** Task command interface counters... - */ - uint8 CmdCounter; /**< \cfetlmmnemonic \TIME_CMDPC - \brief Time Command Execution Counter */ - uint8 ErrCounter; /**< \cfetlmmnemonic \TIME_CMDEC - \brief Time Command Error Counter */ - - /* - ** Clock state flags and "as calculated" clock state... - */ - uint16 ClockStateFlags; /**< \cfetlmmnemonic \TIME_STATEFLG - \brief State Flags */ - int16 ClockStateAPI; /**< \cfetlmmnemonic \TIME_APISTATE - \brief API State */ - - /* - ** Leap Seconds... - */ - int16 LeapSeconds; /**< \cfetlmmnemonic \TIME_LEAPSECS - \brief Current Leaps Seconds */ - - /* - ** Current MET and STCF time values... - */ - uint32 SecondsMET; /**< \cfetlmmnemonic \TIME_METSECS - \brief Current MET (seconds) */ - uint32 SubsecsMET; /**< \cfetlmmnemonic \TIME_METSUBSECS - \brief Current MET (sub-seconds) */ - - uint32 SecondsSTCF; /**< \cfetlmmnemonic \TIME_STCFSECS - \brief Current STCF (seconds) */ - uint32 SubsecsSTCF; /**< \cfetlmmnemonic \TIME_STCFSUBSECS - \brief Current STCF (sub-seconds) */ - - /* - ** 1Hz STCF adjustment values (server only)... - */ - #if (CFE_TIME_CFG_SERVER == TRUE) - uint32 Seconds1HzAdj; /**< \cfetlmmnemonic \TIME_1HZADJSECS - \brief Current 1 Hz SCTF adjustment (seconds) */ - uint32 Subsecs1HzAdj; /**< \cfetlmmnemonic \TIME_1HZADJSSECS - \brief Current 1 Hz SCTF adjustment (sub-seconds) */ - #endif - - /* - ** Time at tone delay values (client only)... - */ - #if (CFE_TIME_CFG_CLIENT == TRUE) - uint32 SecondsDelay; /**< \cfetlmmnemonic \TIME_1HZDLYSECS - \brief Current 1 Hz SCTF Delay (seconds) */ - uint32 SubsecsDelay; /**< \cfetlmmnemonic \TIME_1HZDLYSSECS - \brief Current 1 Hz SCTF Delay (sub-seconds) */ - #endif - -} CFE_TIME_HkPacket_Payload_t; - -typedef struct -{ - uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; - CFE_TIME_HkPacket_Payload_t Payload; -} CFE_TIME_HkPacket_t; - - -/*************************************************************************/ - -/** -** \cfetimetlm Time Services Diagnostics Packet -**/ -typedef struct -{ - /* - ** Data values used to compute time (in reference to "tone")... - */ - CFE_TIME_SysTime_t AtToneMET; /**< \cfetlmmnemonic \TIME_TMETS - \brief MET at time of tone */ - CFE_TIME_SysTime_t AtToneSTCF; /**< \cfetlmmnemonic \TIME_STCFS - \brief STCF at time of tone */ - CFE_TIME_SysTime_t AtToneDelay; /**< \cfetlmmnemonic \TIME_LATENTS - \brief Adjustment for slow tone detection */ - CFE_TIME_SysTime_t AtToneLatch; /**< \cfetlmmnemonic \TIME_TVALIDS - \brief Local clock latched at time of tone */ - - int16 AtToneLeaps; /**< \cfetlmmnemonic \TIME_LEAPS - \brief Leap Seconds at time of tone */ - int16 ClockStateAPI; /**< \cfetlmmnemonic \TIME_APISTATE - \brief Clock state as per API */ - - /* - ** Data values that reflect the time (right now)... - */ - CFE_TIME_SysTime_t TimeSinceTone; /**< \cfetlmmnemonic \TIME_ELAPSEDS - \brief Time elapsed since the tone */ - CFE_TIME_SysTime_t CurrentLatch; /**< \cfetlmmnemonic \TIME_LOCALS - \brief Local clock latched just "now" */ - CFE_TIME_SysTime_t CurrentMET; /**< \cfetlmmnemonic \TIME_METS - \brief MET at this instant */ - CFE_TIME_SysTime_t CurrentTAI; /**< \cfetlmmnemonic \TIME_TAIS - \brief TAI at this instant */ - CFE_TIME_SysTime_t CurrentUTC; /**< \cfetlmmnemonic \TIME_UTCS - \brief UTC at this instant */ - - /* - ** Data values used to define the current clock state... - */ - int16 ClockSetState; /**< \cfetlmmnemonic \TIME_VALID - \brief Time has been "set" */ - int16 ClockFlyState; /**< \cfetlmmnemonic \TIME_FLYWHEEL - \brief Current fly-wheel state */ - int16 ClockSource; /**< \cfetlmmnemonic \TIME_SOURCE - \brief Internal vs external, etc. */ - int16 ClockSignal; /**< \cfetlmmnemonic \TIME_SIGNAL - \brief Primary vs redundant, etc. */ - int16 ServerFlyState; /**< \cfetlmmnemonic \TIME_SRVFLY - \brief Used by clients only */ - int16 Forced2Fly; /**< \cfetlmmnemonic \TIME_CMD2FLY - \brief Commanded into fly-wheel */ - - /* - ** Clock state flags... - */ - uint16 ClockStateFlags;/**< \cfetlmmnemonic \TIME_STATEFLAGS - \brief Clock State Flags */ - - /* - ** STCF adjustment direction values... - */ - int16 OneTimeDirection; /**< \cfetlmmnemonic \TIME_ADJUSTDIR - \brief One time STCF adjustment direction (Add = 1, Sub = 2) */ - int16 OneHzDirection; /**< \cfetlmmnemonic \TIME_1HZADJDIR - \brief 1Hz STCF adjustment direction */ - int16 DelayDirection; /**< \cfetlmmnemonic \TIME_LATENTDIR - \brief Client latency adjustment direction */ - - /* - ** STCF adjustment values... - */ - CFE_TIME_SysTime_t OneTimeAdjust; /**< \cfetlmmnemonic \TIME_ADJUSTS - \brief Previous one-time STCF adjustment */ - CFE_TIME_SysTime_t OneHzAdjust; /**< \cfetlmmnemonic \TIME_1HZADJS - \brief Current 1Hz STCF adjustment */ - - /* - ** Most recent local clock latch values... - */ - CFE_TIME_SysTime_t ToneSignalLatch; /**< \cfetlmmnemonic \TIME_TTS - \brief Local Clock latched at most recent tone signal */ - CFE_TIME_SysTime_t ToneDataLatch; /**< \cfetlmmnemonic \TIME_TDS - \brief Local Clock latched at arrival of tone data */ - - /* - ** Miscellaneous counters (subject to reset command)... - */ - uint32 ToneMatchCount; /**< \cfetlmmnemonic \TIME_VERIFYCNT - \brief Tone signal / data verification count */ - uint32 ToneMatchErrors; /**< \cfetlmmnemonic \TIME_VERIFYER - \brief Tone signal / data verification error count */ - uint32 ToneSignalCount; /**< \cfetlmmnemonic \TIME_TSDETCNT - \brief Tone signal detected SB message count */ - uint32 ToneDataCount; /**< \cfetlmmnemonic \TIME_TATTCNT - \brief Time at the tone data SB message count */ - uint32 ToneIntCount; /**< \cfetlmmnemonic \TIME_TSISRCNT - \brief Tone signal ISR execution count */ - uint32 ToneIntErrors; /**< \cfetlmmnemonic \TIME_TSISRERR - \brief Tone signal ISR error count */ - uint32 ToneTaskCount; /**< \cfetlmmnemonic \TIME_TSTASKCNT - \brief Tone task execution count */ - uint32 VersionCount; /**< \cfetlmmnemonic \TIME_VERSIONCNT - \brief Count of mods to time at tone reference data (version) */ - uint32 LocalIntCount; /**< \cfetlmmnemonic \TIME_1HZISRCNT - \brief Local 1Hz ISR execution count */ - uint32 LocalTaskCount; /**< \cfetlmmnemonic \TIME_1HZTASKCNT - \brief Local 1Hz task execution count */ - - /* - ** Miscellaneous counters (not subject to reset command)... - */ - uint32 VirtualMET; /**< \cfetlmmnemonic \TIME_LOGICALMET - \brief Software MET */ - - /* - ** Time window verification values (converted from micro-secs)... - ** - ** Regardless of whether the tone follows the time packet, or vice - ** versa, these values define the acceptable window of time for - ** the second event to follow the first. The minimum value may - ** be as little as zero, and the maximum must be something less - ** than a second. - */ - uint32 MinElapsed; /**< \cfetlmmnemonic \TIME_MINWINDOW - \brief Min tone signal / data pkt arrival window (Sub-seconds) */ - uint32 MaxElapsed; /**< \cfetlmmnemonic \TIME_MAXWINDOW - \brief Max tone signal / data pkt arrival window (Sub-seconds) */ - - /* - ** Maximum local clock value (before roll-over)... - */ - CFE_TIME_SysTime_t MaxLocalClock; /**< \cfetlmmnemonic \TIME_WRAPS - \brief Max local clock value before rollover */ - - /* - ** Tone signal tolerance limits... - */ - uint32 ToneOverLimit; /**< \cfetlmmnemonic \TIME_MAXSS - \brief Max between tone signal interrupts */ - uint32 ToneUnderLimit; /**< \cfetlmmnemonic \TIME_MINSS - \brief Min between tone signal interrupts */ - - /* - ** Reset Area... - */ - uint32 DataStoreStatus; /**< \cfetlmmnemonic \TIME_ATASTSTAT - \brief Data Store status (preserved across processor reset) */ -} CFE_TIME_DiagPacket_Payload_t; - -typedef struct -{ - uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; - CFE_TIME_DiagPacket_Payload_t Payload; -} CFE_TIME_DiagPacket_t; - - -/*************************************************************************/ - -#endif /* _cfe_time_msg_ */ - -/************************/ -/* End of File Comment */ -/************************/ diff --git a/src/components/interface/cFE/cfe_version.h b/src/components/interface/cFE/cfe_version.h deleted file mode 100644 index 7b5be26d5c..0000000000 --- a/src/components/interface/cFE/cfe_version.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -** File: -** cfe_es_version.h -** $Id: cfe_version.h 1.8.2.5 2014/12/02 19:26:21GMT-05:00 sstrege Exp $ -** -** -** Copyright (c) 2004-2012, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software(cFE) was created at NASA's Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Purpose: -** Provide version identifiers for the cFE core. -** -** References: -** Flight Software Branch C Coding Standard Version 1.0a -** cFE Flight Software Application Developers Guide -** -** Notes: -** -** -** Modification History: -** $Log: cfe_version.h $ -** Revision 1.8.2.5 2014/12/02 19:26:21GMT-05:00 sstrege -** Changing version number for the branch to 6.4.1 -** Revision 1.8.2.4 2014/09/30 17:39:28EDT sstrege -** Changing the version number for the branch tip to 9.9.9 -** Revision 1.8.2.3 2014/09/30 15:56:42EDT sstrege -** Changing version number for 6.4.0 release -** Revision 1.8.2.2 2014/09/10 22:36:45EDT sstrege -** Changing the version number for the branch tip to 9.9.9 -** Revision 1.8.2.1 2014/09/10 22:27:48EDT sstrege -** Changing the version number for the branch to 6.4.0 -** Revision 1.8 2012/01/13 11:50:06EST acudmore -** Member renamed from cfe_es_version.h to cfe_version.h in project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj. -** Revision 1.7 2012/01/13 11:50:06ACT acudmore -** Member moved from cfe_es_version.h in project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/es/project.pj to cfe_es_version.h in project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj. -** Revision 1.6 2012/01/13 11:50:06ACT acudmore -** Changed license text to reflect open source -** Revision 1.5 2010/11/23 15:27:32EST jmdagost -** Changed SubMinor Version definition to Revision to match other cFE/CFS components. -** Revision 1.4 2010/10/25 15:02:13EDT jmdagost -** Corrected bad apostrophe in prologue. -** Revision 1.3 2010/10/04 15:37:32EDT jmdagost -** Cleaned up copyright symbol. -** Revision 1.2 2008/07/21 16:00:07EDT rjmcgraw -** DCR4195:1 Changed version number from 9.9.9 to 0.0.0 -** Revision 1.1 2008/04/17 08:05:10EDT ruperera -** Initial revision -** Member added to cFE project -*/ - -#ifndef _cfe_es_version_ -#define _cfe_es_version_ - -/* - * The "enhanced build" (cmake-driven) instantiates a configuration - * object that contains extended version information within it. - * - * This information is generated automatically by the build using - * git to determine the most recent tag and commitid. - * - * This is only available when compiling with the cmake scripts which - * is why it is conditionally included. - */ -#ifdef _ENHANCED_BUILD_ -#include -#endif - - -/* -** Macro Definitions -*/ -#define CFE_MAJOR_VERSION 6 -#define CFE_MINOR_VERSION 5 -#define CFE_REVISION 0 - - -#endif /* _cfe_es_version_ */ - diff --git a/src/components/interface/cFE/common_types.h b/src/components/interface/cFE/common_types.h deleted file mode 100644 index e915f00e99..0000000000 --- a/src/components/interface/cFE/common_types.h +++ /dev/null @@ -1,374 +0,0 @@ -/*--------------------------------------------------------------------------- -** -** Filename: -** $Id: common_types.h 1.9 2014/01/14 16:28:32GMT-05:00 acudmore Exp $ -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software was created at NASAs Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Purpose: -** Unit specification for common types. -** -** Design Notes: -** Assumes make file has defined processor family -** -** References: -** Flight Software Branch C Coding Standard Version 1.0a -** -** -** Notes: -** -** -** $Date: 2014/01/14 16:28:32GMT-05:00 $ -** $Revision: 1.9 $ -** $Log: common_types.h $ -** Revision 1.9 2014/01/14 16:28:32GMT-05:00 acudmore -** Fixed typo in macro for x86-64 -** Revision 1.8 2013/08/09 13:58:04GMT-05:00 acudmore -** Added int64 type, added support for ARM arch, added 64 bit x86 arch, added arch check for GCC arch macros, added check for proper data type sizes -** Revision 1.7 2013/07/25 10:01:29GMT-05:00 acudmore -** Added C++ support -** Revision 1.6 2012/04/11 09:19:03GMT-05:00 acudmore -** added OS_USED attribute -** Revision 1.5 2010/02/18 16:43:29EST acudmore -** Added SPARC processor section -** Removed special characters from comments that cause problems with some tools. -** Revision 1.4 2010/02/18 16:41:39EST acudmore -** Added a block of defines for GCC specific pragmas and extensions. -** Removed RTEMS boolean related ifdefs -** moved OS_PACK into the GCC specific block -** Revision 1.3 2010/02/01 12:31:17EST acudmore -** Added uint64 type -** Revision 1.2 2009/07/07 16:30:05EDT acudmore -** Removed conditinal comp. around boolean for m68k. -** This will need to be done for all RTEMS targets -** Revision 1.1 2009/06/02 10:04:58EDT acudmore -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/os/inc/project.pj -** Revision 1.1 2008/04/20 22:35:58EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/inc/project.pj -** Revision 1.1 2007/10/16 16:14:49EDT apcudmore -** Initial revision -** Member added to project d:/mksdata/MKS-OSAL-REPOSITORY/src/inc/project.pj -** Revision 1.2 2006/06/08 14:28:32EDT David Kobe (dlkobe) -** Added NASA Open Source Legal Statement -** Revision 1.1 2005/06/09 09:57:51GMT-05:00 rperera -** Initial revision -** Member added to project d:/mksdata/MKS-CFE-REPOSITORY/cfe-core/inc/project.pj -** Revision 1.6 2005/03/24 19:20:52 rmcgraw -** Wrapped the boolean defintion for all three processors with #ifndef _USING_RTEMS_INCLUDES_ -** -** Revision 1.5 2005/03/10 16:59:08 acudmore -** removed boolean prefix to TRUE and FALSE defintion to avoid vxWorks conflict. -** -** Revision 1.4 2005/03/07 20:23:34 acudmore -** removed duplicate boolean definition -** -** Revision 1.3 2005/03/07 20:05:17 acudmore -** updated with __PPC__ macro that gnu compiler uses -** -** Revision 1.2 2005/03/04 16:02:44 acudmore -** added coldfire architecture -** -** Revision 1.1 2005/03/04 15:58:45 acudmore -** Added common_types.h -** -** -** -**-------------------------------------------------------------------------*/ - -#ifndef _common_types_ -#define _common_types_ - -#ifdef __cplusplus - extern "C" { -#endif - -/* -** Includes -*/ - -/* -** Macro Definitions -*/ - -/* -** Condition = TRUE is ok, Condition = FALSE is error -*/ -#define CompileTimeAssert(Condition, Message) typedef char Message[(Condition) ? 1 : -1] - - -/* -** Define compiler specific macros -** The __extension__ compiler pragma is required -** for the uint64 type using GCC with the ANSI C90 standard. -** Other macros can go in here as needed, for example alignment -** pragmas. -** -** NOTE: The white-box (coverage) unit testing may need to disable -** these extra attributes. These test builds define the OSAPI_NO_SPECIAL_ATTRIBS -** macro to disable this. -*/ -#if defined (__GNUC__) && !defined(OSAPI_NO_SPECIAL_ATTRIBS) - #define _EXTENSION_ __extension__ - #define OS_PACK __attribute__ ((packed)) - #define OS_ALIGN(n) __attribute__((aligned(n))) - #define OS_USED __attribute__((used)) - #define OS_PRINTF(n,m) __attribute__ ((format (printf, n, m))) -#else - #define _EXTENSION_ - #define OS_PACK - #define OS_ALIGN(n) - #define OS_USED - #define OS_PRINTF(n,m) -#endif - -/* - * If the host system has a ISO C99 standard stdint header file, prefer it. - * This ensures that fixed-width types are correct including on 64-bit systems. - */ -#if defined(_HAVE_STDINT_) - -#include -#include -/* - * NOTE - NOT DEFINING STRUCT_LOW_BIT_FIRST or STRUCT_HIGH_BIT_FIRST - * We should not make assumptions about the bit order here - */ - - typedef uint8_t osalbool; - typedef int8_t int8; - typedef int16_t int16; - typedef int32_t int32; - typedef int64_t int64; - typedef uint8_t uint8; - typedef uint16_t uint16; - typedef uint32_t uint32; - typedef uint64_t uint64; - typedef intptr_t intptr; - typedef uintptr_t cpuaddr; - typedef size_t cpusize; - typedef ptrdiff_t cpudiff; - -/* - * Fall back to default integer type maps - - * These definitions assume a 32-bit processor - */ -#elif defined(_ix86_) || defined (__i386__) -/* ----------------------- Intel x86 processor family -------------------------*/ - /* Little endian */ - #undef _STRUCT_HIGH_BIT_FIRST_ - #define _STRUCT_LOW_BIT_FIRST_ - - typedef unsigned char osalbool; - typedef signed char int8; - typedef short int int16; - typedef long int int32; - _EXTENSION_ typedef long long int int64; - typedef unsigned char uint8; - typedef unsigned short int uint16; - typedef unsigned long int uint32; - _EXTENSION_ typedef unsigned long long int uint64; - - typedef unsigned long int cpuaddr; - typedef unsigned long int cpusize; - typedef long int cpudiff; - -#elif defined (_ix64_) || defined (__x86_64__) -/* ----------------------- Intel/AMD x64 processor family -------------------------*/ - /* Little endian */ - #undef _STRUCT_HIGH_BIT_FIRST_ - #define _STRUCT_LOW_BIT_FIRST_ - - typedef unsigned char osalbool; - typedef signed char int8; - typedef short int int16; - typedef int int32; - typedef long int int64; - typedef unsigned char uint8; - typedef unsigned short int uint16; - typedef unsigned int uint32; - typedef unsigned long int uint64; - - typedef unsigned long int cpuaddr; - typedef unsigned long int cpusize; - typedef long int cpudiff; - -#elif defined(__PPC__) || defined (__ppc__) - /* ----------------------- Motorola Power PC family ---------------------------*/ - /* The PPC can be programmed to be big or little endian, we assume native */ - /* Big endian */ - #define _STRUCT_HIGH_BIT_FIRST_ - #undef _STRUCT_LOW_BIT_FIRST_ - - typedef unsigned char osalbool; - typedef signed char int8; - typedef short int int16; - typedef long int int32; - _EXTENSION_ typedef long long int int64; - typedef unsigned char uint8; - typedef unsigned short int uint16; - typedef unsigned long int uint32; - _EXTENSION_ typedef unsigned long long int uint64; - - typedef unsigned long int cpuaddr; - typedef unsigned long int cpusize; - typedef long int cpudiff; - -#elif defined(_m68k_) || defined(__m68k__) - /* ----------------------- Motorola m68k/Coldfire family ---------------------------*/ - /* Big endian */ - #define _STRUCT_HIGH_BIT_FIRST_ - #undef _STRUCT_LOW_BIT_FIRST_ - - typedef unsigned char osalbool; - typedef signed char int8; - typedef short int int16; - typedef long int int32; - _EXTENSION_ typedef long long int int64; - typedef unsigned char uint8; - typedef unsigned short int uint16; - typedef unsigned long int uint32; - _EXTENSION_ typedef unsigned long long int uint64; - - typedef unsigned long int cpuaddr; - typedef unsigned long int cpusize; - typedef long int cpudiff; - -#elif defined (__ARM__) || defined(__arm__) -/* ----------------------- ARM processor family -------------------------*/ - /* Little endian */ - #undef _STRUCT_HIGH_BIT_FIRST_ - #define _STRUCT_LOW_BIT_FIRST_ - - typedef unsigned char osalbool; - typedef signed char int8; - typedef short int int16; - typedef long int int32; - _EXTENSION_ typedef long long int int64; - typedef unsigned char uint8; - typedef unsigned short int uint16; - typedef unsigned long int uint32; - _EXTENSION_ typedef unsigned long long int uint64; - - typedef unsigned long int cpuaddr; - typedef unsigned long int cpusize; - typedef long int cpudiff; - -#elif defined(__SPARC__) || defined (_sparc_) - /* ----------------------- SPARC/LEON family ---------------------------*/ - /* SPARC Big endian */ - #define _STRUCT_HIGH_BIT_FIRST_ - #undef _STRUCT_LOW_BIT_FIRST_ - - typedef unsigned char osalbool; - typedef signed char int8; - typedef short int int16; - typedef long int int32; - _EXTENSION_ typedef long long int int64; - typedef unsigned char uint8; - typedef unsigned short int uint16; - typedef unsigned long int uint32; - _EXTENSION_ typedef unsigned long long int uint64; - - typedef unsigned long int cpuaddr; - typedef unsigned long int cpusize; - typedef long int cpudiff; - -#else /* not any of the above */ - #error undefined processor -#endif /* processor types */ - -/* - * Boolean type for compatibility -- - * - * Note it is a bad idea to typedef "bool" or "boolean" -- MANY other projects - * and libraries also define a boolean type due to the lack of a standard bool in C89. - * But calling it simply "bool" or "boolean" almost guarantees a namespace conflict - * if trying to use OSAL with one of those other existing projects. - * - * RTEMS 4.11 no longer defines boolean type by default (deprecated) probably also - * due to the high likelihood of name conflicts. - * - * In order to preserve compatibility for apps written against prior versions of - * OSAL, the name "boolean" is typedefed as well, but this may be turned off - * in a future version whenever appropriate. - */ - -#if (!defined(_USING_RTEMS_INCLUDES_) || !defined(RTEMS_DEPRECATED_TYPES)) - typedef osalbool boolean; -#endif - - -#ifndef NULL /* pointer to nothing */ - #define NULL ((void *) 0) -#endif - -#ifndef TRUE /* Boolean true */ - #define TRUE (1) -#endif - -#ifndef FALSE /* Boolean false */ - #define FALSE (0) -#endif - -/* -** Check Sizes -*/ -CompileTimeAssert(sizeof(uint8)==1, TypeUint8WrongSize); -CompileTimeAssert(sizeof(uint16)==2, TypeUint16WrongSize); -CompileTimeAssert(sizeof(uint32)==4, TypeUint32WrongSize); -CompileTimeAssert(sizeof(uint64)==8, TypeUint64WrongSize); -CompileTimeAssert(sizeof(int8)==1, Typeint8WrongSize); -CompileTimeAssert(sizeof(int16)==2, Typeint16WrongSize); -CompileTimeAssert(sizeof(int32)==4, Typeint32WrongSize); -CompileTimeAssert(sizeof(int64)==8, Typeint64WrongSize); -CompileTimeAssert(sizeof(cpuaddr) >= sizeof(void *), TypePtrWrongSize); - -/* - * TEMPORARY COMPATIBILITY MACRO - * - * Any code that depends on this macro should be fixed so as to not need it. - * The value for this had been set by the BSP makefiles but this is not reliable, - * especially on processors that support both big- and little- endian modes e.g. - * ARM and MIPS. - * - * This is deprecated and only here to bridge the gap until code that depends - * on this can be fixed. Do not write any new code that uses this macro. - * - * If using an older makefile that defines one of the BIT_ORDER macros already, - * then this entire section is skipped and the macro is used as-is. - */ -#if !defined(SOFTWARE_BIG_BIT_ORDER) && !defined(SOFTWARE_LITTLE_BIT_ORDER) - -#if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || \ - defined(__BIG_ENDIAN__) || \ - defined(__ARMEB__) || \ - defined(__THUMBEB__) || \ - defined(__AARCH64EB__) || \ - defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__) -/* It is a big-endian target architecture */ -#define SOFTWARE_BIG_BIT_ORDER -#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || \ - defined(__LITTLE_ENDIAN__) || \ - defined(__ARMEL__) || \ - defined(__THUMBEL__) || \ - defined(__AARCH64EL__) || \ - defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) -/* It is a little-endian target architecture */ -#define SOFTWARE_LITTLE_BIT_ORDER -#endif - -#endif /* !defined(SOFTWARE_BIG_BIT_ORDER) && !defined(SOFTWARE_LITTLE_BIT_ORDER) */ - -#ifdef __cplusplus - } -#endif - -#endif /* _common_types_ */ diff --git a/src/components/interface/cFE/network_includes.h b/src/components/interface/cFE/network_includes.h deleted file mode 100644 index 1b0d93356a..0000000000 --- a/src/components/interface/cFE/network_includes.h +++ /dev/null @@ -1,104 +0,0 @@ -/****************************************************************************** -** File: network_includes.h -** $Id: network_includes.h 1.3 2009/07/31 10:20:30GMT-05:00 acudmore Exp $ -** -** Purpose: -** This header file contains the correct set of network include -** files, which are dependant on the operating system. -** -** Author: R.McGraw/SSI -** -** Notes: -** -** $Date: 2009/07/31 10:20:30GMT-05:00 $ -** $Revision: 1.3 $ -** $Log: network_includes.h $ -** Revision 1.3 2009/07/31 10:20:30GMT-05:00 acudmore -** Updated RTEMS section to define a MSG_DONTWAIT flag that ci_lab uses. -** Revision 1.2 2009/07/17 14:18:09EDT acudmore -** Updated includes to prevent warnings from ARC suggestions. -** Revision 1.1 2008/04/17 08:05:27EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-CFE-PROJECT/fsw/cfe-core/src/inc/project.pj -** Revision 1.5 2006/06/08 14:20:29EDT apcudmore -** Re-ordered include files to prevent warnings/errors for vxWorks and REMS -** Revision 1.4 2006/03/03 16:28:38GMT apcudmore -** Created conditional compilation for systems that dont have the fcntl function -** Revision 1.3 2006/03/03 15:11:03GMT apcudmore -** Fixed non-blocking socket problem with CI -** Revision 1.2 2005/07/29 18:16:40GMT apcudmore -** Updated for mac and linux builds -** Revision 1.1 2005/06/09 09:57:51CDT rperera -** Initial revision -** Member added to project d:/mksdata/MKS-CFE-REPOSITORY/cfe-core/inc/project.pj -** Revision 1.1 2005/03/23 16:04:15 rmcgraw -** Initial Release -** -** -******************************************************************************/ - -#ifndef _network_includes_ -#define _network_includes_ - -#ifdef _VXWORKS_OS_ - #include - #include - #include - #include - #include - #include - #include - -#elif _RTEMS_OS_ - #define _USING_RTEMS_INCLUDES_ - #include - #include - #include - #include - #include - #include - #include - #define _HAVE_FCNTL_ - #ifndef MSG_DONTWAIT - #define MSG_DONTWAIT 0 - #endif -#elif _MAC_OS_ - #include - #include - #include - #include - #include - #include - #include - #define _HAVE_FCNTL_ - -#elif _LINUX_OS_ - #include - #include - #include - #include - #include - #include - #include - #define _HAVE_FCNTL_ - #ifndef MSG_DONTWAIT - #define MSG_DONTWAIT 0 - #endif - -#elif _COMPOSITE_OS_ - #include - #include - #include - #include - #include - #include - #include - #define _HAVE_FCNTL_ - #ifndef MSG_DONTWAIT - #define MSG_DONTWAIT 0 - #endif -#else - #error "No OS defined!" -#endif - -#endif /* _network_includes_ */ diff --git a/src/components/interface/cFE/osapi-os-core.h b/src/components/interface/cFE/osapi-os-core.h deleted file mode 100644 index 2f59a1a469..0000000000 --- a/src/components/interface/cFE/osapi-os-core.h +++ /dev/null @@ -1,330 +0,0 @@ -/* -** File: osapi-os-core.h -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software was created at NASAs Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Author: Ezra Yeheksli -Code 582/Raytheon -** -** Purpose: Contains functions prototype definitions and variables declarations -** for the OS Abstraction Layer, Core OS module -** -** $Revision: 1.8 $ -** -** $Date: 2013/07/25 10:02:00GMT-05:00 $ -** -** $Log: osapi-os-core.h $ -** Revision 1.8 2013/07/25 10:02:00GMT-05:00 acudmore -** removed circular include "osapi.h" -** Revision 1.7 2012/04/11 09:30:48GMT-05:00 acudmore -** Added OS_printf_enable and OS_printf_disable -** Revision 1.6 2010/11/12 12:00:17EST acudmore -** replaced copyright character with (c) and added open source notice where needed. -** Revision 1.5 2010/11/10 15:33:14EST acudmore -** Updated IntAttachHandler prototype -** Revision 1.4 2010/03/08 12:06:28EST acudmore -** added function pointer type to get rid of warnings -** Revision 1.3 2010/02/01 12:37:15EST acudmore -** added return code to OS API init -** Revision 1.2 2009/08/04 10:49:09EDT acudmore -** -*/ - -#ifndef _osapi_core_ -#define _osapi_core_ - -#include /* for va_list */ - -/*difines constants for OS_BinSemCreate for state of semaphore */ -#define OS_SEM_FULL 1 -#define OS_SEM_EMPTY 0 - -/* #define for enabling floating point operations on a task*/ -#define OS_FP_ENABLED 1 - -/* tables for the properties of objects */ - -/*tasks */ -typedef struct -{ - char name [OS_MAX_API_NAME]; - uint32 creator; - uint32 stack_size; - uint32 priority; - uint32 OStask_id; -}OS_task_prop_t; - -/* queues */ -typedef struct -{ - char name [OS_MAX_API_NAME]; - uint32 creator; -}OS_queue_prop_t; - -/* Binary Semaphores */ -typedef struct -{ - char name [OS_MAX_API_NAME]; - uint32 creator; - int32 value; -}OS_bin_sem_prop_t; - -/* Counting Semaphores */ -typedef struct -{ - char name [OS_MAX_API_NAME]; - uint32 creator; - int32 value; -}OS_count_sem_prop_t; - -/* Mutexes */ -typedef struct -{ - char name [OS_MAX_API_NAME]; - uint32 creator; -}OS_mut_sem_prop_t; - - -/* struct for OS_GetLocalTime() */ - -typedef struct -{ - uint32 seconds; - uint32 microsecs; -}OS_time_t; - -/* heap info */ -typedef struct -{ - uint32 free_bytes; - uint32 free_blocks; - uint32 largest_free_block; -}OS_heap_prop_t; - - -/* This typedef is for the OS_GetErrorName function, to ensure - * everyone is making an array of the same length. - * - * Implementation note for developers: - * - * The sizes of strings in OSAL functions are built with this - * OS_ERROR_NAME_LENGTH limit in mind. Always check the uses of os_err_name_t - * when changing this value. - */ - -#define OS_ERROR_NAME_LENGTH 35 -typedef char os_err_name_t[OS_ERROR_NAME_LENGTH]; - -/* -** These typedefs are for the task entry point -*/ -typedef void osal_task; -typedef osal_task ((*osal_task_entry)(void)); - -/* -** Typedef for general purpose OSAL callback functions -** This may be used by multiple APIS -*/ -typedef void (*OS_ArgCallback_t)(uint32 object_id, void *arg); - - -/* -** External Declarations -*/ - -/* -** Prototype for application startup function. -** This is implemented by the user application -*/ -void OS_Application_Startup(void); - - -/* -** Exported Functions -*/ - -/* -** Initialization of API -*/ -int32 OS_API_Init (void); - -/* -** OS-specific background thread implementation - waits forever for events to occur. -** -** This should be called from the BSP main routine / initial thread after all other -** board / application initialization has taken place and all other tasks are running. -*/ -void OS_IdleLoop (void); - -/* -** OS_DeleteAllObjects() provides a means to clean up all resources allocated by this -** instance of OSAL. It would typically be used during an orderly shutdown but may also -** be helpful for testing purposes. -*/ -void OS_DeleteAllObjects (void); - -/* -** OS_ApplicationShutdown() provides a means for a user-created thread to request the orderly -** shutdown of the whole system, such as part of a user-commanded reset command. -** This is preferred over e.g. ApplicationExit() which exits immediately and does not -** provide for any means to clean up first. -*/ -void OS_ApplicationShutdown (uint8 flag); - - -/* -** Task API -*/ - -int32 OS_TaskCreate (uint32 *task_id, const char *task_name, - osal_task_entry function_pointer, - uint32 *stack_pointer, - uint32 stack_size, - uint32 priority, uint32 flags); - -int32 OS_TaskDelete (uint32 task_id); -void OS_TaskExit (void); -int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer); -int32 OS_TaskDelay (uint32 millisecond); -int32 OS_TaskSetPriority (uint32 task_id, uint32 new_priority); -int32 OS_TaskRegister (void); -uint32 OS_TaskGetId (void); -int32 OS_TaskGetIdByName (uint32 *task_id, const char *task_name); -int32 OS_TaskGetInfo (uint32 task_id, OS_task_prop_t *task_prop); - -/* -** Message Queue API -*/ - -/* -** Queue Create now has the Queue ID returned to the caller. -*/ -int32 OS_QueueCreate (uint32 *queue_id, const char *queue_name, - uint32 queue_depth, uint32 data_size, uint32 flags); -int32 OS_QueueDelete (uint32 queue_id); -int32 OS_QueueGet (uint32 queue_id, void *data, uint32 size, - uint32 *size_copied, int32 timeout); -int32 OS_QueuePut (uint32 queue_id, const void *data, uint32 size, - uint32 flags); -int32 OS_QueueGetIdByName (uint32 *queue_id, const char *queue_name); -int32 OS_QueueGetInfo (uint32 queue_id, OS_queue_prop_t *queue_prop); - -/* -** Semaphore API -*/ - -int32 OS_BinSemCreate (uint32 *sem_id, const char *sem_name, - uint32 sem_initial_value, uint32 options); -int32 OS_BinSemFlush (uint32 sem_id); -int32 OS_BinSemGive (uint32 sem_id); -int32 OS_BinSemTake (uint32 sem_id); -int32 OS_BinSemTimedWait (uint32 sem_id, uint32 msecs); -int32 OS_BinSemDelete (uint32 sem_id); -int32 OS_BinSemGetIdByName (uint32 *sem_id, const char *sem_name); -int32 OS_BinSemGetInfo (uint32 sem_id, OS_bin_sem_prop_t *bin_prop); - -int32 OS_CountSemCreate (uint32 *sem_id, const char *sem_name, - uint32 sem_initial_value, uint32 options); -int32 OS_CountSemGive (uint32 sem_id); -int32 OS_CountSemTake (uint32 sem_id); -int32 OS_CountSemTimedWait (uint32 sem_id, uint32 msecs); -int32 OS_CountSemDelete (uint32 sem_id); -int32 OS_CountSemGetIdByName (uint32 *sem_id, const char *sem_name); -int32 OS_CountSemGetInfo (uint32 sem_id, OS_count_sem_prop_t *count_prop); - -/* -** Mutex API -*/ - -int32 OS_MutSemCreate (uint32 *sem_id, const char *sem_name, uint32 options); -int32 OS_MutSemGive (uint32 sem_id); -int32 OS_MutSemTake (uint32 sem_id); -int32 OS_MutSemDelete (uint32 sem_id); -int32 OS_MutSemGetIdByName (uint32 *sem_id, const char *sem_name); -int32 OS_MutSemGetInfo (uint32 sem_id, OS_mut_sem_prop_t *mut_prop); - -/* -** OS Time/Tick related API -*/ - -int32 OS_Milli2Ticks (uint32 milli_seconds); -int32 OS_Tick2Micros (void); -int32 OS_GetLocalTime (OS_time_t *time_struct); -int32 OS_SetLocalTime (OS_time_t *time_struct); - -/* -** Exception API -*/ - -int32 OS_ExcAttachHandler (uint32 ExceptionNumber, - void (*ExceptionHandler)(uint32, const void *,uint32), - int32 parameter); -int32 OS_ExcEnable (int32 ExceptionNumber); -int32 OS_ExcDisable (int32 ExceptionNumber); - -/* -** Floating Point Unit API -*/ - -int32 OS_FPUExcAttachHandler (uint32 ExceptionNumber, void * ExceptionHandler , - int32 parameter); -int32 OS_FPUExcEnable (int32 ExceptionNumber); -int32 OS_FPUExcDisable (int32 ExceptionNumber); -int32 OS_FPUExcSetMask (uint32 mask); -int32 OS_FPUExcGetMask (uint32 *mask); - -/* -** Interrupt API -*/ -int32 OS_IntAttachHandler (uint32 InterruptNumber, osal_task_entry InterruptHandler, int32 parameter); -int32 OS_IntUnlock (int32 IntLevel); -int32 OS_IntLock (void); - -int32 OS_IntEnable (int32 Level); -int32 OS_IntDisable (int32 Level); - -int32 OS_IntSetMask (uint32 mask); -int32 OS_IntGetMask (uint32 *mask); -int32 OS_IntAck (int32 InterruptNumber); - -/* -** Shared memory API -*/ -int32 OS_ShMemInit (void); -int32 OS_ShMemCreate (uint32 *Id, uint32 NBytes, const char* SegName); -int32 OS_ShMemSemTake (uint32 Id); -int32 OS_ShMemSemGive (uint32 Id); -int32 OS_ShMemAttach (cpuaddr * Address, uint32 Id); -int32 OS_ShMemGetIdByName (uint32 *ShMemId, const char *SegName ); - -/* -** Heap API -*/ -int32 OS_HeapGetInfo (OS_heap_prop_t *heap_prop); - -/* -** API for useful debugging function -*/ -int32 OS_GetErrorName (int32 error_num, os_err_name_t* err_name); - - -/* -** Abstraction for printf statements -*/ -void OS_printf( const char *string, ...) OS_PRINTF(1,2); -void OS_printf_disable(void); -void OS_printf_enable(void); - -/* -** Call to exit the running application -** Normally embedded applications run forever, but for debugging purposes -** (unit testing for example) this is needed in order to end the test -*/ -void OS_ApplicationExit(int32 Status); - -#endif diff --git a/src/components/interface/cFE/osapi-os-filesys.h b/src/components/interface/cFE/osapi-os-filesys.h deleted file mode 100644 index b51bf77b9a..0000000000 --- a/src/components/interface/cFE/osapi-os-filesys.h +++ /dev/null @@ -1,440 +0,0 @@ -/* -** File: osapi-os-filesys.h -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software was created at NASAs Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Author: Alan Cudmore Code 582 -** -** Purpose: Contains functions prototype definitions and variables declarations -** for the OS Abstraction Layer, File System module -** -** $Revision: 1.11 $ -** -** $Date: 2013/12/16 12:57:41GMT-05:00 $ -** -** $Log: osapi-os-filesys.h $ -** Revision 1.11 2013/12/16 12:57:41GMT-05:00 acudmore -** Added macros for Volume name length and physical device name length -** Revision 1.10 2013/07/29 12:05:48GMT-05:00 acudmore -** Added define for device and volume name length -** Revision 1.9 2013/07/25 14:31:21GMT-05:00 acudmore -** Added prototype and datatype for OS_GetFsInfo -** Revision 1.8 2011/12/05 12:04:21GMT-05:00 acudmore -** Added OS_rewinddir API -** Revision 1.7 2011/04/05 16:01:12EDT acudmore -** Added OS_CloseFileByName and OS_CloseAllFiles -** Revision 1.6 2010/11/15 11:04:38EST acudmore -** Added OS_FileOpenCheck function. -** Revision 1.5 2010/11/12 12:00:18EST acudmore -** replaced copyright character with (c) and added open source notice where needed. -** Revision 1.4 2010/02/01 12:28:57EST acudmore -** Added OS_fsBytesFree API -** Revision 1.3 2010/01/25 14:44:26EST acudmore -** renamed "new" variable to avoid C++ reserved name conflict. -** Revision 1.2 2009/07/14 15:16:05EDT acudmore -** Added OS_TranslatePath to the API -** Revision 1.1 2008/04/20 22:36:01EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/os/inc/project.pj -** Revision 1.1 2007/10/16 16:14:52EDT apcudmore -** Initial revision -** Member added to project d:/mksdata/MKS-OSAL-REPOSITORY/src/os/inc/project.pj -** Revision 1.1 2007/08/24 13:43:24EDT apcudmore -** Initial revision -** Member added to project d:/mksdata/MKS-CFE-PROJECT/fsw/cfe-core/os/inc/project.pj -** Revision 1.17 2007/06/07 09:59:14EDT njyanchik -** I replaced the second OS_cp definition with OS_mv -** Revision 1.16 2007/06/05 16:25:33EDT apcudmore -** Increased Number of volume table entries from 10 to 14. -** Added 2 extra EEPROM disk mappings to RAD750 Volume table + 2 spares -** Added 4 spares to every other volume table. -** Revision 1.15 2007/05/25 09:17:56EDT njyanchik -** I added the rmfs call to the OSAL and updated the unit test stubs to match -** Revision 1.14 2007/03/21 10:15:29EST njyanchik -** I mistakenly put the wrong length in for the path in the OS_FDTableEntry structure, and I added -** some code that will set and out of range file descriptors .IsValid flag to false in OS_FDGetInfo -** Revision 1.13 2007/03/06 11:52:46EST njyanchik -** This change goes with the previous CP, I forgot to include it -** Revision 1.12 2007/02/28 14:57:45EST njyanchik -** The updates for supporting copying and moving files are now supported -** Revision 1.11 2007/02/27 15:22:11EST njyanchik -** This CP has the initial import of the new file descripor table mechanism -** Revision 1.10 2006/12/20 10:27:09EST njyanchik -** This change package incorporates all the changes necessary for the addition -** of a new API to get the real physical drive undernieth a mount point -** Revision 1.9 2006/11/14 14:44:28GMT-05:00 njyanchik -** Checks were added to the OS fs calls that look at the return of a function that -** changes the name of paths from abstracted to local path names. -** Revision 1.8 2006/10/30 16:12:19GMT-05:00 apcudmore -** Updated Compact flash and RAM device names for vxWorks 6.2 changes. -** Revision 1.7 2006/10/25 11:31:18EDT njyanchik -** This CP incorporates changes to every bsp_voltab.c file. I increased the number -** entries in the volume table to 10. I also changed the #define in the os_filesys.h -** file for the number of entries to match. -** -** This update also includes adding the prototype for OS_initfs in os_filesys.h -** Revision 1.6 2006/09/26 09:03:46GMT-05:00 njyanchik -** Contains the initial import of the ES Shell commands interface -** Revision 1.5 2006/07/25 15:37:52EDT njyanchik -** It turns out the both the FS app and the OSAL were incorrect where file descriptors are -** concerned. the file descriptors should be int32 across the board. -** Revision 1.4 2006/01/20 11:56:18EST njyanchik -** Fixed header file information to match api document -** Revision 1.26 2005/07/12 17:13:56 nyanchik -** Moved the Volume table to a bsp table in the arch directories. -** -** Revision 1.2 2005/07/11 16:26:57EDT apcudmore -** OSAPI 2.0 integration -** Revision 1.25 2005/07/06 16:11:17 nyanchik -** *** empty log message *** -** -** Revision 1.24 2005/07/05 18:34:55 nyanchik -** fixed issues found in code walkthrogh. Also removed the OS_Info* functions that are going in the BSP -** -** Revision 1.23 2005/06/17 19:46:34 nyanchik -** added new file system style to linux and rtems. -** -** Revision 1.22 2005/06/15 16:43:48 nyanchik -** added extra parenthesis for the .h file # defines -** -** Revision 1.21 2005/06/06 14:17:42 nyanchik -** added headers to osapi-os-core.h and osapi-os-filesys.h -** -** Revision 1.20 2005/06/02 18:04:24 nyanchik -** *** empty log message *** -** -** Revision 1.1 2005/03/15 18:26:32 nyanchik -** *** empty log message *** -** -** -** Date Written: -** -** -*/ - -#ifndef _osapi_filesys_ -#define _osapi_filesys_ -#include -#include -#include -#include - -#define OS_READ_ONLY 0 -#define OS_WRITE_ONLY 1 -#define OS_READ_WRITE 2 - -#define OS_SEEK_SET 0 -#define OS_SEEK_CUR 1 -#define OS_SEEK_END 2 - -#define OS_CHK_ONLY 0 -#define OS_REPAIR 1 - -#define FS_BASED 0 -#define RAM_DISK 1 -#define EEPROM_DISK 2 -#define ATA_DISK 3 - - -/* -** Number of entries in the internal volume table -*/ -#define NUM_TABLE_ENTRIES 14 - -/* -** Length of a Device and Volume name -*/ -#define OS_FS_DEV_NAME_LEN 32 -#define OS_FS_PHYS_NAME_LEN 64 -#define OS_FS_VOL_NAME_LEN 32 - - -/* -** Defines for File System Calls -*/ -/* - * NOTE - these values used to overlap with the - * other OSAPI error codes. They now start at -100 - * to avoid this overlap. - */ -#define OS_FS_ERR_PATH_TOO_LONG (-103) -#define OS_FS_ERR_NAME_TOO_LONG (-104) -#define OS_FS_ERR_DRIVE_NOT_CREATED (-106) -#define OS_FS_ERR_DEVICE_NOT_FREE (-107) -#define OS_FS_ERR_PATH_INVALID (-108) - - -/* - * Map some codes used by the file API back to the generic counterparts - * where there is overlap between them. Do not duplicate error codes. - */ -#define OS_FS_SUCCESS OS_SUCCESS -#define OS_FS_ERROR OS_ERROR -#define OS_FS_ERR_INVALID_POINTER OS_INVALID_POINTER -#define OS_FS_ERR_NO_FREE_FDS OS_ERR_NO_FREE_IDS -#define OS_FS_ERR_INVALID_FD OS_ERR_INVALID_ID -#define OS_FS_UNIMPLEMENTED OS_ERR_NOT_IMPLEMENTED - - -/* This typedef is for the OS_FS_GetErrorName function, to ensure - * everyone is making an array of the same length - * - * Implementation note for developers: - * - * os_fs_err_name_t is now equivalent to the OSAL "os_err_name_t" typedef, - * to preserve source code compatibility with anything using the OS_FS_GetErrorName api - * - * The sizes of strings in OSAL functions are built with os_fs_err_name_t's - * limits in mind. Always check the uses of os_fs_err_name_t when changing - * os_err_name_t. - */ -typedef os_err_name_t os_fs_err_name_t; - - -/* -** Internal structure of the OS volume table for -** mounted file systems and path translation -*/ -typedef struct -{ - char DeviceName [OS_FS_DEV_NAME_LEN]; - char PhysDevName [OS_FS_PHYS_NAME_LEN]; - uint32 VolumeType; - uint8 VolatileFlag; - uint8 FreeFlag; - uint8 IsMounted; - char VolumeName [OS_FS_VOL_NAME_LEN]; - char MountPoint [OS_MAX_PATH_LEN]; - uint32 BlockSize; - -}OS_VolumeInfo_t; - -typedef struct -{ - int32 OSfd; /* The underlying OS's file descriptor */ - char Path[OS_MAX_PATH_LEN]; /* The path of the file opened */ - uint32 User; /* The task id of the task who opened the file*/ - uint8 IsValid; /* Whether or not this entry is valid */ -}OS_FDTableEntry; - -typedef struct -{ - uint32 MaxFds; /* Total number of file descriptors */ - uint32 FreeFds; /* Total number that are free */ - uint32 MaxVolumes; /* Maximum number of volumes */ - uint32 FreeVolumes; /* Total number of volumes free */ -} os_fsinfo_t; - -/* modified to posix calls, since all of the - * applicable OSes use the posix calls */ - -typedef struct stat os_fstat_t; -typedef DIR* os_dirp_t; -typedef struct dirent os_dirent_t; -/* still don't know what this should be*/ -typedef unsigned long int os_fshealth_t; - -/* - * Exported Functions -*/ - - -/****************************************************************************** -** Standard File system API -******************************************************************************/ -/* - * Initializes the File System functions -*/ - -int32 OS_FS_Init(void); - -/* - * Creates a file specified by path -*/ -int32 OS_creat (const char *path, int32 access); - -/* - * Opend a file for reading/writing. Returns file descriptor -*/ -int32 OS_open (const char *path, int32 access, uint32 mode); - -/* - * Closes an open file. -*/ -int32 OS_close (int32 filedes); - -/* - * Reads nbytes bytes from file into buffer -*/ -int32 OS_read (int32 filedes, void *buffer, uint32 nbytes); - -/* - * Write nybytes bytes of buffer into the file -*/ -int32 OS_write (int32 filedes, void *buffer, uint32 nbytes); - -/* - * Changes the permissions of a file -*/ -int32 OS_chmod (const char *path, uint32 access); - -/* - * Returns file status information in filestats -*/ -int32 OS_stat (const char *path, os_fstat_t *filestats); - -/* - * Seeks to the specified position of an open file -*/ -int32 OS_lseek (int32 filedes, int32 offset, uint32 whence); - -/* - * Removes a file from the file system -*/ -int32 OS_remove (const char *path); - -/* - * Renames a file in the file system -*/ -int32 OS_rename (const char *old_filename, const char *new_filename); - -/* - * copies a single file from src to dest -*/ -int32 OS_cp (const char *src, const char *dest); - -/* - * moves a single file from src to dest -*/ -int32 OS_mv (const char *src, const char *dest); - -/* - * Copies the info of an open file to the structure -*/ -int32 OS_FDGetInfo (int32 filedes, OS_FDTableEntry *fd_prop); - -/* -** Check to see if a file is open -*/ -int32 OS_FileOpenCheck(char *Filename); - -/* -** Close all open files -*/ -int32 OS_CloseAllFiles(void); - -/* -** Close a file by filename -*/ -int32 OS_CloseFileByName(char *Filename); - - -/****************************************************************************** -** Directory API -******************************************************************************/ - -/* - * Makes a new directory -*/ -int32 OS_mkdir (const char *path, uint32 access); - -/* - * Opens a directory for searching -*/ -os_dirp_t OS_opendir (const char *path); - -/* - * Closes an open directory -*/ -int32 OS_closedir(os_dirp_t directory); - -/* - * Rewinds an open directory -*/ -void OS_rewinddir(os_dirp_t directory); - -/* - * Reads the next object in the directory -*/ -os_dirent_t * OS_readdir (os_dirp_t directory); - -/* - * Removes an empty directory from the file system. -*/ -int32 OS_rmdir (const char *path); - -/****************************************************************************** -** System Level API -******************************************************************************/ -/* - * Makes a file system -*/ -int32 OS_mkfs (char *address,char *devname, char *volname, - uint32 blocksize, uint32 numblocks); -/* - * Mounts a file system -*/ -int32 OS_mount (const char *devname, char *mountpoint); - -/* - * Initializes an existing file system -*/ -int32 OS_initfs (char *address,char *devname, char *volname, - uint32 blocksize, uint32 numblocks); - -/* - * removes a file system -*/ -int32 OS_rmfs (char *devname); - -/* - * Unmounts a mounted file system -*/ -int32 OS_unmount (const char *mountpoint); - -/* - * Returns the number of free blocks in a file system -*/ -int32 OS_fsBlocksFree (const char *name); - -/* -** Returns the number of free bytes in a file system -** Note the 64 bit data type to support filesystems that -** are greater than 4 Gigabytes -*/ -int32 OS_fsBytesFree (const char *name, uint64 *bytes_free); - -/* - * Checks the health of a file system and repairs it if neccesary -*/ -os_fshealth_t OS_chkfs (const char *name, boolean repair); - -/* - * Returns in the parameter the physical drive underneith the mount point -*/ -int32 OS_FS_GetPhysDriveName (char * PhysDriveName, char * MountPoint); - -/* -** Translates a OSAL Virtual file system path to a host Local path -*/ -int32 OS_TranslatePath ( const char *VirtualPath, char *LocalPath); - -/* -** Returns information about the file system in an os_fsinfo_t -*/ -int32 OS_GetFsInfo(os_fsinfo_t *filesys_info); - -/****************************************************************************** -** Shell API -******************************************************************************/ - -/* executes the shell command passed into is and writes the output of that - * command to the file specified by the given OSAPI file descriptor */ -int32 OS_ShellOutputToFile(char* Cmd, int32 OS_fd); -#endif diff --git a/src/components/interface/cFE/osapi-os-loader.h b/src/components/interface/cFE/osapi-os-loader.h deleted file mode 100644 index f14845ff65..0000000000 --- a/src/components/interface/cFE/osapi-os-loader.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -** File: osapi-os-loader.h -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software was created at NASAs Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Author: Alan Cudmore - Code 582 -** -** Purpose: Contains functions prototype definitions and variables declarations -** for the OS Abstraction Layer, Object file loader API -** -** $Revision: 1.5 $ -** -** $Date: 2013/07/25 10:02:08GMT-05:00 $ -** -** $Log: osapi-os-loader.h $ -** Revision 1.5 2013/07/25 10:02:08GMT-05:00 acudmore -** removed circular include "osapi.h" -** Revision 1.4 2010/11/12 12:00:18GMT-05:00 acudmore -** replaced copyright character with (c) and added open source notice where needed. -** Revision 1.3 2010/02/01 12:38:06EST acudmore -** added return code to OS_ModuleTableInit -** Revision 1.2 2008/06/20 15:13:43EDT apcudmore -** Checked in new Module loader/symbol table functionality -** Revision 1.1 2008/04/20 22:36:02EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/os/inc/project.pj -** Revision 1.1 2008/02/07 11:08:24EST apcudmore -** Initial revision -** Member added to project d:/mksdata/MKS-OSAL-REPOSITORY/src/os/inc/project.pj -** -** -*/ - -#ifndef _osapi_loader_ -#define _osapi_loader_ - -/* -** Defines -*/ - - -/* -** Typedefs -*/ - -typedef struct -{ - uint32 valid; - uint32 flags; - cpuaddr code_address; - cpuaddr code_size; - cpuaddr data_address; - cpuaddr data_size; - cpuaddr bss_address; - cpuaddr bss_size; -} OS_module_address_t; - -typedef struct -{ - cpuaddr entry_point; - uint32 host_module_id; - char filename[OS_MAX_PATH_LEN]; - char name[OS_MAX_API_NAME]; - OS_module_address_t addr; -} OS_module_prop_t; - -/* - * Define the former "OS_module_record_t" type as equivalent - * to the OS_module_prop_t. This is what the OS_ModuleInfo() - * will output. It used to be the same as the internal record - * just without all the fields filled in. This has been changed - * to make it a separate structure, which will allow the internal - * implementation to change without further changing the API. - * - * Ideally OS_module_record_t type should be removed to avoid confusion, - * but this would break existing code that calls OS_ModuleInfo(). - */ -#ifndef OSAL_OMIT_DEPRECATED -typedef OS_module_prop_t OS_module_record_t; -#endif - -/* -** Loader API -*/ -int32 OS_ModuleTableInit ( void ); - -int32 OS_SymbolLookup (cpuaddr *symbol_address, const char *symbol_name ); - -int32 OS_SymbolTableDump ( const char *filename, uint32 size_limit ); - -int32 OS_ModuleLoad ( uint32 *module_id, const char *module_name, const char *filename ); - -int32 OS_ModuleUnload ( uint32 module_id ); - -int32 OS_ModuleInfo ( uint32 module_id, OS_module_prop_t *module_info ); - - -#endif diff --git a/src/components/interface/cFE/osapi-os-net.h b/src/components/interface/cFE/osapi-os-net.h deleted file mode 100644 index 41335e0699..0000000000 --- a/src/components/interface/cFE/osapi-os-net.h +++ /dev/null @@ -1,129 +0,0 @@ -/* -** File: osapi-os-net.h -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software was created at NASAs Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Author: Alan Cudmore Code 582 -** -** Purpose: Contains functions prototype definitions and variables declarations -** for the OS Abstraction Layer, Network Module -** -** $Revision: 1.2 $ -** -** $Date: 2010/11/12 12:00:19GMT-05:00 $ -** -** $Log: osapi-os-net.h $ -** Revision 1.2 2010/11/12 12:00:19GMT-05:00 acudmore -** replaced copyright character with (c) and added open source notice where needed. -** Revision 1.1 2008/04/20 22:36:02EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/os/inc/project.pj -** Revision 1.1 2007/10/16 16:14:52EDT apcudmore -** Initial revision -** Member added to project d:/mksdata/MKS-OSAL-REPOSITORY/src/os/inc/project.pj -** Revision 1.1 2007/08/24 13:43:25EDT apcudmore -** Initial revision -** Member added to project d:/mksdata/MKS-CFE-PROJECT/fsw/cfe-core/os/inc/project.pj -** Revision 1.3 2006/01/20 11:56:18EST njyanchik -** Fixed header file information to match api document -** Revision 1.4 2005/06/07 16:49:31 nyanchik -** changed returns code for osapi.c to all int32 from uint32 -** -** Revision 1.3 2005/03/22 19:04:54 acudmore -** fixed uint type -** -** Revision 1.2 2005/03/22 18:59:33 acudmore -** updated prototype -** -** Revision 1.1 2005/03/22 18:58:51 acudmore -** added osapi network interface -** -** Revision 1.1 2005/03/15 18:26:32 nyanchik -** *** empty log message *** -** -** -** Date Written: -** -** -*/ -#ifndef _osapi_network_ -#define _osapi_network_ - -/* - * Sockets API wrapper functions - */ - -typedef enum -{ - OS_SocketDomain_INVALID, -#ifdef OS_INCLUDE_NETWORK - OS_SocketDomain_INET, - OS_SocketDomain_INET6, -#endif - OS_SocketDomain_MAX -} OS_SocketDomain_t; - -typedef enum -{ - OS_SocketType_INVALID, -#ifdef OS_INCLUDE_NETWORK - OS_SocketType_DATAGRAM, - OS_SocketType_STREAM, -#endif - OS_SocketType_MAX -} OS_SocketType_t; - -#ifdef OS_INCLUDE_NETWORK - -/* NOTE - osconfig.h may optionally specify the value for OS_SOCADDR_MAX_LEN */ -#include - -#ifndef OS_SOCKADDR_MAX_LEN -#define OS_SOCKADDR_MAX_LEN 32 -#endif - -typedef struct -{ - uint32 ActualLength; - char AddrData[OS_SOCKADDR_MAX_LEN]; -} OS_SockAddr_t; - -typedef struct -{ - char name [OS_MAX_API_NAME]; - uint32 creator; -} OS_socket_prop_t; - - -int32 OS_SocketOpen(uint32 *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t Type); -int32 OS_SocketClose(uint32 sock_id); -int32 OS_SocketBind(uint32 sock_id, const OS_SockAddr_t *Addr); -int32 OS_SocketConnect(uint32 sock_id, const OS_SockAddr_t *Addr, int32 timeout); -int32 OS_SocketAccept(uint32 sock_id, uint32 *connsock_id, OS_SockAddr_t *Addr, int32 timeout); -int32 OS_SocketRecvFrom(uint32 sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout); -int32 OS_SocketSendTo(uint32 sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr); -int32 OS_SocketGetIdByName (uint32 *sock_id, const char *sock_name); -int32 OS_SocketGetInfo (uint32 sock_id, OS_socket_prop_t *sock_prop); - -int32 OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain); -int32 OS_SocketAddrToString(char *buffer, uint32 buflen, const OS_SockAddr_t *Addr); -int32 OS_SocketAddrFromString(OS_SockAddr_t *Addr, const char *string); -int32 OS_SocketAddrGetPort(uint16 *PortNum, const OS_SockAddr_t *Addr); -int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum); - -/* -** OS_NetworkGetID is currently [[deprecated]] as its behavior is -** unknown and not consistent across operating systems. -*/ -int32 OS_NetworkGetID (void); -int32 OS_NetworkGetHostName (char *host_name, uint32 name_len); - -#endif /* OS_INCLUDE_NETWORK */ - -#endif diff --git a/src/components/interface/cFE/osapi-os-timer.h b/src/components/interface/cFE/osapi-os-timer.h deleted file mode 100644 index 89ca47db9e..0000000000 --- a/src/components/interface/cFE/osapi-os-timer.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -** File: osapi-os-timer.h -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software was created at NASAs Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Author: Alan Cudmore - Code 582 -** -** Purpose: Contains functions prototype definitions and variable declarations -** for the OS Abstraction Layer, Timer API -** -** $Revision: 1.5 $ -** -** $Date: 2013/07/25 10:02:20GMT-05:00 $ -** -** $Log: osapi-os-timer.h $ -** Revision 1.5 2013/07/25 10:02:20GMT-05:00 acudmore -** removed circular include "osapi.h" -** Revision 1.4 2010/11/12 12:00:19GMT-05:00 acudmore -** replaced copyright character with (c) and added open source notice where needed. -** Revision 1.3 2010/02/01 12:38:34EST acudmore -** Added return code to OS_TimerAPIInit -** Revision 1.2 2008/08/26 13:52:52EDT apcudmore -** removed linux specific define -** Revision 1.1 2008/08/20 16:12:07EDT apcudmore -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/os/inc/project.pj -** -** -*/ - -#ifndef _osapi_timer_ -#define _osapi_timer_ - -/* -** Typedefs -*/ -typedef void (*OS_TimerCallback_t)(uint32 timer_id); -typedef int32 (*OS_TimerSync_t)(uint32 timer_id); - -typedef struct -{ - char name[OS_MAX_API_NAME]; - uint32 creator; - uint32 start_time; - uint32 interval_time; - uint32 accuracy; - -} OS_timer_prop_t; - -typedef struct -{ - char name[OS_MAX_API_NAME]; - uint32 creator; - uint32 interval_time; - uint32 accuracy; -} OS_timebase_prop_t; - -/* -** Timer API -*/ -int32 OS_TimerAPIInit (void); - -int32 OS_TimeBaseCreate (uint32 *timer_id, const char *timebase_name, OS_TimerSync_t external_sync); -int32 OS_TimeBaseSet (uint32 timer_id, uint32 start_time, uint32 interval_time); -int32 OS_TimeBaseDelete (uint32 timer_id); -int32 OS_TimeBaseGetIdByName (uint32 *timer_id, const char *timebase_name); - -int32 OS_TimerCreate (uint32 *timer_id, const char *timer_name, uint32 *clock_accuracy, OS_TimerCallback_t callback_ptr); -int32 OS_TimerAdd (uint32 *timer_id, const char *timer_name, uint32 timebase_id, OS_ArgCallback_t callback_ptr, void *callback_arg); -int32 OS_TimerSet (uint32 timer_id, uint32 start_time, uint32 interval_time); -int32 OS_TimerDelete (uint32 timer_id); - -int32 OS_TimerGetIdByName (uint32 *timer_id, const char *timer_name); -int32 OS_TimerGetInfo (uint32 timer_id, OS_timer_prop_t *timer_prop); - -#endif diff --git a/src/components/interface/cFE/osapi-version.h b/src/components/interface/cFE/osapi-version.h deleted file mode 100644 index 5c2a3afb83..0000000000 --- a/src/components/interface/cFE/osapi-version.h +++ /dev/null @@ -1,69 +0,0 @@ -/************************************************************************ -** File: -** $Id: osapi-version.h 1.10 2014/01/23 16:33:31GMT-05:00 acudmore Exp $ -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software was created at NASAs Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Purpose: -** The OSAL version numbers -** -** Notes: -** -** $Log: osapi-version.h $ -** Revision 1.10 2014/01/23 16:33:31GMT-05:00 acudmore -** Update for 4.1 release -** Revision 1.9 2013/01/16 14:35:18GMT-05:00 acudmore -** updated version label -** Revision 1.8 2012/04/16 14:57:04GMT-05:00 acudmore -** Updated version label to 3.5.0.0 -** Revision 1.7 2012/01/17 16:04:29EST acudmore -** Updated version to 3.4.1 -** Revision 1.6 2011/12/05 15:45:16EST acudmore -** Updated version label to 3.4.0 -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/os/inc/project.pj -** -*************************************************************************/ -#ifndef _osapi_version_h_ -#define _osapi_version_h_ - -/* - * Note about the OS_REVISION value: - * During development of the "next" version of OSAL (whatever number it might be), the - * OS_REVISION value should be something high (>90) to indicate the fact that this is a development - * version and not an official release version. For instance, at the time of this writing - * the official version is 4.1.1 and the next version would likely be 4.2.0. So anyone - * who uses the "bleeding edge" development branch before 4.2.0 is officially released will - * get a version that reads e.g. "4.1.91" to show that this is a pre-4.2 build. - * - * This still leaves room for patches to be applied to 4.1.1 to produce 4.1.2 if needed. - * - * During development, if an API-affecting change is introduced then the OS_REVISION value should - * be incremented with it to indicate this. Client code that depends on the new API can do a "#if" - * against the development version number e.g. "#if OSAL_API_VERSION >= 40191" and this check - * will still be valid after the version becomes 40200 (although at some point it can be cleaned - * up to reflect the official version number, it is not going to break the build in the meantime). - */ - -#define OS_MAJOR_VERSION 4 -#define OS_MINOR_VERSION 2 -#define OS_REVISION 1 -#define OS_MISSION_REV 0 - -/** - * Combine the revision components into a single value that application code can check against - * e.g. "#if OSAL_API_VERSION >= 40100" would check if some feature added in OSAL 4.1 is present. - */ -#define OSAL_API_VERSION ((OS_MAJOR_VERSION * 10000) + (OS_MINOR_VERSION * 100) + OS_REVISION) - -#endif /* _osapi_version_h_ */ - -/************************/ -/* End of File Comment */ -/************************/ diff --git a/src/components/interface/cFE/osapi.h b/src/components/interface/cFE/osapi.h deleted file mode 100644 index b22991548d..0000000000 --- a/src/components/interface/cFE/osapi.h +++ /dev/null @@ -1,149 +0,0 @@ -/* -** File: osapi.h -** -** Copyright (c) 2004-2006, United States government as represented by the -** administrator of the National Aeronautics Space Administration. -** All rights reserved. This software was created at NASAs Goddard -** Space Flight Center pursuant to government contracts. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** Author: Alan Cudmore - Code 582 -** -** Purpose: Contains functions prototype definitions and variables declarations -** for the OS Abstraction Layer, Core OS module -** -** $Revision: 1.10 $ -** -** $Date: 2013/07/25 10:01:32GMT-05:00 $ -** -** $Log: osapi.h $ -** Revision 1.10 2013/07/25 10:01:32GMT-05:00 acudmore -** Added C++ support -** Revision 1.9 2010/11/12 12:00:17GMT-05:00 acudmore -** replaced copyright character with (c) and added open source notice where needed. -** Revision 1.8 2010/03/08 15:57:20EST acudmore -** include new OSAL version header file -** Revision 1.7 2009/08/10 14:01:10EDT acudmore -** Reset OSAL version for trunk -** Revision 1.6 2009/08/10 13:55:49EDT acudmore -** Updated OSAL version defines to 3.0 -** Revision 1.5 2009/06/10 14:15:55EDT acudmore -** Removed HAL include files. HAL code was removed from OSAL. -** Revision 1.4 2008/08/20 16:12:51EDT apcudmore -** Updated timer error codes -** Revision 1.3 2008/08/20 15:46:27EDT apcudmore -** Add support for timer API -** Revision 1.2 2008/06/20 15:13:43EDT apcudmore -** Checked in new Module loader/symbol table functionality -** Revision 1.1 2008/04/20 22:36:02EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/os/inc/project.pj -** Revision 1.6 2008/02/14 11:29:10EST apcudmore -** Updated version define ( 2.11 ) -** Revision 1.5 2008/02/07 11:31:58EST apcudmore -** Fixed merge problem -** Revision 1.4 2008/02/07 11:07:29EST apcudmore -** Added dynamic loader / Symbol lookup API -** -- API only, next release will have functionality -** Revision 1.2 2008/01/29 14:30:49EST njyanchik -** I added code to all the ports that allow the values of both binary and counting semaphores to be -** gotten through the OS_*SemGetInfo API. -** Revision 1.1 2007/10/16 16:14:52EDT apcudmore -** Initial revision -** Member added to project d:/mksdata/MKS-OSAL-REPOSITORY/src/os/inc/project.pj -** Revision 1.2 2007/09/28 15:46:49EDT rjmcgraw -** Updated version numbers to 5.0 -** Revision 1.1 2007/08/24 13:43:25EDT apcudmore -** Initial revision -** Member added to project d:/mksdata/MKS-CFE-PROJECT/fsw/cfe-core/os/inc/project.pj -** Revision 1.9.1.1 2007/05/21 08:58:51EDT njyanchik -** The trunk version number has been updated to version 0.0 -** Revision 1.9 2006/06/12 10:20:07EDT rjmcgraw -** Updated OS_MINOR_VERSION from 3 to 4 -** Revision 1.8 2006/02/03 09:30:45EST njyanchik -** Changed version number to 2.3 -** Revision 1.7 2006/01/20 11:56:16EST njyanchik -** Fixed header file information to match api document -** Revision 1.15 2005/11/09 13:35:49 nyanchik -** Revisions for 2.2 include: -** a new scheduler mapper for Linux and OS X -** addition of OS_printf function -** fixed issues that would cause warnings at compile time -** -** -*/ - -#ifndef _osapi_ -#define _osapi_ - -#include "common_types.h" - -#ifdef __cplusplus - extern "C" { -#endif - -#define OS_SUCCESS (0) -#define OS_ERROR (-1) -#define OS_INVALID_POINTER (-2) -#define OS_ERROR_ADDRESS_MISALIGNED (-3) -#define OS_ERROR_TIMEOUT (-4) -#define OS_INVALID_INT_NUM (-5) -#define OS_SEM_FAILURE (-6) -#define OS_SEM_TIMEOUT (-7) -#define OS_QUEUE_EMPTY (-8) -#define OS_QUEUE_FULL (-9) -#define OS_QUEUE_TIMEOUT (-10) -#define OS_QUEUE_INVALID_SIZE (-11) -#define OS_QUEUE_ID_ERROR (-12) -#define OS_ERR_NAME_TOO_LONG (-13) -#define OS_ERR_NO_FREE_IDS (-14) -#define OS_ERR_NAME_TAKEN (-15) -#define OS_ERR_INVALID_ID (-16) -#define OS_ERR_NAME_NOT_FOUND (-17) -#define OS_ERR_SEM_NOT_FULL (-18) -#define OS_ERR_INVALID_PRIORITY (-19) -#define OS_INVALID_SEM_VALUE (-20) -#define OS_ERR_FILE (-27) -#define OS_ERR_NOT_IMPLEMENTED (-28) -#define OS_TIMER_ERR_INVALID_ARGS (-29) -#define OS_TIMER_ERR_TIMER_ID (-30) -#define OS_TIMER_ERR_UNAVAILABLE (-31) -#define OS_TIMER_ERR_INTERNAL (-32) - -/* -** Defines for Queue Timeout parameters -*/ -#define OS_PEND (-1) -#define OS_CHECK (0) - -#include "osapi-version.h" - -/* -** Include the configuration file -*/ -#include "osconfig.h" - -/* -** Include the OS API modules -*/ -#include "osapi-os-core.h" -#include "osapi-os-filesys.h" -#include "osapi-os-net.h" -#include "osapi-os-loader.h" -#include "osapi-os-timer.h" - -/* - ****************************************************************************** - * Items below here are internal OSAL-use definitions and are not part of the - * OSAL API - ***************************************************************************** - */ - -#ifdef __cplusplus - } -#endif - -#endif - diff --git a/src/components/interface/cFE/osconfig.h b/src/components/interface/cFE/osconfig.h deleted file mode 100644 index f3fb52439b..0000000000 --- a/src/components/interface/cFE/osconfig.h +++ /dev/null @@ -1,219 +0,0 @@ -/****************************************************************************** -** File: osconfig.h -** $Id: osconfig.h 1.2 2013/12/16 13:07:17GMT-05:00 acudmore Exp $ -** -** Purpose: -** This header file contains the OS API configuration parameters. -** -** Author: A. Cudmore -** -** Notes: -** -** $Date: 2013/12/16 13:07:17GMT-05:00 $ -** $Revision: 1.2 $ -** $Log: osconfig.h $ -** Revision 1.2 2013/12/16 13:07:17GMT-05:00 acudmore -** use OS_FS_PHYS_NAME_LEN macro instead of hard-coded value -** Revision 1.1 2013/07/19 14:05:01GMT-05:00 acudmore -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/src/bsp/pc-linux/config/project.pj -** Revision 1.8 2011/12/05 12:41:15GMT-05:00 acudmore -** Removed OS_MEM_TABLE_SIZE parameter -** Revision 1.7 2009/07/14 14:24:53EDT acudmore -** Added parameter for local path size. -** Revision 1.6 2009/07/07 14:01:02EDT acudmore -** Changed OS_MAX_NUM_OPEN_FILES to 50 to preserve data/telmetry space -** Revision 1.5 2009/07/07 13:58:22EDT acudmore -** Added OS_STATIC_LOADER define to switch between static and dynamic loaders. -** Revision 1.4 2009/06/04 11:43:43EDT rmcgraw -** DCR8290:1 Increased settings for max tasks,queues,sems and modules -** Revision 1.3 2008/08/20 15:49:37EDT apcudmore -** Add OS_MAX_TIMERS parameter for Timer API -** Revision 1.2 2008/06/20 15:17:56EDT apcudmore -** Added conditional define for Module Loader API configuration -** Revision 1.1 2008/04/20 22:35:19EDT ruperera -** Initial revision -** Member added to project c:/MKSDATA/MKS-REPOSITORY/MKS-OSAL-REPOSITORY/build/inc/project.pj -** Revision 1.6 2008/02/12 13:27:59EST apcudmore -** New API updates: -** - fixed RTEMS osapi compile error -** - related makefile fixes -** - header file parameter update -** -** Revision 1.1 2005/06/09 10:57:58EDT rperera -** Initial revision -** -******************************************************************************/ - -#ifndef _osconfig_ -#define _osconfig_ - -/* -** Platform Configuration Parameters for the OS API -*/ - -#define OS_MAX_TASKS 64 -#define OS_MAX_QUEUES 64 -#define OS_MAX_COUNT_SEMAPHORES 20 -#define OS_MAX_BIN_SEMAPHORES 20 -#define OS_MAX_MUTEXES 20 - -/* -** Maximum length for an absolute path name -*/ -#define OS_MAX_PATH_LEN 64 - -/* -** Maximum length for a local or host path/filename. -** This parameter can consist of the OSAL filename/path + -** the host OS physical volume name or path. -*/ -#define OS_MAX_LOCAL_PATH_LEN (OS_MAX_PATH_LEN + OS_FS_PHYS_NAME_LEN) - -/* -** The maxium length allowed for a object (task,queue....) name -*/ -#define OS_MAX_API_NAME 20 - -/* -** The maximum length for a file name -*/ -#define OS_MAX_FILE_NAME 20 - -/* -** These defines are for OS_printf -*/ -#define OS_BUFFER_SIZE 172 -#define OS_BUFFER_MSG_DEPTH 100 - -/* This #define turns on a utility task that - * will read the statements to print from - * the OS_printf function. If you want OS_printf - * to print the text out itself, comment this out - * - * NOTE: The Utility Task #defines only have meaning - * on the VxWorks operating systems - */ - -#define OS_UTILITY_TASK_ON - - -#ifdef OS_UTILITY_TASK_ON - #define OS_UTILITYTASK_STACK_SIZE 2048 - /* some room is left for other lower priority tasks */ - #define OS_UTILITYTASK_PRIORITY 245 -#endif - - -/* -** the size of a command that can be passed to the underlying OS -*/ -#define OS_MAX_CMD_LEN 1000 - -/* -** This define will include the OS network API. -** It should be turned off for targtets that do not have a network stack or -** device ( like the basic RAD750 vxWorks BSP ) -*/ -#define OS_INCLUDE_NETWORK - -/* -** This is the maximum number of open file descriptors allowed at a time -*/ -#define OS_MAX_NUM_OPEN_FILES 50 - -/* -** This defines the filethe input command of OS_ShellOutputToFile -** is written to in the VxWorks6 port -*/ -#define OS_SHELL_CMD_INPUT_FILE_NAME "/ram/OS_ShellCmd.in" - -/* -** This define sets the queue implentation of the Linux port to use sockets -** commenting this out makes the Linux port use the POSIX message queues. -*/ -/* #define OSAL_SOCKET_QUEUE */ - -/* -** Module loader/symbol table is optional -*/ -#define OS_INCLUDE_MODULE_LOADER - -#ifdef OS_INCLUDE_MODULE_LOADER - /* - ** This define sets the size of the OS Module Table, which keeps track of the loaded modules in - ** the running system. This define must be set high enough to support the maximum number of - ** loadable modules in the system. If the the table is filled up at runtime, a new module load - ** would fail. - */ - #define OS_MAX_MODULES 20 - - /* - ** The Static Loader define is used for switching between the Dynamic and Static loader implementations. - */ - /* #define OS_STATIC_LOADER */ - -#endif - - -/* -** This define sets the maximum symbol name string length. It is used in implementations that -** support the symbols and symbol lookup. -*/ -#define OS_MAX_SYM_LEN 64 - -/* -** This define sets the maximum number of time base objects -** The limit depends on the underlying OS and the resources it offers, but in general -** these are a limited resource and only a handful can be created. -** -** This is included as an example, for OSAL implementations that do not [yet] support -** separate timebase objects, this directive will be ignored. However, the OSAL unit -** test stub code does require that this is defined. -*/ -#define OS_MAX_TIMEBASES 5 - -/* -** This define sets the maximum number of user timers available -** The limit here depends on whether the OSAL implementation uses limited resources -** for a timer object; in the case of the newer "posix-ng" and "rtems-ng" variants, -** the "timebase" allocates the OS resources and the timer does not use any additional -** OS resources. Therefore this limit can be higher. -*/ -#define OS_MAX_TIMERS 5 - -/* -** This define sets the maximum number of open directories -*/ -#define OS_MAX_NUM_OPEN_DIRS 4 - -/* -** This define sets the maximum depth of an OSAL message queue. On some implementations this may -** affect the overall OSAL memory footprint so it may be beneficial to set this limit according to -** what the application actually needs. -*/ -#define OS_QUEUE_MAX_DEPTH 50 - -/* - * If OS_DEBUG_PRINTF is defined, this will enable the "OS_DEBUG" statements in the code - * This should be left disabled in a normal build as it may affect real time performance as - * well as producing extra console output. - */ -#undef OS_DEBUG_PRINTF - -/* - * If OSAL_DEBUG_PERMISSIVE_MODE is defined, this will enable features to make the - * OSAL library compatible with a non-root (normal user mode) environment. In the PC-Linux/Posix - * build, this means: - * - A message queue deeper than the maximum system limit will be silently truncated - * to the maximum system limit (no error). - * - If the user does not have permission to create elevated priority tasks, then the tasks will - * be created at the default priority (no error). Note this behavior can also be forced by the - * OSAL_DEBUG_DISABLE_TASK_PRIORITIES macro below. - * - * Leaving this undefined will produce the default behavior, which is to return errors to the caller - * for these conditions. - */ -#define OSAL_DEBUG_PERMISSIVE_MODE - -#endif diff --git a/src/components/interface/cFE/psp_version.h b/src/components/interface/cFE/psp_version.h deleted file mode 100644 index 10c2eb4201..0000000000 --- a/src/components/interface/cFE/psp_version.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -** $Id: psp_version.h 1.2.2.3 2014/10/01 15:41:26GMT-05:00 sstrege Exp $ -** -** -** Copyright (c) 2004-2011, United States Government as represented by -** Administrator for The National Aeronautics and Space Administration. -** All Rights Reserved. -** -** This is governed by the NASA Open Source Agreement and may be used, -** distributed and modified only pursuant to the terms of that agreement. -** -** -** -** Purpose: -** Provide version identifiers for the cFE Platform Support Packages (PSP). -** -*/ - -#ifndef _psp_version_ -#define _psp_version_ - - -/* -** Macro Definitions -*/ -#define CFE_PSP_IMPL_MAJOR_VERSION 1 -#define CFE_PSP_IMPL_MINOR_VERSION 3 -#define CFE_PSP_IMPL_REVISION 0 -#define CFE_PSP_IMPL_MISSION_REV 0 - -#ifndef _ENHANCED_BUILD_ - -#define CFE_PSP_MAJOR_VERSION CFE_PSP_IMPL_MAJOR_VERSION -#define CFE_PSP_MINOR_VERSION CFE_PSP_IMPL_MINOR_VERSION -#define CFE_PSP_REVISION CFE_PSP_IMPL_REVISION -#define CFE_PSP_MISSION_REV CFE_PSP_IMPL_MISSION_REV - -/* For backwards compatibility */ -#define CFE_PSP_SUBMINOR_VERSION CFE_PSP_IMPL_REVISION - -#endif - -#endif /* _psp_version_ */ - diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index a4899501bc..a4cdf6fb6c 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -12,66 +12,22 @@ .text -cos_asm_server_stub(OS_printf) -cos_asm_server_stub(OS_TaskInstallDeleteHandler) -cos_asm_server_stub(OS_TaskDelay) - +cos_asm_server_stub(OS_IdleLoop) cos_asm_server_stub(CFE_ES_ExitApp) cos_asm_server_stub(CFE_ES_PerfLogAdd) cos_asm_server_stub(CFE_ES_RegisterApp) +cos_asm_server_stub(CFE_ES_RunLoop) + cos_asm_server_stub(CFE_EVS_Register) cos_asm_server_stub(CFE_EVS_SendEvent) + cos_asm_server_stub(CFE_SB_CreatePipe) cos_asm_server_stub(CFE_SB_GetCmdCode) cos_asm_server_stub(CFE_SB_GetMsgId) cos_asm_server_stub(CFE_SB_GetTotalMsgLength) +cos_asm_server_stub(CFE_SB_InitMsg) cos_asm_server_stub(CFE_SB_RcvMsg) cos_asm_server_stub(CFE_SB_SendMsg) cos_asm_server_stub(CFE_SB_Subscribe) cos_asm_server_stub(CFE_SB_TimeStampMsg) -cos_asm_server_stub(CFE_ES_RunLoop) -cos_asm_server_stub(CFE_SB_InitMsg) -cos_asm_server_stub(CFE_SB_MessageStringGet) -cos_asm_server_stub(CFE_SB_SubscribeEx) -cos_asm_server_stub(CFE_SB_Unsubscribe) - -cos_asm_server_stub(CFE_ES_CalculateCRC) -cos_asm_server_stub(CFE_ES_CopyToCDS) -cos_asm_server_stub(CFE_ES_CreateChildTask) -cos_asm_server_stub(CFE_ES_DeleteChildTask) -cos_asm_server_stub(CFE_ES_ExitChildTask) -cos_asm_server_stub(CFE_ES_GetAppID) -cos_asm_server_stub(CFE_ES_GetAppIDByName) -cos_asm_server_stub(CFE_ES_GetAppInfo) -cos_asm_server_stub(CFE_ES_GetAppName) -cos_asm_server_stub(CFE_ES_RegisterCDS) -cos_asm_server_stub(CFE_ES_RegisterChildTask) -cos_asm_server_stub(CFE_ES_RestoreFromCDS) -cos_asm_server_stub(CFE_ES_WaitForStartupSync) -cos_asm_server_stub(CFE_ES_WriteToSysLog) -cos_asm_server_stub(CFE_PSP_GetCFETextSegmentInfo) -cos_asm_server_stub(CFE_PSP_GetKernelTextSegmentInfo) -cos_asm_server_stub(CFE_PSP_MemCpy) -cos_asm_server_stub(CFE_PSP_MemSet) -cos_asm_server_stub(CFE_PSP_MemValidateRange) -cos_asm_server_stub(CFE_TBL_GetAddress) -cos_asm_server_stub(CFE_TBL_GetInfo) -cos_asm_server_stub(CFE_TBL_Load) -cos_asm_server_stub(CFE_TBL_Manage) -cos_asm_server_stub(CFE_TBL_Modified) -cos_asm_server_stub(CFE_TBL_Register) -cos_asm_server_stub(CFE_TBL_ReleaseAddress) -cos_asm_server_stub(CFE_TBL_Share) -cos_asm_server_stub(CFE_TBL_Unregister) -cos_asm_server_stub(OS_close) -cos_asm_server_stub(OS_open) - -cos_asm_server_stub(CFE_ES_GetPoolBuf) -cos_asm_server_stub(CFE_ES_PoolCreate) -cos_asm_server_stub(CFE_ES_PutPoolBuf) -cos_asm_server_stub(CFE_SB_GetUserData) -cos_asm_server_stub(CFE_TBL_DumpToBuffer) -cos_asm_server_stub(CFE_TBL_GetStatus) -cos_asm_server_stub(CFE_TBL_Update) -cos_asm_server_stub(CFE_TBL_Validate) diff --git a/src/components/lib/Makefile b/src/components/lib/Makefile index 851fdafc19..30ff8cb0f8 100644 --- a/src/components/lib/Makefile +++ b/src/components/lib/Makefile @@ -1,6 +1,6 @@ include Makefile.src Makefile.comp -LIB_OBJS=heap.o cobj_format.o cos_kernel_api.o cos_defkernel_api.o +LIB_OBJS=heap.o cobj_format.o cos_kernel_api.o cos_defkernel_api.o cFE_emu.o LIBS=$(LIB_OBJS:%.o=%.a) MANDITORY=c_stub.o cos_asm_upcall.o cos_asm_ainv.o cos_component.o MAND=$(MANDITORY_LIB) diff --git a/src/components/lib/cFE_emu.c b/src/components/lib/cFE_emu.c new file mode 100644 index 0000000000..3b53b2a9a9 --- /dev/null +++ b/src/components/lib/cFE_emu.c @@ -0,0 +1,21 @@ +#include + +// FIXME: Query the cFE to decide whether printf is enabled +int is_printf_enabled = 1; + +// FIXME: Point this at the real buffer size +#define OS_BUFFER_SIZE 4096 + +void OS_printf(const char *string, ...) +{ + if(is_printf_enabled) { + char s[OS_BUFFER_SIZE]; + va_list arg_ptr; + int ret, len = OS_BUFFER_SIZE; + + va_start(arg_ptr, string); + ret = vsnprintf(s, len, string, arg_ptr); + va_end(arg_ptr); + cos_llprint(s, ret); + } +} diff --git a/src/components/lib/sl/sl.c b/src/components/lib/sl/sl.c index c0c6bd531c..100db555d8 100644 --- a/src/components/lib/sl/sl.c +++ b/src/components/lib/sl/sl.c @@ -32,7 +32,7 @@ sl_cs_enter_contention(union sl_cs_intern *csi, union sl_cs_intern *cached, thdc if (!ps_cas(&g->lock.u.v, cached->v, csi->v)) return 1; } /* Switch to the owner of the critical section, with inheritance using our tcap/priority */ - if ((ret = cos_defswitch(csi->s.owner, t->prio, csi->s.owner == sl_thd_thdcap(g->sched_thd) ? + if ((ret = cos_defswitch(csi->s.owner, t->prio, csi->s.owner == sl_thd_thdcap(g->sched_thd) ? TCAP_TIME_NIL : g->timeout_next, tok))) return ret; /* if we have an outdated token, then we want to use the same repeat loop, so return to that */ @@ -247,7 +247,7 @@ sl_thd_wakeup_no_cs_rm(struct sl_thd *t) { assert(t); - if (unlikely(t->state == SL_THD_RUNNABLE)) return 1; + if (unlikely(t->state == SL_THD_RUNNABLE)) return 1; assert(t->state == SL_THD_BLOCKED || t->state == SL_THD_BLOCKED_TIMEOUT); t->state = SL_THD_RUNNABLE; @@ -445,6 +445,34 @@ sl_thd_alloc(cos_thd_fn_t fn, void *data) return t; } +struct sl_thd * +sl_thd_init(struct cos_aep_info *a, int own_tcap) +{ + struct cos_defcompinfo *dci = cos_defcompinfo_curr_get(); + struct cos_compinfo *ci = &dci->ci; + struct sl_thd *t = NULL; + struct cos_aep_info *aep = NULL; + thdid_t tid; + + sl_cs_enter(); + + aep = sl_thd_alloc_aep_backend(); + if (!aep) goto done; + + *aep = *a; + tid = cos_introspect(ci, a->thd, THD_GET_TID); + assert(tid); + t = sl_thd_alloc_init(tid, aep, 0, own_tcap ? SL_THD_PROPERTY_OWN_TCAP : 0); + sl_mod_thd_create(sl_mod_thd_policy_get(t)); + +done: + sl_cs_exit(); + + return t; +} + + + struct sl_thd * sl_thd_aep_alloc(cos_aepthd_fn_t fn, void *data, int own_tcap) { diff --git a/src/platform/i386/runscripts/llboot_cFE.sh b/src/platform/i386/runscripts/llboot_cFE.sh index 64b7741f3c..8f94abb4c2 100644 --- a/src/platform/i386/runscripts/llboot_cFE.sh +++ b/src/platform/i386/runscripts/llboot_cFE.sh @@ -1,2 +1,3 @@ cp llboot_test.o llboot.o -./cos_linker 'llboot.o, ;cFE_booter.o, ;sample_lib.o, ;sample_app.o, ;sch_lab.o, :sample_app.o-cFE_booter.o;sample_lib.o-cFE_booter.o;sch_lab.o-cFE_booter.o' ./gen_client_stub +cp cFE_booter.o sl_cFE.o +./cos_linker 'llboot.o, ;sl_cFE.o, ;sample_lib.o, ;sample_app.o, ;sch_lab.o, :sample_app.o-sl_cFE.o;sample_lib.o-sl_cFE.o;sch_lab.o-sl_cFE.o' ./gen_client_stub From a60b702e341801a85e74addae40245aeb401f15e Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sun, 18 Feb 2018 13:51:51 -0500 Subject: [PATCH 090/122] Stub out some cFE methods in cFE_emu This change lets apps actually boot fully, even if they don't work correctly. --- src/components/Makefile.comp | 3 +- .../no_interface/cFE_booter/osloader.c | 9 +- .../interface/cFE/private/README.txt | 22 -- .../cFE/private/cfe_es_erlog_typedef.h | 60 ---- .../cFE/private/cfe_es_perfdata_typedef.h | 60 ---- .../cFE/private/cfe_es_resetdata_typedef.h | 96 ------ .../cFE/private/cfe_evs_log_typedef.h | 43 --- .../interface/cFE/private/cfe_private.h | 319 ------------------ src/components/interface/cFE/stubs/s_stub.S | 5 - src/components/lib/cFE_emu.c | 40 ++- 10 files changed, 45 insertions(+), 612 deletions(-) delete mode 100644 src/components/interface/cFE/private/README.txt delete mode 100644 src/components/interface/cFE/private/cfe_es_erlog_typedef.h delete mode 100644 src/components/interface/cFE/private/cfe_es_perfdata_typedef.h delete mode 100644 src/components/interface/cFE/private/cfe_es_resetdata_typedef.h delete mode 100644 src/components/interface/cFE/private/cfe_evs_log_typedef.h delete mode 100644 src/components/interface/cFE/private/cfe_private.h diff --git a/src/components/Makefile.comp b/src/components/Makefile.comp index 95ed38bfde..259f5ec814 100644 --- a/src/components/Makefile.comp +++ b/src/components/Makefile.comp @@ -4,7 +4,8 @@ IMPLDIR=$(CDIR)/implementation/ INTERDIR=$(CDIR)/interface/ LIBDIR=$(CDIR)/lib/ MANDITORY_LIB=cos_manditory.o -CINC=-I./ -I$(CDIR)/include/ -I$(SHAREDINC) -I$(CDIR)/lib/ck/include -I$(CDIR)/lib/ps/ -I$(CDIR)/lib/libcxx/include +# FIXME: Point the cFE includes at the actual cFE +CINC=-I./ -I$(CDIR)/include/ -I$(SHAREDINC) -I$(CDIR)/lib/ck/include -I$(CDIR)/lib/ps/ -I$(CDIR)/lib/libcxx/include -I$(CDIR)/implementation/no_interface/cFE_booter/gen MUSLDIR=$(CDIR)/lib/musl-1.1.11 MUSLBIN=$(MUSLDIR)/bin diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index faf30e58cf..d30d0d4b97 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -64,15 +64,18 @@ void launch_other_component(int component_id) { // 4) Add a proxy here void sample_lib_proxy() { - launch_other_component(2); + launch_other_component(2); + // Do not idle loop if you are an app, they are initialized on the main thread } void sample_app_proxy() { - launch_other_component(3); + launch_other_component(3); + OS_IdleLoop(); } void sch_lab_proxy() { - launch_other_component(4); + launch_other_component(4); + OS_IdleLoop(); } struct symbol_proxy { diff --git a/src/components/interface/cFE/private/README.txt b/src/components/interface/cFE/private/README.txt deleted file mode 100644 index e5e32ba57f..0000000000 --- a/src/components/interface/cFE/private/README.txt +++ /dev/null @@ -1,22 +0,0 @@ -About the "private" cFE include directory ------------------------------------------ - -This directory is for include files that are used within the cFE core library -only, including types and definitions that are shared between more than one -cFE module. - -External libraries and applications should *NOT* include anything from this -directory. Doing so may cause the build to break. The reason is because -directly using definitions in here at compile-time will cause the external -entity (lib or app) to become hard-linked to the same specific cFE config -used to build the cFE - and it will surely break if that app is used with -a cFE instance that has been built with a different config (and probably -in a non-obvious way). - -Instead, the external app or lib should use the configuration exported from -the cFE library via the proper external ABI. - -Include files in here should check that _CFE_CORE_ is defined to prevent -accidental usage by external entities. - - diff --git a/src/components/interface/cFE/private/cfe_es_erlog_typedef.h b/src/components/interface/cFE/private/cfe_es_erlog_typedef.h deleted file mode 100644 index b848c37fec..0000000000 --- a/src/components/interface/cFE/private/cfe_es_erlog_typedef.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2004-2015, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Glenn - * Research Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/** - * \file cfe_es_erlog_typedef.h - * - * Created on: Jan 22, 2015 - * Author: joseph.p.hickey@nasa.gov - * - * Definition of the CFE_ES_ERLog structure type. - * This was moved into its own header file since it is referenced by multiple CFE core apps. - */ - -#ifndef CFE_ES_ERLOG_TYPEDEF_H_ -#define CFE_ES_ERLOG_TYPEDEF_H_ - -#include -#include /* Needed for CFE_TIME_SysTime_t */ - -/* -** Debug variables type -*/ -typedef struct -{ - uint32 DebugFlag; - uint32 WatchdogWriteFlag; - uint32 PrintfEnabledFlag; - uint32 LastAppId; - -} CFE_ES_DebugVariables_t; - -/* -** Exception and Reset Log Structure -*/ -typedef struct -{ - uint32 LogEntryType; /* What type of log entry */ - uint32 ResetType; /* Main cause for the reset */ - uint32 ResetSubtype; /* The sub-type for the reset */ - uint32 BootSource; /* The boot source */ - uint32 ProcessorResetCount; /* The number of processor resets */ - uint32 MaxProcessorResetCount; /* The maximum number before a Power On */ - CFE_ES_DebugVariables_t DebugVars; /* ES Debug variables */ - CFE_TIME_SysTime_t TimeCode; /* Time code */ - char Description[80]; /* The ascii data for the event */ - uint32 ContextSize; /* Indicates the context data is valid */ - uint32 AppID; /* The application ID */ - uint32 Context[CFE_ES_ER_LOG_MAX_CONTEXT_SIZE / sizeof(uint32)]; /* cpu context */ -} CFE_ES_ERLog_t; - - - -#endif /* CFE_ES_ERLOG_TYPEDEF_H_ */ diff --git a/src/components/interface/cFE/private/cfe_es_perfdata_typedef.h b/src/components/interface/cFE/private/cfe_es_perfdata_typedef.h deleted file mode 100644 index 15344908d5..0000000000 --- a/src/components/interface/cFE/private/cfe_es_perfdata_typedef.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2004-2015, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Glenn - * Research Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/** - * \file cfe_es_perfdata_typedef.h - * - * Created on: Jan 22, 2015 - * Author: joseph.p.hickey@nasa.gov - * - * Placeholder for file content description - */ - -#ifndef CFE_ES_PERFDATA_TYPEDEF_H_ -#define CFE_ES_PERFDATA_TYPEDEF_H_ - -#include -#include "cfe_platform_cfg.h" /* Required for CFE_ES_PERF_MAX_IDS */ - -#define CFE_ES_PERF_32BIT_WORDS_IN_MASK ((CFE_ES_PERF_MAX_IDS) / 32) - - -typedef struct { - uint32 Data; - uint32 TimerUpper32; /* TBU - timebase register */ - uint32 TimerLower32; /* TBL - timebase register */ -} CFE_ES_PerfDataEntry_t; - -typedef struct { - uint8 Version; - uint8 Endian; - uint8 Spare[2]; - uint32 TimerTicksPerSecond; - uint32 TimerLow32Rollover; - uint32 State; - uint32 Mode; - uint32 TriggerCount; - uint32 DataStart; - uint32 DataEnd; - uint32 DataCount; - uint32 InvalidMarkerReported; - uint32 FilterTriggerMaskSize; - uint32 FilterMask[CFE_ES_PERF_32BIT_WORDS_IN_MASK]; - uint32 TriggerMask[CFE_ES_PERF_32BIT_WORDS_IN_MASK]; -} CFE_ES_PerfMetaData_t; - -typedef struct { - CFE_ES_PerfMetaData_t MetaData; - CFE_ES_PerfDataEntry_t DataBuffer[CFE_ES_PERF_DATA_BUFFER_SIZE]; -} CFE_ES_PerfData_t; - - - -#endif /* CFE_ES_PERFDATA_TYPEDEF_H_ */ diff --git a/src/components/interface/cFE/private/cfe_es_resetdata_typedef.h b/src/components/interface/cFE/private/cfe_es_resetdata_typedef.h deleted file mode 100644 index 297cb6dfae..0000000000 --- a/src/components/interface/cFE/private/cfe_es_resetdata_typedef.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2004-2015, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Glenn - * Research Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/** - * \file cfe_es_resetdata_typedef.h - * - * Created on: Jan 22, 2015 - * Author: joseph.p.hickey@nasa.gov - * - * Definition of the CFE_ES_ResetData structure type. - * This was moved into its own header file since it is referenced by multiple CFE core apps. - */ - -#ifndef CFE_ES_RESETDATA_TYPEDEF_H_ -#define CFE_ES_RESETDATA_TYPEDEF_H_ - -#include - -#include /* Required for CFE_TIME_ResetVars_t definition */ -#include "cfe_es_erlog_typedef.h" /* Required for CFE_ES_ERLog_t definition */ -#include "cfe_es_perfdata_typedef.h" /* Required for CFE_ES_PerfData_t definition */ -#include "cfe_evs_log_typedef.h" /* Required for CFE_EVS_Log_t definition */ -#include "cfe_platform_cfg.h" /* CFE_EVS_LOG_ON, CFE_ES_ER_LOG_ENTRIES, CFE_ES_SYSTEM_LOG_SIZE */ - -/* -** Reset Variables type -*/ -typedef struct -{ - uint32 ResetType; - uint32 ResetSubtype; - uint32 BootSource; - uint32 ES_CausedReset; - uint32 ProcessorResetCount; - uint32 MaxProcessorResetCount; -} CFE_ES_ResetVariables_t; - - -/* -** Executive Services Global Reset Data type -** This is the special memory area for ES that is preserved -** on a processor reset. -*/ -typedef struct -{ - /* - ** Exception and Reset log declaration - */ - CFE_ES_ERLog_t ERLog[CFE_ES_ER_LOG_ENTRIES]; - uint32 ERLogIndex; - uint32 ERLogEntries; - uint32 LastAppId; - - /* - ** System Log declaration - */ - char SystemLog[CFE_ES_SYSTEM_LOG_SIZE]; - uint32 SystemLogIndex; - uint32 SystemLogMode; - uint32 SystemLogEntryNum; - - /* - ** Performance Data - */ - CFE_ES_PerfData_t Perf; - - /* - ** Reset Variables - */ - CFE_ES_ResetVariables_t ResetVars; - - /* - ** Time variables that are - ** preserved on a processor reset - */ - CFE_TIME_ResetVars_t TimeResetVars; - -#ifdef CFE_EVS_LOG_ON - /* - ** EVS Log and associated variables. This needs to be preserved on a processor reset. - */ - CFE_EVS_Log_t EVS_Log; -#endif - -} CFE_ES_ResetData_t; - - - -#endif /* CFE_ES_RESETDATA_TYPEDEF_H_ */ diff --git a/src/components/interface/cFE/private/cfe_evs_log_typedef.h b/src/components/interface/cFE/private/cfe_evs_log_typedef.h deleted file mode 100644 index 6c7c6e5d44..0000000000 --- a/src/components/interface/cFE/private/cfe_evs_log_typedef.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2004-2015, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Glenn - * Research Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/** - * \file cfe_evs_log_typedef.h - * - * Created on: Jan 22, 2015 - * Author: joseph.p.hickey@nasa.gov - * - * Definition of the CFE_EVS_Log structure type. - * This was moved into its own header file since it is referenced by multiple CFE core apps. - */ - -#ifndef CFE_EVS_LOG_TYPEDEF_H_ -#define CFE_EVS_LOG_TYPEDEF_H_ - -#include -#include "cfe_evs_msg.h" /* Required for CFE_EVS_Packet_t definition */ - -/* -** \brief EVS Log type definition. This is declared here so ES can include it -** in the reset area structure -*/ -typedef struct { - uint16 Next; /**< \brief Index of the next entry in the local event log */ - uint16 LogCount; /**< \brief Local Event Kog counter */ - uint8 LogFullFlag; /**< \brief Local Event Log full flag */ - uint8 LogMode; /**< \brief Local Event Logging mode (overwrite/discard) */ - uint16 LogOverflowCounter; /**< \brief Local Event Log overflow counter */ - CFE_EVS_Packet_t LogEntry[CFE_EVS_LOG_MAX];/**< \brief The actual Local Event Log entry */ - -} CFE_EVS_Log_t; - - - -#endif /* CFE_EVS_LOG_TYPEDEF_H_ */ diff --git a/src/components/interface/cFE/private/cfe_private.h b/src/components/interface/cFE/private/cfe_private.h deleted file mode 100644 index c1cc0cf114..0000000000 --- a/src/components/interface/cFE/private/cfe_private.h +++ /dev/null @@ -1,319 +0,0 @@ -/* - * cfe_private.h - * - * Created on: Dec 3, 2013 - * Author: jphickey - */ - -#ifndef CFE_PRIVATE_H_ -#define CFE_PRIVATE_H_ - -#include "common_types.h" -#include "cfe.h" - -#include "cfe_platform_cfg.h" /* Define platform configuration parameters */ - - -/*****************************************************************************/ -/** cFE Core task entry point prototypes *************************************/ -/*****************************************************************************/ -/* - * All cFE core apps should define an entry point and the prototype should be here - * These may also be called from the unit test - */ - -/*****************************************************************************/ -/** -** \brief Entry Point for cFE Core Application -** -** \par Description -** This is the entry point to the cFE TIME Core Application. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \retval None -******************************************************************************/ -extern void CFE_TIME_TaskMain(void); - -/*****************************************************************************/ -/** -** \brief Entry Point for cFE Core Application -** -** \par Description -** This is the entry point to the cFE SB Core Application. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \retval None -******************************************************************************/ -extern void CFE_SB_TaskMain(void); - -/*****************************************************************************/ -/** -** \brief Entry Point for cFE Core Application -** -** \par Description -** This is the entry point to the cFE EVS Core Application. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \retval None -******************************************************************************/ -extern void CFE_EVS_TaskMain(void); - -/*****************************************************************************/ -/** -** \brief Entry Point for cFE Core Application -** -** \par Description -** This is the entry point to the cFE ES Core Application. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \retval None -******************************************************************************/ -extern void CFE_ES_TaskMain(void); - -/*****************************************************************************/ -/** -** \brief Entry Point for cFE Table Services Core Application -** -** \par Description -** This is the entry point to the cFE Table Services Core Application. -** This Application provides the ground interface to the cFE Table -** Services. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \retval None -******************************************************************************/ -extern void CFE_TBL_TaskMain(void); - - - - -/*****************************************************************************/ -/** cFE Core task early init prototypes **************************************/ -/*****************************************************************************/ -/* - * cFE core apps may define an early init function and the prototype should be here - * These may also be called from the unit test - */ - -/*****************************************************************************/ -/** -** \brief Initializes the cFE core module API Library -** -** \par Description -** Initializes the cFE core module API Library -** -** \par Assumptions, External Events, and Notes: -** -# This function MUST be called before any module API's are called. -** -******************************************************************************/ -extern int32 CFE_EVS_EarlyInit(void); - -/*****************************************************************************/ -/** -** \brief Initializes the cFE core module API Library -** -** \par Description -** Initializes the cFE core module API Library -** -** \par Assumptions, External Events, and Notes: -** -# This function MUST be called before any module API's are called. -** -******************************************************************************/ -extern int32 CFE_SB_EarlyInit(void); - -/*****************************************************************************/ -/** -** \brief Initializes the cFE core module API Library -** -** \par Description -** Initializes the cFE core module API Library -** -** \par Assumptions, External Events, and Notes: -** -# This function MUST be called before any module API's are called. -** -******************************************************************************/ -extern int32 CFE_TIME_EarlyInit(void); - -/*****************************************************************************/ -/** -** \brief Initializes the Table Services API Library -** -** \par Description -** Initializes the Table Services API Library -** -** \par Assumptions, External Events, and Notes: -** -# This function MUST be called before any TBL API's are called. -** -******************************************************************************/ -extern int32 CFE_TBL_EarlyInit(void); - -/*****************************************************************************/ -/** -** \brief Initializes the cFE core module API Library -** -** \par Description -** Initializes the cFE core module API Library -** -** \par Assumptions, External Events, and Notes: -** -# This function MUST be called before any module API's are called. -** -******************************************************************************/ -extern int32 CFE_ES_CDS_EarlyInit(void); - -/*****************************************************************************/ -/** -** \brief Initializes the cFE core module API Library -** -** \par Description -** Initializes the cFE core module API Library -** -** \par Assumptions, External Events, and Notes: -** -# This function MUST be called before any module API's are called. -** -******************************************************************************/ -extern int32 CFE_FS_EarlyInit(void); - - - -/*****************************************************************************/ -/** cFE Core task clean up prototypes ****************************************/ -/*****************************************************************************/ -/* - * cFE core apps may define a clean up function and the prototype should be here - * These may also be called from the unit test - */ -/*****************************************************************************/ -/** -** \brief Removes TBL resources associated with specified Application -** -** \par Description -** This function is called by cFE Executive Services to cleanup after -** an Application has been terminated. It frees TBL services resources -** that have been allocated to the specified Application. -** -** \par Assumptions, External Events, and Notes: -** -# This function DOES NOT remove any critical tables associated with -** the specified application from the Critical Data Store. -** -******************************************************************************/ -extern int32 CFE_TBL_CleanUpApp(uint32 AppId); - -/*****************************************************************************/ -/** -** \brief Removes SB resources associated with specified Application -** -** \par Description -** This function is called by cFE Executive Services to cleanup after -** an Application has been terminated. It frees resources -** that have been allocated to the specified Application. -** -******************************************************************************/ -extern int32 CFE_SB_CleanUpApp(uint32 AppId); - -/*****************************************************************************/ -/** -** \brief Removes EVS resources associated with specified Application -** -** \par Description -** This function is called by cFE Executive Services to cleanup after -** an Application has been terminated. It frees resources -** that have been allocated to the specified Application. -** -******************************************************************************/ -extern int32 CFE_EVS_CleanUpApp(uint32 AppId); - -/*****************************************************************************/ -/** -** \brief Removes TIME resources associated with specified Application -** -** \par Description -** This function is called by cFE Executive Services to cleanup after -** an Application has been terminated. It frees resources -** that have been allocated to the specified Application. -** -******************************************************************************/ -extern int32 CFE_TIME_CleanUpApp(uint32 AppId); - - -/*****************************************************************************/ -/** cFE Core task other function call prototypes *****************************/ -/*****************************************************************************/ -/* - * Functions that are used in a cFE core module other than the module that - * actually defines the function should be prototyped here. - * - * Including the prototype here allows the function to be called properly - * without redefining it at the point of use. - */ - -/*****************************************************************************/ -/** -** \brief Reserve space (or re-obtain previously reserved space) in the Critical Data Store (CDS) -** -** \par Description -** This routine is identical to #CFE_ES_RegisterCDS except it identifies the contents -** of the CDS as a critical table. This is crucial because a critical table CDS must -** only be deleted by cFE Table Services, not via an ES delete CDS command. Otherwise, -** Table Services may be out of sync with the contents of the CDS. -** -** \par Assumptions, External Events, and Notes: -** -# This function assumes input parameters are error free and have met size/value restrictions. -** -# The calling function is responsible for issuing any event messages associated with errors. -** -** \param[in] HandlePtr Pointer Application's variable that will contain the CDS Memory Block Handle. -** -** \param[in] BlockSize The number of bytes needed in the CDS. -** -** \param[in] Name Pointer to character string containing the Application's local name for -** the CDS. -** -** \param[in] CriticalTbl Indicates whether the CDS is to be used as a Critical Table or not -** -** \param[out] *HandlePtr The handle of the CDS block that can be used in #CFE_ES_CopyToCDS and #CFE_ES_RestoreFromCDS. -** -** \return See return codes for #CFE_ES_RegisterCDS -** -******************************************************************************/ -int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, int32 BlockSize, const char *Name, boolean CriticalTbl); - -/*****************************************************************************/ -/** -** \brief Deletes the specified CDS from the CDS Registry and frees CDS Memory -** -** \par Description -** Removes the record of the specified CDS from the CDS Registry and -** frees the associated CDS memory for future use. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] CDSName - Pointer to character string containing complete -** CDS Name (of the format "AppName.CDSName"). -** -** \param[in] CalledByTblServices - Flag that identifies whether the CDS is supposed to -** be a Critical Table Image or not. -** -** \return #CFE_SUCCESS \copydoc CFE_SUCCESS -** \return #CFE_ES_CDS_WRONG_TYPE_ERR \copydoc CFE_ES_CDS_WRONG_TYPE_ERR -** \return #CFE_ES_CDS_OWNER_ACTIVE_ERR \copydoc CFE_ES_CDS_OWNER_ACTIVE_ERR -** \return #CFE_ES_CDS_NOT_FOUND_ERR \copydoc CFE_ES_CDS_NOT_FOUND_ERR -** \return Any of the return values from #CFE_ES_UpdateCDSRegistry -** \return Any of the return values from #CFE_ES_PutCDSBlock -** -******************************************************************************/ -int32 CFE_ES_DeleteCDS(const char *CDSName, boolean CalledByTblServices); - - - - -#endif /* CFE_PRIVATE_H_ */ diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index a4cdf6fb6c..9139bce35d 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -19,14 +19,9 @@ cos_asm_server_stub(CFE_ES_PerfLogAdd) cos_asm_server_stub(CFE_ES_RegisterApp) cos_asm_server_stub(CFE_ES_RunLoop) -cos_asm_server_stub(CFE_EVS_Register) -cos_asm_server_stub(CFE_EVS_SendEvent) - -cos_asm_server_stub(CFE_SB_CreatePipe) cos_asm_server_stub(CFE_SB_GetCmdCode) cos_asm_server_stub(CFE_SB_GetMsgId) cos_asm_server_stub(CFE_SB_GetTotalMsgLength) -cos_asm_server_stub(CFE_SB_InitMsg) cos_asm_server_stub(CFE_SB_RcvMsg) cos_asm_server_stub(CFE_SB_SendMsg) cos_asm_server_stub(CFE_SB_Subscribe) diff --git a/src/components/lib/cFE_emu.c b/src/components/lib/cFE_emu.c index 3b53b2a9a9..6a513cae2a 100644 --- a/src/components/lib/cFE_emu.c +++ b/src/components/lib/cFE_emu.c @@ -1,11 +1,11 @@ #include +#include +#include + // FIXME: Query the cFE to decide whether printf is enabled int is_printf_enabled = 1; -// FIXME: Point this at the real buffer size -#define OS_BUFFER_SIZE 4096 - void OS_printf(const char *string, ...) { if(is_printf_enabled) { @@ -19,3 +19,37 @@ void OS_printf(const char *string, ...) cos_llprint(s, ret); } } + + +// TODO: Actually emulate these calls +int32 CFE_EVS_Register (void *Filters, /* Pointer to an array of filters */ + uint16 NumFilteredEvents, /* How many elements in the array? */ + uint16 FilterScheme) /* Filtering Algorithm to be implemented */ +{ + printc("CFE_EVS_Register called...\n"); + return CFE_SUCCESS; +} + +int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, + uint16 Depth, + const char *PipeName) +{ + printc("CFE_SB_CreatePipe called...\n"); + return CFE_SUCCESS; +} + +void CFE_SB_InitMsg(void *MsgPtr, + CFE_SB_MsgId_t MsgId, + uint16 Length, + boolean Clear ) +{ + printc("CFE_SB_InitMsg called...\n"); +} + +int32 CFE_EVS_SendEvent (uint16 EventID, + uint16 EventType, + const char *Spec, ... ) +{ + printc("CFE_EVS_SendEvent called...\n"); + return CFE_SUCCESS; +} From 610cec65e04978c5451b4a2d07680f6a070b21d4 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sun, 18 Feb 2018 16:41:47 -0500 Subject: [PATCH 091/122] Fix capitalization of includes, which was a problem Shoutout to joe for spotting this issue --- src/components/implementation/no_interface/cFE_booter/ostask.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index f586be0917..4843661c9b 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -7,7 +7,7 @@ #include "gen/osapi.h" #include "gen/common_types.h" -#include "gen/cFE_time.h" +#include "gen/cfe_time.h" void From 3a5920b6955c4809dbdda1296b9c517d420f8dac Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Thu, 1 Mar 2018 15:31:54 -0500 Subject: [PATCH 092/122] Switch the cFE to using the res_mgr for resource requests Currently some bug in invocation code makes this fail --- .../implementation/no_interface/cFE_booter/Makefile | 4 ++-- .../implementation/no_interface/cFE_booter/osapi.c | 2 -- .../implementation/no_interface/cFE_booter/osfilesys.c | 2 +- .../implementation/no_interface/cFE_booter/osfilesys.h | 2 ++ src/components/implementation/resmgr/naive/res_mgr.c | 9 +++++++-- src/platform/i386/runscripts/llboot_cFE.sh | 8 ++++++-- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index 25b68c0660..e9b0991476 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -2,9 +2,9 @@ ASM_OBJS= COMPONENT=cFE_booter.o INTERFACES=cFE -DEPENDENCIES= +DEPENDENCIES=resmgr IF_LIB:=./composite_cFE.o $(wildcard test/*.o) -ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api -lcos_defkernel_api -lsl_rawmgr -lsl_sched -lheap -lsl_lock +ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api -lcos_defkernel_api -lsl_resmgr -lsl_sched -lheap -lsl_lock include ../../Makefile.subsubdir CFLAGS += -I./gen -I ./test/shared $(CPPFLAGS) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 2ff8adfafb..c417178a48 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -21,8 +21,6 @@ int have_initialized = 0; int32 OS_API_Init(void) { if(!have_initialized) { - cos_defcompinfo_init(); - struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); struct cos_compinfo *ci = cos_compinfo_get(defci); cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.c b/src/components/implementation/no_interface/cFE_booter/osfilesys.c index a5e1929bfb..6ab3fe7a30 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.c +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.c @@ -282,7 +282,7 @@ uint32 part_get_new(struct f_part **part) struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); struct cos_compinfo *ci = &defci->ci; - *part = cos_page_bump_alloc(ci); + *part = memmgr_heap_page_alloc(cos_comp_info.cos_this_spd_id); assert(part != NULL); (*part)->next = NULL; diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.h b/src/components/implementation/no_interface/cFE_booter/osfilesys.h index 931c7d8d19..f4040a54dc 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.h +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.h @@ -5,6 +5,8 @@ #include #include +#include + #include "gen/common_types.h" #include "gen/osapi.h" #include "gen/osapi-os-filesys.h" diff --git a/src/components/implementation/resmgr/naive/res_mgr.c b/src/components/implementation/resmgr/naive/res_mgr.c index d0b4549119..625c083663 100644 --- a/src/components/implementation/resmgr/naive/res_mgr.c +++ b/src/components/implementation/resmgr/naive/res_mgr.c @@ -8,6 +8,7 @@ thdcap_t resmgr_thd_create_intern(spdid_t cur, int idx, int u1, int u2, int *u3, int *u4) { + printc("inside resmgr_thd_create_intern\n"); struct cos_defcompinfo *res_dci = cos_defcompinfo_curr_get(); struct cos_compinfo *res_ci = cos_compinfo_get(res_dci); struct res_comp_info *r = res_info_comp_find(cur); @@ -18,14 +19,18 @@ resmgr_thd_create_intern(spdid_t cur, int idx, int u1, int u2, int *u3, int *u4) assert(res_info_is_sched(cur)); assert(idx > 0); + printc("calling sl_thd_ext_idx_alloc\n"); t = sl_thd_ext_idx_alloc(res_info_dci(r), idx); assert(t); + printc("res_info_thd_init\n"); rt = res_info_thd_init(r, t); assert(rt); + printc("cos_cap_cpy\n"); ret = cos_cap_cpy(res_info_ci(r), res_ci, CAP_THD, sl_thd_thdcap(rt)); assert(ret > 0); + printc("returning\n"); return ret; } @@ -114,7 +119,7 @@ resmgr_initaep_create_intern(spdid_t cur, spdid_t s, int owntc, int u1, asndcap_ assert(t); rt = res_info_thd_init(rc, t); assert(rt); - rst = res_info_initthd_init(rs, t); + rst = res_info_initthd_init(rs, t); assert(rst); /* child is a scheduler.. copy initcaps */ @@ -177,7 +182,7 @@ resmgr_ext_aep_create_intern(spdid_t cur, spdid_t s, int tidx, int owntc, arcvca /* cur is a scheduler, copy thdcap */ ret = cos_cap_cpy(res_info_ci(rc), res_ci, CAP_THD, sl_thd_thdcap(rt)); assert(ret > 0); - /* + /* * for aep thread.. rcv cap should be accessible in the destination component, * so we return that cap so the scheduler can init proper structures of the dest component. */ diff --git a/src/platform/i386/runscripts/llboot_cFE.sh b/src/platform/i386/runscripts/llboot_cFE.sh index 3f37a273b5..c89743cc85 100644 --- a/src/platform/i386/runscripts/llboot_cFE.sh +++ b/src/platform/i386/runscripts/llboot_cFE.sh @@ -1,4 +1,8 @@ +# cp llboot_comp.o llboot.o +# cp resmgr.o mm.o +# ./cos_linker 'llboot.o, ;mm.o, ;*cFE_booter.o, ;sample_lib.o, ;sample_app.o, ;sch_lab.o, :cFE_booter.o-mm.o;sample_app.o-cFE_booter.o;sample_lib.o-cFE_booter.o;sch_lab.o-cFE_booter.o' ./gen_client_stub + cp llboot_comp.o llboot.o -cp llboot_comp.o dummy.o cp resmgr.o mm.o -./cos_linker 'llboot.o, ;mm.o, ;*cFE_booter.o, ;sample_lib.o, ;sample_app.o, ;sch_lab.o, :sample_app.o-cFE_booter.o;sample_lib.o-cFE_booter.o;sch_lab.o-cFE_booter.o' ./gen_client_stub +cp cFE_booter.o boot.o +./cos_linker 'llboot.o, ;sample_lib.o, ;mm.o, ;sample_app.o, ;*boot.o, ;sch_lab.o, :boot.o-mm.o;sample_app.o-boot.o;sample_lib.o-boot.o;sch_lab.o-boot.o' ./gen_client_stub From dbff2f556c0113777eedd13b4fbe6337a21015f3 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Thu, 1 Mar 2018 23:38:57 -0500 Subject: [PATCH 093/122] Fix bugs in cFE res_mgr usage We still have issues with syncronous invocations --- .../no_interface/cFE_booter/osapi.c | 1 + .../no_interface/cFE_booter/osfilesys.c | 2 +- .../no_interface/cFE_booter/osloader.c | 35 +++++-------------- .../no_interface/cFE_booter/ostask.c | 4 --- .../no_interface/llbooter/boot_deps.h | 7 ++-- .../implementation/resmgr/naive/res_mgr.c | 5 --- src/components/lib/cos_kernel_api.c | 1 + src/kernel/include/inv.h | 6 ++-- 8 files changed, 19 insertions(+), 42 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index c417178a48..b8ea0465fc 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -21,6 +21,7 @@ int have_initialized = 0; int32 OS_API_Init(void) { if(!have_initialized) { + cos_defcompinfo_init(); struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); struct cos_compinfo *ci = cos_compinfo_get(defci); cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.c b/src/components/implementation/no_interface/cFE_booter/osfilesys.c index 6ab3fe7a30..5031b0e297 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.c +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.c @@ -282,7 +282,7 @@ uint32 part_get_new(struct f_part **part) struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); struct cos_compinfo *ci = &defci->ci; - *part = memmgr_heap_page_alloc(cos_comp_info.cos_this_spd_id); + *part = (void*)memmgr_heap_page_alloc(cos_comp_info.cos_this_spd_id); assert(part != NULL); (*part)->next = NULL; diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index acbb5085b2..64e53c727e 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -26,32 +26,13 @@ int32 OS_ModuleUnload(uint32 module_id) return OS_SUCCESS; } -void launch_other_component(int component_id) { - struct cos_defcompinfo *dci; - struct cos_compinfo *ci; +void launch_other_component(int child_id) { + struct cos_defcompinfo dci; + cos_defcompinfo_childid_init(&dci, child_id); - dci = cos_defcompinfo_curr_get(); - assert(dci); - ci = cos_compinfo_get(dci); - assert(ci); - - - pgtblcap_t pgtslot = cos_capid_bump_alloc(ci, CAP_PGTBL); - assert(pgtslot); - captblcap_t captslot = cos_capid_bump_alloc(ci, CAP_CAPTBL); - assert(captslot); - compcap_t ccslot = cos_capid_bump_alloc(ci, CAP_COMP); - assert(ccslot); - - spdid_t parent_spid; - hypercall_comp_info_get(component_id, pgtslot, captslot, ccslot, &parent_spid); - - thdcap_t thd = cos_initthd_alloc(ci, ccslot); - assert(thd); - struct sl_thd *t = sl_thd_ext_init(thd, 0, 0, 0); - - sl_thd_param_set(t, sched_param_pack(SCHEDP_PRIO, 1)); - sl_thd_yield(t->thdid); + struct sl_thd *t = sl_thd_child_initaep_alloc(&dci, 0, 1); + sl_thd_param_set(t, sched_param_pack(SCHEDP_PRIO, 1)); + sl_thd_yield(t->thdid); } // Component proxy hack @@ -62,7 +43,7 @@ void launch_other_component(int component_id) { // 4) Add a proxy here void sample_lib_proxy() { - launch_other_component(2); + launch_other_component(1); // Do not idle loop if you are an app, they are initialized on the main thread } @@ -72,7 +53,7 @@ void sample_app_proxy() { } void sch_lab_proxy() { - launch_other_component(4); + launch_other_component(5); OS_IdleLoop(); } diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index a03b33670e..523346df50 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -37,10 +37,8 @@ timer_fn_1hz(void *d) thdid_t main_delegate_thread_id; void OS_SchedulerStart(cos_thd_fn_t main_delegate) { - printc("Doing sl_init\n"); sl_init(SL_MIN_PERIOD_US); - printc("Creating main delegate thread\n"); struct sl_thd* main_delegate_thread = sl_thd_alloc(main_delegate, NULL); union sched_param_union sp = {.c = {.type = SCHEDP_PRIO, .value = MAIN_DELEGATE_THREAD_PRIORITY}}; sl_thd_param_set(main_delegate_thread, sp.v); @@ -51,14 +49,12 @@ void OS_SchedulerStart(cos_thd_fn_t main_delegate) { policy->osal_task_prop.priority = MAIN_DELEGATE_THREAD_PRIORITY; policy->osal_task_prop.OStask_id = (uint32) main_delegate_thread->thdid; - printc("Creating timer thread\n"); struct sl_thd *timer_thd = sl_thd_alloc(timer_fn_1hz, NULL); union sched_param_union spperiod = {.c = {.type = SCHEDP_WINDOW, .value = 250000 }}; union sched_param_union spprio = {.c = {.type = SCHEDP_PRIO, .value = MAIN_DELEGATE_THREAD_PRIORITY+1}}; sl_thd_param_set(timer_thd, spperiod.v); sl_thd_param_set(timer_thd, spprio.v); - printc("Doing sl_sched_loop\n"); sl_sched_loop(); } diff --git a/src/components/implementation/no_interface/llbooter/boot_deps.h b/src/components/implementation/no_interface/llbooter/boot_deps.h index 43aeba0de5..b5bf1aac97 100644 --- a/src/components/implementation/no_interface/llbooter/boot_deps.h +++ b/src/components/implementation/no_interface/llbooter/boot_deps.h @@ -237,7 +237,7 @@ boot_newcomp_init_caps(spdid_t spdid) struct comp_cap_info *capci = &new_comp_cap_info[spdid]; struct cos_aep_info *child_aep = boot_spd_initaep_get(spdid); int ret, i; - + /* FIXME: not everyone should have it. but for now, because getting cpu cycles uses this */ ret = cos_cap_cpy_at(ci, BOOT_CAPTBL_SELF_INITHW_BASE, boot_info, BOOT_CAPTBL_SELF_INITHW_BASE); assert(ret == 0); @@ -250,7 +250,7 @@ boot_newcomp_init_caps(spdid_t spdid) * - to get budget on tcap * - other introspect...requirements.. * - * I don't know a way to get away from this for now! + * I don't know a way to get away from this for now! * If it were just thdid, resmgr could have returned the thdids! */ ret = cos_cap_cpy_at(ci, BOOT_CAPTBL_SELF_CT, boot_info, ci->captbl_cap); @@ -351,7 +351,8 @@ boot_done(void) ret = cos_tcap_transfer(root_aep->rcv, BOOT_CAPTBL_SELF_INITTCAP_BASE, TCAP_RES_INF, LLBOOT_ROOT_PRIO); assert(ret == 0); - ret = cos_switch(root_aep->thd, root_aep->tc, LLBOOT_ROOT_PRIO, TCAP_TIME_NIL, 0, cos_sched_sync()); + while(1) + cos_switch(root_aep->thd, root_aep->tc, LLBOOT_ROOT_PRIO, TCAP_TIME_NIL, 0, cos_sched_sync()); PRINTC("ERROR: Root scheduler returned.\n"); assert(0); } diff --git a/src/components/implementation/resmgr/naive/res_mgr.c b/src/components/implementation/resmgr/naive/res_mgr.c index 625c083663..2c28dd7796 100644 --- a/src/components/implementation/resmgr/naive/res_mgr.c +++ b/src/components/implementation/resmgr/naive/res_mgr.c @@ -8,7 +8,6 @@ thdcap_t resmgr_thd_create_intern(spdid_t cur, int idx, int u1, int u2, int *u3, int *u4) { - printc("inside resmgr_thd_create_intern\n"); struct cos_defcompinfo *res_dci = cos_defcompinfo_curr_get(); struct cos_compinfo *res_ci = cos_compinfo_get(res_dci); struct res_comp_info *r = res_info_comp_find(cur); @@ -19,18 +18,14 @@ resmgr_thd_create_intern(spdid_t cur, int idx, int u1, int u2, int *u3, int *u4) assert(res_info_is_sched(cur)); assert(idx > 0); - printc("calling sl_thd_ext_idx_alloc\n"); t = sl_thd_ext_idx_alloc(res_info_dci(r), idx); assert(t); - printc("res_info_thd_init\n"); rt = res_info_thd_init(r, t); assert(rt); - printc("cos_cap_cpy\n"); ret = cos_cap_cpy(res_info_ci(r), res_ci, CAP_THD, sl_thd_thdcap(rt)); assert(ret > 0); - printc("returning\n"); return ret; } diff --git a/src/components/lib/cos_kernel_api.c b/src/components/lib/cos_kernel_api.c index 9afea9c1b3..3c4b148985 100644 --- a/src/components/lib/cos_kernel_api.c +++ b/src/components/lib/cos_kernel_api.c @@ -915,6 +915,7 @@ cos_thd_mod(struct cos_compinfo *ci, thdcap_t tc, void *tlsaddr) int cos_introspect(struct cos_compinfo *ci, capid_t cap, unsigned long op) { + assert(ci->captbl_cap); return call_cap_op(ci->captbl_cap, CAPTBL_OP_INTROSPECT, cap, (int)op, 0, 0); } diff --git a/src/kernel/include/inv.h b/src/kernel/include/inv.h index 33bda8bc3a..54fc437414 100644 --- a/src/kernel/include/inv.h +++ b/src/kernel/include/inv.h @@ -307,10 +307,12 @@ static inline void sret_ret(struct thread *thd, struct pt_regs *regs, struct cos_cpu_local_info *cos_info) { struct comp_info *ci; - unsigned long ip, sp; + unsigned long ip = 0, sp = 0; ci = thd_invstk_pop(thd, &ip, &sp, cos_info); - if (unlikely(!ci)) { + if (unlikely(!ci || !ip || !sp)) { + printk("cos: sync return failed, thd_invstk_pop(thd = %p, cos_info = %p) gives (ip = %p, sp = %p, ci = %p), which is invalid\n", + thd, cos_info, ip, sp, ci); __userregs_set(regs, 0xDEADDEAD, 0, 0); return; } From 71a8d179e3b9f9fdd82bc7f07bdb216f5a5f583b Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sat, 3 Mar 2018 00:22:59 -0500 Subject: [PATCH 094/122] Implement emulation for many cFE methods --- .../no_interface/cFE_booter/cFE_emu_support.c | 41 ++++++++++++ .../no_interface/cFE_booter/osapi.c | 12 ++-- .../no_interface/cFE_booter/osloader.c | 29 +++++---- .../no_interface/sample_app/Makefile | 2 +- .../no_interface/sample_app/init.c | 4 +- .../no_interface/sample_lib/Makefile | 2 +- .../no_interface/sample_lib/init.c | 4 +- .../no_interface/sch_lab/Makefile | 2 +- .../no_interface/sch_lab/init.c | 4 +- src/components/include/cFE_emu.h | 37 +++++++++++ src/components/interface/cFE/stubs/s_stub.S | 6 ++ src/components/lib/cFE_emu.c | 63 ++++++++++++++++--- src/platform/i386/runscripts/llboot_cFE.sh | 2 +- 13 files changed, 174 insertions(+), 34 deletions(-) create mode 100644 src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c create mode 100644 src/components/include/cFE_emu.h diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c new file mode 100644 index 0000000000..c054307ca7 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -0,0 +1,41 @@ +#include +#include + +#include + +#include + +union shared_region *shared_regions[16]; + +int emu_backend_request_memory(spdid_t client) +{ + vaddr_t our_addr = 0; + int id = memmgr_shared_page_alloc(cos_comp_info.cos_this_spd_id, &our_addr); + assert(our_addr); + shared_regions[client] = (void*)our_addr; + return id; +} + +int32 emu_CFE_EVS_Register(spdid_t client) +{ + union shared_region* s = shared_regions[client]; + return CFE_EVS_Register(s->cfe_evs_register.filters, s->cfe_evs_register.NumEventFilters, s->cfe_evs_register.FilterScheme); +} + +int32 emu_CFE_SB_CreatePipe(spdid_t client) +{ + union shared_region* s = shared_regions[client]; + return CFE_SB_CreatePipe(&s->cfe_sb_createPipe.PipeId, s->cfe_sb_createPipe.Depth, s->cfe_sb_createPipe.PipeName); +} + +void emu_CFE_SB_InitMsg(spdid_t client) +{ + union shared_region* s = shared_regions[client]; + CFE_SB_InitMsg(s->cfe_sb_initMsg.MsgBuffer, s->cfe_sb_initMsg.MsgId, s->cfe_sb_initMsg.Length, s->cfe_sb_initMsg.Clear); +} + +int32 emu_CFE_EVS_SendEvent(spdid_t client) +{ + union shared_region* s = shared_regions[client]; + return CFE_EVS_SendEvent(s->cfe_evs_sendEvent.EventID, s->cfe_evs_sendEvent.EventType, "%s", s->cfe_evs_sendEvent.Msg); +} diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index b8ea0465fc..96d2cb3d8c 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -1,17 +1,15 @@ -#include "cFE_util.h" +#include +#include -#include "sl.h" -#include "sl_consts.h" +#include +#include #include "gen/osapi.h" #include "gen/cfe_psp.h" #include "gen/cfe_time.h" #include "gen/common_types.h" - -#include -#include - +#include "cFE_util.h" /* ** Initialization of API diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index 64e53c727e..402b886d8e 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -26,13 +26,18 @@ int32 OS_ModuleUnload(uint32 module_id) return OS_SUCCESS; } -void launch_other_component(int child_id) { +void launch_other_component(int child_id, int is_library) +{ struct cos_defcompinfo dci; cos_defcompinfo_childid_init(&dci, child_id); struct sl_thd *t = sl_thd_child_initaep_alloc(&dci, 0, 1); - sl_thd_param_set(t, sched_param_pack(SCHEDP_PRIO, 1)); - sl_thd_yield(t->thdid); + if (is_library) { + sl_thd_param_set(t, sched_param_pack(SCHEDP_PRIO, 1)); + sl_thd_yield(t->thdid); + } else { + while(1) sl_thd_yield(t->thdid); + } } // Component proxy hack @@ -42,19 +47,19 @@ void launch_other_component(int child_id) { // 3) Add an init routine in the component // 4) Add a proxy here -void sample_lib_proxy() { - launch_other_component(1); - // Do not idle loop if you are an app, they are initialized on the main thread +void sample_lib_proxy() +{ + launch_other_component(1, 1); } -void sample_app_proxy() { - launch_other_component(3); - OS_IdleLoop(); +void sample_app_proxy() +{ + launch_other_component(3, 0); } -void sch_lab_proxy() { - launch_other_component(5); - OS_IdleLoop(); +void sch_lab_proxy() +{ + launch_other_component(5, 0); } struct symbol_proxy { diff --git a/src/components/implementation/no_interface/sample_app/Makefile b/src/components/implementation/no_interface/sample_app/Makefile index 1171638148..9cf7838914 100644 --- a/src/components/implementation/no_interface/sample_app/Makefile +++ b/src/components/implementation/no_interface/sample_app/Makefile @@ -2,7 +2,7 @@ ASM_OBJS= COMPONENT=sample_app.o INTERFACES= -DEPENDENCIES=cFE +DEPENDENCIES=cFE resmgr IF_LIB:=./cFE_sample_app.o ADDITIONAL_LIBS=-lcos_kernel_api -lcFE_emu diff --git a/src/components/implementation/no_interface/sample_app/init.c b/src/components/implementation/no_interface/sample_app/init.c index 2e25625b00..4b87b8ed03 100644 --- a/src/components/implementation/no_interface/sample_app/init.c +++ b/src/components/implementation/no_interface/sample_app/init.c @@ -1,12 +1,14 @@ +#include #include #include -#include extern void SAMPLE_AppMain(); extern void OS_IdleLoop(); +extern void do_emulation_setup(spdid_t id); void cos_init(void) { + do_emulation_setup(cos_comp_info.cos_this_spd_id); printc("Starting app main\n"); SAMPLE_AppMain(); printc("Ending app main\n"); diff --git a/src/components/implementation/no_interface/sample_lib/Makefile b/src/components/implementation/no_interface/sample_lib/Makefile index e76b850ca0..a8d95d44db 100644 --- a/src/components/implementation/no_interface/sample_lib/Makefile +++ b/src/components/implementation/no_interface/sample_lib/Makefile @@ -2,7 +2,7 @@ ASM_OBJS= COMPONENT=sample_lib.o INTERFACES= -DEPENDENCIES=cFE +DEPENDENCIES=cFE resmgr IF_LIB:=./cFE_sample_lib.o ADDITIONAL_LIBS=-lcos_kernel_api -lcFE_emu diff --git a/src/components/implementation/no_interface/sample_lib/init.c b/src/components/implementation/no_interface/sample_lib/init.c index c1265a43e1..e775f717e9 100644 --- a/src/components/implementation/no_interface/sample_lib/init.c +++ b/src/components/implementation/no_interface/sample_lib/init.c @@ -1,12 +1,14 @@ +#include #include #include -#include extern void SAMPLE_LibInit(); extern void OS_IdleLoop(); +extern void do_emulation_setup(spdid_t id); void cos_init(void) { + do_emulation_setup(cos_comp_info.cos_this_spd_id); printc("Starting lib init\n"); SAMPLE_LibInit(); printc("Ending lib init\n"); diff --git a/src/components/implementation/no_interface/sch_lab/Makefile b/src/components/implementation/no_interface/sch_lab/Makefile index e7c35096d1..4edc6c45b9 100644 --- a/src/components/implementation/no_interface/sch_lab/Makefile +++ b/src/components/implementation/no_interface/sch_lab/Makefile @@ -2,7 +2,7 @@ ASM_OBJS= COMPONENT=sch_lab.o INTERFACES= -DEPENDENCIES=cFE +DEPENDENCIES=cFE resmgr IF_LIB:=./cFE_sch_lab_app.o ADDITIONAL_LIBS=-lcos_kernel_api -lcFE_emu diff --git a/src/components/implementation/no_interface/sch_lab/init.c b/src/components/implementation/no_interface/sch_lab/init.c index df9be7cac8..837b85f3fb 100644 --- a/src/components/implementation/no_interface/sch_lab/init.c +++ b/src/components/implementation/no_interface/sch_lab/init.c @@ -1,12 +1,14 @@ +#include #include #include -#include extern void SCH_Lab_AppMain(); extern void OS_IdleLoop(); +extern void do_emulation_setup(spdid_t id); void cos_init(void) { + do_emulation_setup(cos_comp_info.cos_this_spd_id); printc("Starting sch main\n"); SCH_Lab_AppMain(); printc("Ending sch main\n"); diff --git a/src/components/include/cFE_emu.h b/src/components/include/cFE_emu.h new file mode 100644 index 0000000000..60525c6376 --- /dev/null +++ b/src/components/include/cFE_emu.h @@ -0,0 +1,37 @@ +#include + +#include + +union shared_region { + struct { + CFE_EVS_BinFilter_t filters[CFE_EVS_MAX_EVENT_FILTERS]; + uint16 NumEventFilters; + uint16 FilterScheme; + } cfe_evs_register; + struct { + CFE_SB_PipeId_t PipeId; + uint16 Depth; + char PipeName[OS_MAX_API_NAME]; + } cfe_sb_createPipe; + struct { + char MsgBuffer[512]; + CFE_SB_MsgId_t MsgId; + uint16 Length; + boolean Clear; + } cfe_sb_initMsg; + struct { + char Msg[512]; + uint16 EventID; + uint16 EventType; + } cfe_evs_sendEvent; +}; + +int emu_backend_request_memory(spdid_t client); + +int32 emu_CFE_EVS_Register(spdid_t sp); + +int32 emu_CFE_SB_CreatePipe(spdid_t client); + +void emu_CFE_SB_InitMsg(spdid_t client); + +int32 emu_CFE_EVS_SendEvent(spdid_t client); diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index 9139bce35d..566ae3fe70 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -26,3 +26,9 @@ cos_asm_server_stub(CFE_SB_RcvMsg) cos_asm_server_stub(CFE_SB_SendMsg) cos_asm_server_stub(CFE_SB_Subscribe) cos_asm_server_stub(CFE_SB_TimeStampMsg) + +cos_asm_server_stub(emu_backend_request_memory) +cos_asm_server_stub(emu_CFE_EVS_Register) +cos_asm_server_stub(emu_CFE_SB_CreatePipe) +cos_asm_server_stub(emu_CFE_SB_InitMsg) +cos_asm_server_stub(emu_CFE_EVS_SendEvent) diff --git a/src/components/lib/cFE_emu.c b/src/components/lib/cFE_emu.c index 6a513cae2a..c4525a99c4 100644 --- a/src/components/lib/cFE_emu.c +++ b/src/components/lib/cFE_emu.c @@ -1,8 +1,29 @@ +#include + #include +#include "../interface/resmgr/memmgr.h" #include #include +#include + +union shared_region *shared_region; +spdid_t spdid; + +void do_emulation_setup(spdid_t id) +{ + spdid = id; + + int region_id = emu_backend_request_memory(id); + + vaddr_t client_addr = 0; + memmgr_shared_page_map(id, region_id, &client_addr); + assert(client_addr); + shared_region = (void*)client_addr; +} + + // FIXME: Query the cFE to decide whether printf is enabled int is_printf_enabled = 1; @@ -21,21 +42,34 @@ void OS_printf(const char *string, ...) } -// TODO: Actually emulate these calls int32 CFE_EVS_Register (void *Filters, /* Pointer to an array of filters */ uint16 NumFilteredEvents, /* How many elements in the array? */ uint16 FilterScheme) /* Filtering Algorithm to be implemented */ { printc("CFE_EVS_Register called...\n"); - return CFE_SUCCESS; + if (FilterScheme != CFE_EVS_BINARY_FILTER) + { + return CFE_EVS_UNKNOWN_FILTER; + } + CFE_EVS_BinFilter_t *bin_filters = Filters; + int i; + for (i = 0; i < NumFilteredEvents; i++) { + shared_region->cfe_evs_register.filters[i] = bin_filters[i]; + } + shared_region->cfe_evs_register.NumEventFilters = NumFilteredEvents; + shared_region->cfe_evs_register.FilterScheme = FilterScheme; + return emu_CFE_EVS_Register(spdid); } int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *PipeName) { - printc("CFE_SB_CreatePipe called...\n"); - return CFE_SUCCESS; + shared_region->cfe_sb_createPipe.Depth = Depth; + strncpy(shared_region->cfe_sb_createPipe.PipeName, PipeName, OS_MAX_API_NAME); + int32 ret = emu_CFE_SB_CreatePipe(spdid); + *PipeIdPtr = shared_region->cfe_sb_createPipe.PipeId; + return ret; } void CFE_SB_InitMsg(void *MsgPtr, @@ -43,13 +77,26 @@ void CFE_SB_InitMsg(void *MsgPtr, uint16 Length, boolean Clear ) { - printc("CFE_SB_InitMsg called...\n"); + char *source = MsgPtr; + memcpy(shared_region->cfe_sb_initMsg.MsgBuffer, source, Length); + shared_region->cfe_sb_initMsg.MsgId = MsgId; + shared_region->cfe_sb_initMsg.Length = Length; + shared_region->cfe_sb_initMsg.Clear = Clear; + emu_CFE_SB_InitMsg(spdid); + memcpy(source, shared_region->cfe_sb_initMsg.MsgBuffer, Length); } -int32 CFE_EVS_SendEvent (uint16 EventID, +int32 CFE_EVS_SendEvent( uint16 EventID, uint16 EventType, const char *Spec, ... ) { - printc("CFE_EVS_SendEvent called...\n"); - return CFE_SUCCESS; + va_list Ptr; + va_start(Ptr, Spec); + vsnprintf(shared_region->cfe_evs_sendEvent.Msg, sizeof(shared_region->cfe_evs_sendEvent.Msg), Spec, Ptr); + va_end(Ptr); + + shared_region->cfe_evs_sendEvent.EventID = EventID; + shared_region->cfe_evs_sendEvent.EventType = EventType; + + return emu_CFE_EVS_SendEvent(spdid); } diff --git a/src/platform/i386/runscripts/llboot_cFE.sh b/src/platform/i386/runscripts/llboot_cFE.sh index c89743cc85..ec99099663 100644 --- a/src/platform/i386/runscripts/llboot_cFE.sh +++ b/src/platform/i386/runscripts/llboot_cFE.sh @@ -5,4 +5,4 @@ cp llboot_comp.o llboot.o cp resmgr.o mm.o cp cFE_booter.o boot.o -./cos_linker 'llboot.o, ;sample_lib.o, ;mm.o, ;sample_app.o, ;*boot.o, ;sch_lab.o, :boot.o-mm.o;sample_app.o-boot.o;sample_lib.o-boot.o;sch_lab.o-boot.o' ./gen_client_stub +./cos_linker 'llboot.o, ;sample_lib.o, ;mm.o, ;sample_app.o, ;*boot.o, ;sch_lab.o, :boot.o-mm.o;sample_app.o-boot.o;sample_lib.o-boot.o;sch_lab.o-boot.o;sample_app.o-mm.o;sample_lib.o-mm.o;sch_lab.o-mm.o' ./gen_client_stub From 02293f9875287f97058fe37956e95aaa313be1ae Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sat, 3 Mar 2018 14:24:17 -0500 Subject: [PATCH 095/122] Emulate the final few cFE methods This makes all the apps work! --- .../no_interface/cFE_booter/cFE_emu_support.c | 59 ++++++++++++- .../no_interface/cFE_booter/osfilesys.c | 2 +- .../no_interface/cFE_booter/osloader.c | 8 +- .../no_interface/cFE_booter/osqueue.c | 3 - .../no_interface/cFE_booter/ostask.c | 12 ++- .../no_interface/cFE_booter/ostask.h | 7 ++ src/components/include/cFE_emu.h | 34 +++++++- src/components/interface/cFE/stubs/s_stub.S | 14 ++-- src/components/lib/cFE_emu.c | 82 ++++++++++++++++++- 9 files changed, 198 insertions(+), 23 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c index c054307ca7..6c0d00e73c 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -3,6 +3,8 @@ #include +#include + #include union shared_region *shared_regions[16]; @@ -10,7 +12,7 @@ union shared_region *shared_regions[16]; int emu_backend_request_memory(spdid_t client) { vaddr_t our_addr = 0; - int id = memmgr_shared_page_alloc(cos_comp_info.cos_this_spd_id, &our_addr); + int id = memmgr_shared_page_alloc(&our_addr); assert(our_addr); shared_regions[client] = (void*)our_addr; return id; @@ -39,3 +41,58 @@ int32 emu_CFE_EVS_SendEvent(spdid_t client) union shared_region* s = shared_regions[client]; return CFE_EVS_SendEvent(s->cfe_evs_sendEvent.EventID, s->cfe_evs_sendEvent.EventType, "%s", s->cfe_evs_sendEvent.Msg); } + +int32 emu_CFE_ES_RunLoop(spdid_t client) +{ + union shared_region* s = shared_regions[client]; + return CFE_ES_RunLoop(&s->cfe_es_runLoop.RunStatus); +} + +int32 emu_CFE_SB_RcvMsg(spdid_t client) +{ + union shared_region* s = shared_regions[client]; + + CFE_SB_MsgPtr_t BufPtr; + int32 result = CFE_SB_RcvMsg(&BufPtr, s->cfe_sb_rcvMsg.PipeId, s->cfe_sb_rcvMsg.TimeOut); + + /* We want to save the message contents to the shared region + * But we need to be sure there is something to copy, so we check the call was successful + */ + if (result == CFE_SUCCESS) { + int len = CFE_SB_GetTotalMsgLength(BufPtr); + assert(len <= EMU_BUF_SIZE); + memcpy(s->cfe_sb_rcvMsg.Msg, (char*)BufPtr, len); + } + return result; +} + +uint16 emu_CFE_SB_GetTotalMsgLength(spdid_t client) +{ + union shared_region* s = shared_regions[client]; + return CFE_SB_GetTotalMsgLength(&s->cfe_sb_getMsgLen.Msg); +} + +int32 emu_CFE_SB_SendMsg(spdid_t client) +{ + union shared_region* s = shared_regions[client]; + return CFE_SB_SendMsg((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); +} + +uint16 emu_CFE_SB_GetCmdCode(spdid_t client) +{ + union shared_region* s = shared_regions[client]; + return CFE_SB_GetCmdCode((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); +} + +CFE_SB_MsgId_t emu_CFE_SB_GetMsgId(spdid_t client) +{ + union shared_region* s = shared_regions[client]; + return CFE_SB_GetMsgId((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); +} + + +void emu_CFE_SB_TimeStampMsg(spdid_t client) +{ + union shared_region* s = shared_regions[client]; + CFE_SB_TimeStampMsg((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); +} diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.c b/src/components/implementation/no_interface/cFE_booter/osfilesys.c index 5031b0e297..482c89dd29 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.c +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.c @@ -282,7 +282,7 @@ uint32 part_get_new(struct f_part **part) struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); struct cos_compinfo *ci = &defci->ci; - *part = (void*)memmgr_heap_page_alloc(cos_comp_info.cos_this_spd_id); + *part = (void*)memmgr_heap_page_alloc(); assert(part != NULL); (*part)->next = NULL; diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index 402b886d8e..6477180350 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -6,11 +6,14 @@ #include #include -#include "cFE_util.h" - #include "gen/osapi.h" #include "gen/common_types.h" +#include "cFE_util.h" +#include "ostask.h" + +thdid_t id_overrides[SL_MAX_NUM_THDS] = { 0 }; + int32 OS_ModuleTableInit(void) { return OS_SUCCESS; @@ -36,6 +39,7 @@ void launch_other_component(int child_id, int is_library) sl_thd_param_set(t, sched_param_pack(SCHEDP_PRIO, 1)); sl_thd_yield(t->thdid); } else { + id_overrides[t->thdid] = sl_thdid(); while(1) sl_thd_yield(t->thdid); } } diff --git a/src/components/implementation/no_interface/cFE_booter/osqueue.c b/src/components/implementation/no_interface/cFE_booter/osqueue.c index fe927e989f..2750beea1e 100644 --- a/src/components/implementation/no_interface/cFE_booter/osqueue.c +++ b/src/components/implementation/no_interface/cFE_booter/osqueue.c @@ -9,9 +9,6 @@ #include -#undef OS_MAX_QUEUES -#define OS_MAX_QUEUES 15 - #define MAX_QUEUE_DATA_SIZE (1024 * 1024) struct sl_lock queue_lock = SL_LOCK_STATIC_INIT(); diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 523346df50..badb6df513 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -9,6 +9,7 @@ #include "gen/common_types.h" #include "gen/cfe_time.h" +#define HZ_PAUSE (1000 * 1000) void timer_fn_1hz(void *d) @@ -17,7 +18,7 @@ timer_fn_1hz(void *d) cycles_t now, start; rdtscll(start); - start += sl_usec2cyc(250000); //250ms after + start += sl_usec2cyc(HZ_PAUSE); while (1) { rdtscll(now); @@ -33,7 +34,7 @@ timer_fn_1hz(void *d) ** Internal Task helper functions */ // We need to keep track of this to check if register or delete handler calls are invalid -#define MAIN_DELEGATE_THREAD_PRIORITY 1 +#define MAIN_DELEGATE_THREAD_PRIORITY 2 thdid_t main_delegate_thread_id; void OS_SchedulerStart(cos_thd_fn_t main_delegate) { @@ -50,7 +51,7 @@ void OS_SchedulerStart(cos_thd_fn_t main_delegate) { policy->osal_task_prop.OStask_id = (uint32) main_delegate_thread->thdid; struct sl_thd *timer_thd = sl_thd_alloc(timer_fn_1hz, NULL); - union sched_param_union spperiod = {.c = {.type = SCHEDP_WINDOW, .value = 250000 }}; + union sched_param_union spperiod = {.c = {.type = SCHEDP_WINDOW, .value = HZ_PAUSE }}; union sched_param_union spprio = {.c = {.type = SCHEDP_PRIO, .value = MAIN_DELEGATE_THREAD_PRIORITY+1}}; sl_thd_param_set(timer_thd, spperiod.v); sl_thd_param_set(timer_thd, spprio.v); @@ -156,7 +157,10 @@ int32 OS_TaskDelete(uint32 task_id) uint32 OS_TaskGetId(void) { - return sl_thdid(); + thdid_t real_id = sl_thdid(); + thdid_t possible_override = id_overrides[real_id]; + if(possible_override) return possible_override; + return real_id; } void OS_TaskExit(void) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.h b/src/components/implementation/no_interface/cFE_booter/ostask.h index c0d057c769..41df42bb8a 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.h +++ b/src/components/implementation/no_interface/cFE_booter/ostask.h @@ -1,6 +1,13 @@ #ifndef OSTASK_H #define OSTASK_H +#include + +/* + * ThreadId overrides for apps + */ +extern thdid_t id_overrides[SL_MAX_NUM_THDS]; + void OS_SchedulerStart(cos_thd_fn_t main_delegate); #endif diff --git a/src/components/include/cFE_emu.h b/src/components/include/cFE_emu.h index 60525c6376..5d45d1057f 100644 --- a/src/components/include/cFE_emu.h +++ b/src/components/include/cFE_emu.h @@ -2,6 +2,8 @@ #include +#define EMU_BUF_SIZE 512 + union shared_region { struct { CFE_EVS_BinFilter_t filters[CFE_EVS_MAX_EVENT_FILTERS]; @@ -14,16 +16,30 @@ union shared_region { char PipeName[OS_MAX_API_NAME]; } cfe_sb_createPipe; struct { - char MsgBuffer[512]; + char MsgBuffer[EMU_BUF_SIZE]; CFE_SB_MsgId_t MsgId; uint16 Length; boolean Clear; } cfe_sb_initMsg; struct { - char Msg[512]; + char Msg[EMU_BUF_SIZE]; uint16 EventID; uint16 EventType; } cfe_evs_sendEvent; + struct { + uint32 RunStatus; + } cfe_es_runLoop; + struct { + CFE_SB_PipeId_t PipeId; + int32 TimeOut; + char Msg[EMU_BUF_SIZE]; + } cfe_sb_rcvMsg; + struct { + CFE_SB_Msg_t Msg; + } cfe_sb_getMsgLen; + struct { + char Msg[EMU_BUF_SIZE]; + } cfe_sb_msg; }; int emu_backend_request_memory(spdid_t client); @@ -35,3 +51,17 @@ int32 emu_CFE_SB_CreatePipe(spdid_t client); void emu_CFE_SB_InitMsg(spdid_t client); int32 emu_CFE_EVS_SendEvent(spdid_t client); + +int32 emu_CFE_ES_RunLoop(spdid_t client); + +int32 emu_CFE_SB_RcvMsg(spdid_t client); + +uint16 emu_CFE_SB_GetTotalMsgLength(spdid_t client); + +int32 emu_CFE_SB_SendMsg(spdid_t client); + +uint16 emu_CFE_SB_GetCmdCode(spdid_t client); + +CFE_SB_MsgId_t emu_CFE_SB_GetMsgId(spdid_t client); + +void emu_CFE_SB_TimeStampMsg(spdid_t client); diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index 566ae3fe70..15f9e4f5b0 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -17,18 +17,18 @@ cos_asm_server_stub(OS_IdleLoop) cos_asm_server_stub(CFE_ES_ExitApp) cos_asm_server_stub(CFE_ES_PerfLogAdd) cos_asm_server_stub(CFE_ES_RegisterApp) -cos_asm_server_stub(CFE_ES_RunLoop) -cos_asm_server_stub(CFE_SB_GetCmdCode) -cos_asm_server_stub(CFE_SB_GetMsgId) -cos_asm_server_stub(CFE_SB_GetTotalMsgLength) -cos_asm_server_stub(CFE_SB_RcvMsg) -cos_asm_server_stub(CFE_SB_SendMsg) cos_asm_server_stub(CFE_SB_Subscribe) -cos_asm_server_stub(CFE_SB_TimeStampMsg) cos_asm_server_stub(emu_backend_request_memory) cos_asm_server_stub(emu_CFE_EVS_Register) cos_asm_server_stub(emu_CFE_SB_CreatePipe) cos_asm_server_stub(emu_CFE_SB_InitMsg) cos_asm_server_stub(emu_CFE_EVS_SendEvent) +cos_asm_server_stub(emu_CFE_ES_RunLoop) +cos_asm_server_stub(emu_CFE_SB_RcvMsg) +cos_asm_server_stub(emu_CFE_SB_GetTotalMsgLength) +cos_asm_server_stub(emu_CFE_SB_SendMsg) +cos_asm_server_stub(emu_CFE_SB_GetCmdCode) +cos_asm_server_stub(emu_CFE_SB_GetMsgId) +cos_asm_server_stub(emu_CFE_SB_TimeStampMsg) diff --git a/src/components/lib/cFE_emu.c b/src/components/lib/cFE_emu.c index c4525a99c4..6526251a5c 100644 --- a/src/components/lib/cFE_emu.c +++ b/src/components/lib/cFE_emu.c @@ -14,11 +14,11 @@ spdid_t spdid; void do_emulation_setup(spdid_t id) { spdid = id; - + int region_id = emu_backend_request_memory(id); vaddr_t client_addr = 0; - memmgr_shared_page_map(id, region_id, &client_addr); + memmgr_shared_page_map(region_id, &client_addr); assert(client_addr); shared_region = (void*)client_addr; } @@ -46,7 +46,6 @@ int32 CFE_EVS_Register (void *Filters, /* Pointer to a uint16 NumFilteredEvents, /* How many elements in the array? */ uint16 FilterScheme) /* Filtering Algorithm to be implemented */ { - printc("CFE_EVS_Register called...\n"); if (FilterScheme != CFE_EVS_BINARY_FILTER) { return CFE_EVS_UNKNOWN_FILTER; @@ -78,6 +77,7 @@ void CFE_SB_InitMsg(void *MsgPtr, boolean Clear ) { char *source = MsgPtr; + assert(Length <= EMU_BUF_SIZE); memcpy(shared_region->cfe_sb_initMsg.MsgBuffer, source, Length); shared_region->cfe_sb_initMsg.MsgId = MsgId; shared_region->cfe_sb_initMsg.Length = Length; @@ -100,3 +100,79 @@ int32 CFE_EVS_SendEvent( uint16 EventID, return emu_CFE_EVS_SendEvent(spdid); } + +int32 CFE_ES_RunLoop(uint32 *RunStatus) +{ + shared_region->cfe_es_runLoop.RunStatus = *RunStatus; + int32 result = emu_CFE_ES_RunLoop(spdid); + *RunStatus = shared_region->cfe_es_runLoop.RunStatus; + return result; +} + +/* + * We want the msg to live in this app, not the cFE component + * But the message is stored in a buffer on the cFE side + * The slution is to copy it into a buffer here + * According to the cFE spec, this buffer only needs to last till the pipe is used again + * Therefore one buffer per pipe is acceptable + */ +struct { + char buf[EMU_BUF_SIZE]; +} pipe_buffers[CFE_SB_MAX_PIPES]; + +int32 CFE_SB_RcvMsg(CFE_SB_MsgPtr_t *BufPtr, + CFE_SB_PipeId_t PipeId, + int32 TimeOut) +{ + shared_region->cfe_sb_rcvMsg.PipeId = PipeId; + shared_region->cfe_sb_rcvMsg.TimeOut = TimeOut; + int32 result = emu_CFE_SB_RcvMsg(spdid); + if (result == CFE_SUCCESS) { + memcpy(pipe_buffers[PipeId].buf, shared_region->cfe_sb_rcvMsg.Msg, EMU_BUF_SIZE); + *BufPtr = (CFE_SB_MsgPtr_t)pipe_buffers[PipeId].buf; + } + return result; +} + +uint16 CFE_SB_GetTotalMsgLength(CFE_SB_MsgPtr_t MsgPtr) +{ + shared_region->cfe_sb_getMsgLen.Msg = *MsgPtr; + return emu_CFE_SB_GetTotalMsgLength(spdid); +} + +int32 CFE_SB_SendMsg(CFE_SB_Msg_t *MsgPtr) +{ + uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); + char *msg_ptr = (char*)MsgPtr; + memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); + return emu_CFE_SB_SendMsg(spdid); +} + +uint16 CFE_SB_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr) +{ + uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); + char *msg_ptr = (char*)MsgPtr; + memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); + return emu_CFE_SB_GetCmdCode(spdid); +} + +CFE_SB_MsgId_t CFE_SB_GetMsgId(CFE_SB_MsgPtr_t MsgPtr) +{ + uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); + char *msg_ptr = (char*)MsgPtr; + memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); + return emu_CFE_SB_GetMsgId(spdid); +} + +void CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr) +{ + uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); + char *msg_ptr = (char*)MsgPtr; + memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); + emu_CFE_SB_TimeStampMsg(spdid); + memcpy(msg_ptr, shared_region->cfe_sb_msg.Msg, (size_t)msg_len); +} From 284585f371aca56b272cc3c2d27a3488be7f21c5 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 19 Mar 2018 19:02:06 -0400 Subject: [PATCH 096/122] Finalize build system changes, so cFE is under composite --- .gitmodules | 3 + src/Makefile | 13 +- .../no_interface/cFE_booter/Makefile | 2 +- src/extern/cFE | 1 + src/extern/make.py | 165 ++++++++++++++++++ 5 files changed, 182 insertions(+), 2 deletions(-) create mode 160000 src/extern/cFE create mode 100755 src/extern/make.py diff --git a/.gitmodules b/.gitmodules index 6fe6c0b6e5..5d8529eceb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "src/components/lib/ps"] path = src/components/lib/ps url = https://github.com/gwsystems/ps.git +[submodule "src/extern/cFE"] + path = src/extern/cFE + url = https://github.com/Others/cFE.git diff --git a/src/Makefile b/src/Makefile index 8a7bd33810..d5ea0b28ed 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,8 +2,19 @@ MAKEFLAGS=--no-print-directory --section-alignment 0x1000 -I$(PWD) #$(info Make flags $(MAKEFLAGS)) default: | all cp + $(info Going!) + +all: | extern comps plat + +.PHONY: extern +extern: + $(info ) + $(info ***********************************************) + $(info *********** Building External Libs ************) + $(info ***********************************************) + $(info ) + $(shell cd extern && python make.py >&2) -all: comps plat comps: $(info ) diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index e9b0991476..d4b866f2aa 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -3,7 +3,7 @@ ASM_OBJS= COMPONENT=cFE_booter.o INTERFACES=cFE DEPENDENCIES=resmgr -IF_LIB:=./composite_cFE.o $(wildcard test/*.o) +IF_LIB:=./composite_cFE.o ./cFE_fs.o $(wildcard test/*.o) ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api -lcos_defkernel_api -lsl_resmgr -lsl_sched -lheap -lsl_lock include ../../Makefile.subsubdir diff --git a/src/extern/cFE b/src/extern/cFE new file mode 160000 index 0000000000..56339c3de9 --- /dev/null +++ b/src/extern/cFE @@ -0,0 +1 @@ +Subproject commit 56339c3de9bf2e86714e03f7dc87320d9a63f63c diff --git a/src/extern/make.py b/src/extern/make.py new file mode 100755 index 0000000000..04eec9a0e5 --- /dev/null +++ b/src/extern/make.py @@ -0,0 +1,165 @@ +#!/usr/bin/env python2.7 +# cFE2cos build script. Builds Composite and the cFE and links the two together. +import argparse +import os +import shutil +import subprocess as sp + +# Load command line arguments. +parser = argparse.ArgumentParser(description='Copy cFE files over to Composite and build Composite with cFE support.') +parser.add_argument('-c', '--clean', dest='clean', action='store_true', help='Clean the Composite build directory before building it.') +parser.add_argument('-i', '--ignore-clock-skew', dest='skew', action='store_true', help='Ignore clock skew warnings when building.') +parser.add_argument('-f', '--first-time', dest='first', action='store_true', help='Also run init steps when building.') +parser.add_argument('-u', '--unit-tests', dest='unit_tests', action='store_true', help='Build unit tests.') + +args = parser.parse_args() + +print """ +####################### +## SETTING VARIABLES ## +####################### +""" + +# Find the root of the composite repository +cos_root, _ = sp.Popen("git rev-parse --show-toplevel", shell=True, stdout=sp.PIPE).communicate() +cos_root = cos_root.strip() + +# Set static variables. +COMPOSITE_DIR = cos_root + "/" +COMPOSITE_TRANSFER_DIR = COMPOSITE_DIR + "transfer/" +COMPOSITE_MAKE_ROOT = COMPOSITE_DIR + "src/" +COMPOSITE_IMPL_NO_INTERFACE_DIR = COMPOSITE_DIR + "src/components/implementation/no_interface/" +COMPOSITE_CFE_COMPONENT_ROOT = COMPOSITE_IMPL_NO_INTERFACE_DIR + "cFE_booter/" +COMPOSITE_CFE_HEADER_DESTINATION = COMPOSITE_CFE_COMPONENT_ROOT + "gen/" +print "COMPOSITE_DIR: {}".format(COMPOSITE_DIR) +print "COMPOSITE_TRANSFER_DIR: {}".format(COMPOSITE_TRANSFER_DIR) +print "COMPOSITE_MAKE_ROOT: {}".format(COMPOSITE_MAKE_ROOT) +print "COMPOSITE_CFE_COMPONENT_ROOT: {}".format(COMPOSITE_CFE_COMPONENT_ROOT) +print "COMPOSITE_CFE_HEADER_DESTINATION: {}".format(COMPOSITE_CFE_HEADER_DESTINATION) + +CFE_DIR = COMPOSITE_MAKE_ROOT + "extern/cFE/" +CFE_MAKE_ROOT = CFE_DIR + "build/cpu1/" +CFE_OBJECT_LOCATION = CFE_MAKE_ROOT + "exe/" +CFE_OBJECT_NAME = "composite_cFE.o" +print "CFE_DIR: {}".format(CFE_DIR) +print "CFE_MAKE_ROOT: {}".format(CFE_MAKE_ROOT) +print "CFE_OBJECT_LOCATION: {}".format(CFE_OBJECT_LOCATION) +print "CFE_OBJECT_NAME: {}".format(CFE_OBJECT_NAME) + +# UT is an abbreviation for Unit Tests. +COMPOSITE_CFE_UT_DESTINATION = COMPOSITE_CFE_COMPONENT_ROOT + "test/" +OSAL_UT_DIR = CFE_DIR + "osal/src/unit-tests/" +print "OSAL_UT_DIR: {}".format(OSAL_UT_DIR) +print "COMPOSITE_CFE_UT_DESTINATION: {}".format(COMPOSITE_CFE_UT_DESTINATION) + +# We don't need these stubs because we already provide our own. +# Copying them over causes duplicate symbol errors +OSAL_UT_OBJECTS_TO_SKIP = [ + "ut_osfile_stubs.o", + "ut_osfilesys_stubs.o", + "ut_osnetwork_stubs.o", + "ut_ostimer_stubs.o" +] +OSAL_UT_HEADERS_TO_COPY = [ + "oscore-test", + "osfile-test", + "osfilesys-test", + "osloader-test", + "osnetwork-test", + "osprintf-test", + "ostimer-test", + "shared" +] + +CFE_HEADERS_TO_COPY = [ + "build/cpu1/inc/cfe_platform_cfg.h", + "build/cpu1/inc/osconfig.h", + "build/mission_inc/cfe_mission_cfg.h", + "cfe/fsw/cfe-core/src/inc/*", + "osal/src/os/inc/*", + "psp/fsw/pc-composite/inc/*", + "psp/fsw/inc/*" +] + +CFE_APPS = [ + ("sch_lab", "sch_lab_app.o"), + ("sample_lib", "sample_lib.o"), + ("sample_app", "sample_app.o") +] + +# Just some shell magic to load the environment variable exports needed to build cFE. +cfe_env = sp.Popen(["bash", "-c", + "trap 'env' exit; cd {} && source \"$1\" > /dev/null 2>&1".format(CFE_DIR), + "_", "setvars.sh"], shell=False, stdout=sp.PIPE).communicate()[0] +os.environ.update(dict([line.split('=', 1) for line in filter(None, cfe_env.split("\n"))])) + +print """ +############## +## BUILDING ## +############## +""" + +OUT = "" +if args.skew: + "Warnings about clock skew will not be printed." + OUT = " 2>&1 | grep -vP 'Clock skew|in the future'" + +# Execute build +if args.clean: + print "=== Cleaning Composite ===" + sp.check_call("rm -rf *", shell=True, cwd=COMPOSITE_TRANSFER_DIR) + sp.check_call("make clean" + OUT, shell=True, cwd=COMPOSITE_MAKE_ROOT) + print "=== Cleaning cFE ===" + sp.check_call("make clean" + OUT, shell=True, cwd=CFE_MAKE_ROOT) + +print "=== Copying headers ===" +if not os.path.exists(COMPOSITE_CFE_HEADER_DESTINATION): + print "cFE header destination folder not found. Creating it now." + os.makedirs(COMPOSITE_CFE_HEADER_DESTINATION) +for header in CFE_HEADERS_TO_COPY: + sp.check_call("cp -r " + CFE_DIR + header + " " + COMPOSITE_CFE_HEADER_DESTINATION, shell=True) + +if args.unit_tests: + print "=== Building unit tests ===" + sp.call("make" + OUT, shell=True, cwd=OSAL_UT_DIR) + print "Cleaning old test objects..." + if os.path.exists(COMPOSITE_CFE_UT_DESTINATION): + shutil.rmtree(COMPOSITE_CFE_UT_DESTINATION) + os.mkdir(COMPOSITE_CFE_UT_DESTINATION) + print "Copying UT objects..." + for obj in os.listdir(OSAL_UT_DIR): + if obj not in OSAL_UT_OBJECTS_TO_SKIP and os.path.isfile(OSAL_UT_DIR + obj): + shutil.copy(OSAL_UT_DIR + obj, COMPOSITE_CFE_UT_DESTINATION) + print "Copied {} to {}".format(obj, COMPOSITE_CFE_UT_DESTINATION) + print "Copying UT headers..." + for folder in OSAL_UT_HEADERS_TO_COPY: + shutil.copytree(OSAL_UT_DIR + folder, COMPOSITE_CFE_UT_DESTINATION + folder) + print "Copied {} to {}".format(folder, COMPOSITE_CFE_UT_DESTINATION) + +print "=== Building cFE ===" + +sp.check_call("make" + OUT, shell=True, cwd=CFE_MAKE_ROOT) + +print "=== Copying cFE Object ===" +OBJECT_SOURCE = CFE_OBJECT_LOCATION + CFE_OBJECT_NAME +OBJECT_DESTINATION = COMPOSITE_CFE_COMPONENT_ROOT + CFE_OBJECT_NAME +if os.path.exists(OBJECT_DESTINATION): + os.remove(OBJECT_DESTINATION) +if not os.path.exists(OBJECT_SOURCE): + raise RuntimeError("Could not find cFE object to copy!") +shutil.copy(OBJECT_SOURCE, OBJECT_DESTINATION) +print "Copied {} to {}".format(OBJECT_SOURCE, OBJECT_DESTINATION) + +print "=== Copying apps ===" +for (app, obj) in CFE_APPS: + src = CFE_MAKE_ROOT + app + "/" + obj + dest = COMPOSITE_IMPL_NO_INTERFACE_DIR + app + "/cFE_" + obj + print "Copying app '{}' to '{}'.".format(src, dest) + shutil.copy(src, dest) + +print "=== Integrating Tar Filesystem ===" +sp.check_call("tar cf cFE_fs.tar --exclude=\"cf/apps/composite_cFE.o\" cf/" + OUT, + shell=True, cwd=CFE_OBJECT_LOCATION) +sp.check_call("ld -r -b binary cFE_fs.tar -o cFE_fs.o" + OUT, + shell=True, cwd=CFE_OBJECT_LOCATION) +shutil.copy(CFE_OBJECT_LOCATION + "/cFE_fs.o", COMPOSITE_CFE_COMPONENT_ROOT) From 8622869d29716fb58b98299013bcb2e3ac2bb39b Mon Sep 17 00:00:00 2001 From: base0x10 Date: Tue, 20 Mar 2018 12:19:33 -0400 Subject: [PATCH 097/122] change symbol names for linking filesystem During the rework of the build system, the names of a few symbols were changed. These were from _binary_cFEfs to _binary_cFE_fs. This meant that the weak symbols for the file symbols were never overwritten. The file system did not exist so reported to the cFE that initialization failed. Rather than change the error in the build system changes, it was easier to change tar.c --- .../no_interface/cFE_booter/tar.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/tar.c b/src/components/implementation/no_interface/cFE_booter/tar.c index b391c7b403..f9d74047ec 100644 --- a/src/components/implementation/no_interface/cFE_booter/tar.c +++ b/src/components/implementation/no_interface/cFE_booter/tar.c @@ -1,11 +1,12 @@ #include "osfilesys.h" #include "tar.h" #include +#include //should be overwritten by linking step in build process -__attribute__((weak)) char _binary_cFEfs_tar_size = 0; -__attribute__((weak)) char _binary_cFEfs_tar_start = 0; -__attribute__((weak)) char _binary_cFEfs_tar_end = 0; +__attribute__((weak)) char _binary_cFE_fs_tar_size = 0; +__attribute__((weak)) char _binary_cFE_fs_tar_start = 0; +__attribute__((weak)) char _binary_cFE_fs_tar_end = 0; //locations and size of tar char *tar_start; @@ -45,18 +46,18 @@ static uint32 oct_to_dec(char *oct) uint32 tar_load() { // First make sure that symbols have been overwritten by linking process - if (!_binary_cFEfs_tar_start) + if (!_binary_cFE_fs_tar_start) return OS_FS_ERR_DRIVE_NOT_CREATED; // Next check that file size is greater than 0 - if (&_binary_cFEfs_tar_size == 0) + if (&_binary_cFE_fs_tar_size == 0) return OS_FS_ERR_DRIVE_NOT_CREATED; // Check that the end of the tar is after the start - if (&_binary_cFEfs_tar_end < &_binary_cFEfs_tar_start) + if (&_binary_cFE_fs_tar_end < &_binary_cFE_fs_tar_start) return OS_FS_ERR_DRIVE_NOT_CREATED; - tar_size = (size_t) &_binary_cFEfs_tar_size; - tar_start = &_binary_cFEfs_tar_start; - tar_end = &_binary_cFEfs_tar_end; + tar_size = (size_t) &_binary_cFE_fs_tar_size; + tar_start = &_binary_cFE_fs_tar_start; + tar_end = &_binary_cFE_fs_tar_end; return OS_FS_SUCCESS; } From cd45f004e727297fb65bccc88b30131100b8bfb1 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 20 Mar 2018 15:02:29 -0400 Subject: [PATCH 098/122] Fix apps failing to boot --- .../implementation/no_interface/cFE_booter/osloader.c | 6 +++--- src/extern/make.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index 36322dd12d..1f103513bf 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -31,10 +31,10 @@ int32 OS_ModuleUnload(uint32 module_id) void launch_other_component(int child_id, int is_library) { - struct cos_defcompinfo dci; - cos_defcompinfo_childid_init(&dci, child_id); + struct cos_defcompinfo child_dci; + cos_defcompinfo_childid_init(&child_dci, child_id); - struct sl_thd *t = sl_thd_comp_init(&dci, 0); + struct sl_thd *t = sl_thd_initaep_alloc(&child_dci, NULL, 0, 0, 0); if (is_library) { sl_thd_param_set(t, sched_param_pack(SCHEDP_PRIO, 1)); sl_thd_yield(sl_thd_thdid(t)); diff --git a/src/extern/make.py b/src/extern/make.py index 04eec9a0e5..2a4bb3bc6d 100755 --- a/src/extern/make.py +++ b/src/extern/make.py @@ -117,7 +117,7 @@ print "cFE header destination folder not found. Creating it now." os.makedirs(COMPOSITE_CFE_HEADER_DESTINATION) for header in CFE_HEADERS_TO_COPY: - sp.check_call("cp -r " + CFE_DIR + header + " " + COMPOSITE_CFE_HEADER_DESTINATION, shell=True) + sp.check_call("cp -ur " + CFE_DIR + header + " " + COMPOSITE_CFE_HEADER_DESTINATION, shell=True) if args.unit_tests: print "=== Building unit tests ===" From 453b68029cee7230ae8a1bf84caf927412d719d9 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 20 Mar 2018 16:29:58 -0400 Subject: [PATCH 099/122] Make the simple 'make init', 'make', 'make run' process work --- src/Makefile | 16 ++++++++++++++-- src/extern/make.py | 6 +++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Makefile b/src/Makefile index 30eebe6782..a463970f15 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,7 @@ MAKEFLAGS=--no-print-directory --section-alignment 0x1000 -I$(PWD) #$(info Make flags $(MAKEFLAGS)) -.PHONY: default all extern comps plat +.PHONY: default all extern comps plat init_extern default: | all cp all: | extern comps plat @@ -14,6 +14,14 @@ extern: $(info ) $(shell cd extern && python make.py >&2) +init_extern: + $(info ) + $(info ***********************************************) + $(info ********** Setting up External Libs ***********) + $(info ***********************************************) + $(info ) + bash -c 'cd extern/cFE/; source setvars.sh; cd ../..; make -C extern/cFE/build/cpu1 config' + $(shell cd extern && python make.py -p >&2) comps: $(info ) @@ -46,8 +54,12 @@ distclean: clean $(MAKE) $(MAKEFLAGS) -C components distclean @rm -f `pwd`/../transfer/* -init: +init: | ensure_config init_extern init_composite + +ensure_config: test -f PLATFORM_ID || $(MAKE) $(MAKEFLAGS) config + +init_composite: $(MAKE) $(MAKEFLAGS) -C components init $(MAKE) $(MAKEFLAGS) PLATFORM=$(shell cat PLATFORM_ID) -C platform init diff --git a/src/extern/make.py b/src/extern/make.py index 2a4bb3bc6d..21862f4b72 100755 --- a/src/extern/make.py +++ b/src/extern/make.py @@ -4,13 +4,14 @@ import os import shutil import subprocess as sp +import sys # Load command line arguments. parser = argparse.ArgumentParser(description='Copy cFE files over to Composite and build Composite with cFE support.') parser.add_argument('-c', '--clean', dest='clean', action='store_true', help='Clean the Composite build directory before building it.') parser.add_argument('-i', '--ignore-clock-skew', dest='skew', action='store_true', help='Ignore clock skew warnings when building.') -parser.add_argument('-f', '--first-time', dest='first', action='store_true', help='Also run init steps when building.') parser.add_argument('-u', '--unit-tests', dest='unit_tests', action='store_true', help='Build unit tests.') +parser.add_argument('-p', '--copy-only', dest='copy_only', action='store_true', help='Don\'t build the cFE, just copy headers') args = parser.parse_args() @@ -136,6 +137,9 @@ shutil.copytree(OSAL_UT_DIR + folder, COMPOSITE_CFE_UT_DESTINATION + folder) print "Copied {} to {}".format(folder, COMPOSITE_CFE_UT_DESTINATION) +if args.copy_only: + sys.exit(0) + print "=== Building cFE ===" sp.check_call("make" + OUT, shell=True, cwd=CFE_MAKE_ROOT) From 6fe1bb7103251a47e1ba4874b9eb3647ba59bd00 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 20 Mar 2018 17:11:01 -0400 Subject: [PATCH 100/122] Fix cFE_booter code formatting --- .../no_interface/cFE_booter/cFE_emu_support.c | 118 +- .../no_interface/cFE_booter/cFE_entrypoint.c | 190 +- .../no_interface/cFE_booter/cFE_util.c | 30 +- .../no_interface/cFE_booter/cFE_util.h | 12 +- .../no_interface/cFE_booter/osapi.c | 536 +++--- .../no_interface/cFE_booter/osfiles.c | 407 ++-- .../no_interface/cFE_booter/osfilesys.c | 1664 ++++++++--------- .../no_interface/cFE_booter/osfilesys.h | 149 +- .../no_interface/cFE_booter/osloader.c | 88 +- .../no_interface/cFE_booter/osnetwork.c | 112 +- .../no_interface/cFE_booter/osqueue.c | 367 ++-- .../no_interface/cFE_booter/ostask.c | 957 +++++----- .../no_interface/cFE_booter/ostimer.c | 70 +- .../no_interface/cFE_booter/psp.c | 245 +-- .../no_interface/cFE_booter/sl_mod_fprr.c | 42 +- .../no_interface/cFE_booter/sl_mod_policy.h | 10 +- .../cFE_booter/sl_thd_static_backend.c | 13 +- .../no_interface/cFE_booter/tar.c | 184 +- .../no_interface/cFE_booter/tar.h | 39 +- src/components/include/cFE_emu.h | 70 +- src/components/include/log.h | 33 - src/components/lib/cFE_emu.c | 216 ++- src/components/lib/cos_asm_upcall.S | 2 +- src/components/lib/cos_kernel_api.c | 1 - src/kernel/include/inv.h | 6 +- 25 files changed, 2787 insertions(+), 2774 deletions(-) delete mode 100644 src/components/include/log.h diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c index 6f23dfc910..d7f2d6b594 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -12,90 +12,106 @@ union shared_region *shared_regions[16]; -int emu_backend_request_memory(spdid_t client) +int +emu_backend_request_memory(spdid_t client) { - vaddr_t our_addr = 0; - int id = memmgr_shared_page_alloc(&our_addr); - assert(our_addr); - shared_regions[client] = (void*)our_addr; - return id; + vaddr_t our_addr = 0; + int id = memmgr_shared_page_alloc(&our_addr); + assert(our_addr); + shared_regions[client] = (void *)our_addr; + return id; } -int32 emu_CFE_EVS_Register(spdid_t client) +int32 +emu_CFE_EVS_Register(spdid_t client) { - union shared_region* s = shared_regions[client]; - return CFE_EVS_Register(s->cfe_evs_register.filters, s->cfe_evs_register.NumEventFilters, s->cfe_evs_register.FilterScheme); + union shared_region *s = shared_regions[client]; + return CFE_EVS_Register(s->cfe_evs_register.filters, s->cfe_evs_register.NumEventFilters, + s->cfe_evs_register.FilterScheme); } -int32 emu_CFE_SB_CreatePipe(spdid_t client) +int32 +emu_CFE_SB_CreatePipe(spdid_t client) { - union shared_region* s = shared_regions[client]; - return CFE_SB_CreatePipe(&s->cfe_sb_createPipe.PipeId, s->cfe_sb_createPipe.Depth, s->cfe_sb_createPipe.PipeName); + union shared_region *s = shared_regions[client]; + return CFE_SB_CreatePipe(&s->cfe_sb_createPipe.PipeId, s->cfe_sb_createPipe.Depth, + s->cfe_sb_createPipe.PipeName); } -void emu_CFE_SB_InitMsg(spdid_t client) +void +emu_CFE_SB_InitMsg(spdid_t client) { - union shared_region* s = shared_regions[client]; - CFE_SB_InitMsg(s->cfe_sb_initMsg.MsgBuffer, s->cfe_sb_initMsg.MsgId, s->cfe_sb_initMsg.Length, s->cfe_sb_initMsg.Clear); + union shared_region *s = shared_regions[client]; + CFE_SB_InitMsg(s->cfe_sb_initMsg.MsgBuffer, s->cfe_sb_initMsg.MsgId, s->cfe_sb_initMsg.Length, + s->cfe_sb_initMsg.Clear); } -int32 emu_CFE_EVS_SendEvent(spdid_t client) +int32 +emu_CFE_EVS_SendEvent(spdid_t client) { - union shared_region* s = shared_regions[client]; - return CFE_EVS_SendEvent(s->cfe_evs_sendEvent.EventID, s->cfe_evs_sendEvent.EventType, "%s", s->cfe_evs_sendEvent.Msg); + union shared_region *s = shared_regions[client]; + return CFE_EVS_SendEvent(s->cfe_evs_sendEvent.EventID, s->cfe_evs_sendEvent.EventType, "%s", + s->cfe_evs_sendEvent.Msg); } -int32 emu_CFE_ES_RunLoop(spdid_t client) +int32 +emu_CFE_ES_RunLoop(spdid_t client) { - union shared_region* s = shared_regions[client]; - return CFE_ES_RunLoop(&s->cfe_es_runLoop.RunStatus); + union shared_region *s = shared_regions[client]; + return CFE_ES_RunLoop(&s->cfe_es_runLoop.RunStatus); } -int32 emu_CFE_SB_RcvMsg(spdid_t client) +int32 +emu_CFE_SB_RcvMsg(spdid_t client) { - union shared_region* s = shared_regions[client]; - - CFE_SB_MsgPtr_t BufPtr; - int32 result = CFE_SB_RcvMsg(&BufPtr, s->cfe_sb_rcvMsg.PipeId, s->cfe_sb_rcvMsg.TimeOut); - - /* We want to save the message contents to the shared region - * But we need to be sure there is something to copy, so we check the call was successful - */ - if (result == CFE_SUCCESS) { - int len = CFE_SB_GetTotalMsgLength(BufPtr); - assert(len <= EMU_BUF_SIZE); - memcpy(s->cfe_sb_rcvMsg.Msg, (char*)BufPtr, len); - } - return result; + union shared_region *s = shared_regions[client]; + + CFE_SB_MsgPtr_t BufPtr; + int32 result = CFE_SB_RcvMsg(&BufPtr, s->cfe_sb_rcvMsg.PipeId, s->cfe_sb_rcvMsg.TimeOut); + + /* We want to save the message contents to the shared region + * But we need to be sure there is something to copy, so we check the call was successful + */ + if (result == CFE_SUCCESS) { + int len = CFE_SB_GetTotalMsgLength(BufPtr); + assert(len <= EMU_BUF_SIZE); + memcpy(s->cfe_sb_rcvMsg.Msg, (char *)BufPtr, len); + } + return result; } -uint16 emu_CFE_SB_GetTotalMsgLength(spdid_t client) +uint16 +emu_CFE_SB_GetTotalMsgLength(spdid_t client) { - union shared_region* s = shared_regions[client]; - return CFE_SB_GetTotalMsgLength(&s->cfe_sb_getMsgLen.Msg); + union shared_region *s = shared_regions[client]; + return CFE_SB_GetTotalMsgLength(&s->cfe_sb_getMsgLen.Msg); } -int32 emu_CFE_SB_SendMsg(spdid_t client) +int32 +emu_CFE_SB_SendMsg(spdid_t client) { - union shared_region* s = shared_regions[client]; - return CFE_SB_SendMsg((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); + union shared_region *s = shared_regions[client]; + return CFE_SB_SendMsg((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); } -uint16 emu_CFE_SB_GetCmdCode(spdid_t client) +uint16 +emu_CFE_SB_GetCmdCode(spdid_t client) { - union shared_region* s = shared_regions[client]; - return CFE_SB_GetCmdCode((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); + union shared_region *s = shared_regions[client]; + return CFE_SB_GetCmdCode((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); } -CFE_SB_MsgId_t emu_CFE_SB_GetMsgId(spdid_t client) +CFE_SB_MsgId_t +emu_CFE_SB_GetMsgId(spdid_t client) { - union shared_region* s = shared_regions[client]; - return CFE_SB_GetMsgId((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); + union shared_region *s = shared_regions[client]; + return CFE_SB_GetMsgId((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); } -void emu_CFE_SB_TimeStampMsg(spdid_t client) +void +emu_CFE_SB_TimeStampMsg(spdid_t client) { - union shared_region* s = shared_regions[client]; - CFE_SB_TimeStampMsg((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); + union shared_region *s = shared_regions[client]; + CFE_SB_TimeStampMsg((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); } diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c index d6e81939a7..59d7967c8c 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c @@ -11,8 +11,10 @@ #include "test/shared/ut_main_composite.h" #endif -// This is based on an old build technique, so we can ignore this warning. -// But I'm leaving it in, just in case we ever switch to cmake +/* This is based on an old build technique, so we can ignore this warning. + * But I'm leaving it in, just in case we ever switch to cmake + */ + /* * cfe_platform_cfg.h needed for CFE_ES_NONVOL_STARTUP_FILE, CFE_CPU_ID/CPU_NAME/SPACECRAFT_ID * @@ -24,128 +26,132 @@ #include "gen/cfe_platform_cfg.h" -extern void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId, const char *StartFilePath ); +extern void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId, const char *StartFilePath); extern void CFE_TIME_Local1HzISR(void); -#define CFE_ES_MAIN_FUNCTION CFE_ES_Main -#define CFE_TIME_1HZ_FUNCTION CFE_TIME_Local1HzISR +#define CFE_ES_MAIN_FUNCTION CFE_ES_Main +#define CFE_TIME_1HZ_FUNCTION CFE_TIME_Local1HzISR /* * The classic build does not support static modules, * so stub the ModuleInit() function out right here */ -void CFE_PSP_ModuleInit(void) +void +CFE_PSP_ModuleInit(void) { } // "Magic" constants -#define CFE_PSP_CPU_NAME_LENGTH 32 +#define CFE_PSP_CPU_NAME_LENGTH 32 #define CFE_PSP_RESET_NAME_LENGTH 10 /* -* Structure for the Command line parameters -* Stolen from the Linux psp_start function... -*/ + * Structure for the Command line parameters + * Stolen from the Linux psp_start function... + */ struct CFE_PSP_CommandData_t { - char ResetType[CFE_PSP_RESET_NAME_LENGTH]; /* Reset type can be "PO" for Power on or "PR" for Processor Reset */ + char ResetType[CFE_PSP_RESET_NAME_LENGTH]; /* Reset type can be "PO" for Power on or "PR" for Processor Reset */ - uint32 SubType; /* Reset Sub Type ( 1 - 5 ) */ + uint32 SubType; /* Reset Sub Type ( 1 - 5 ) */ - char CpuName[CFE_PSP_CPU_NAME_LENGTH]; /* CPU Name */ + char CpuName[CFE_PSP_CPU_NAME_LENGTH]; /* CPU Name */ - uint32 CpuId; /* CPU ID */ + uint32 CpuId; /* CPU ID */ - uint32 SpacecraftId; /* Spacecraft ID */ + uint32 SpacecraftId; /* Spacecraft ID */ }; -void command_line_set_defaults(struct CFE_PSP_CommandData_t* args) { - strncpy(args->ResetType, "PO", 2); - args->SubType = 1; - args->CpuId = 1; - args->SpacecraftId = CFE_SPACECRAFT_ID; +void +command_line_set_defaults(struct CFE_PSP_CommandData_t *args) +{ + strncpy(args->ResetType, "PO", 2); + args->SubType = 1; + args->CpuId = 1; + args->SpacecraftId = CFE_SPACECRAFT_ID; } // This must be global so that cos_init_delegate can read it // TODO: Consider passing cos_init_delegate this data instead -uint32 reset_type; +uint32 reset_type; struct CFE_PSP_CommandData_t args; // This is the delegate function called by the scheduler -void cos_init_delegate(void* data) { - OS_printf("CFE_PSP: Doing PSP setup...\n"); +void +cos_init_delegate(void *data) +{ + OS_printf("CFE_PSP: Doing PSP setup...\n"); #ifdef UNIT_TESTS - OS_printf("Beginning unit tests\n"); - Composite_UT_oscore(); - Composite_UT_osfile(); - Composite_UT_osfilesys(); - Composite_UT_osloader(); - Composite_UT_osnetwork(); - Composite_UT_ostimer(); - OS_printf("End unit tests\n"); + OS_printf("Beginning unit tests\n"); + Composite_UT_oscore(); + Composite_UT_osfile(); + Composite_UT_osfilesys(); + Composite_UT_osloader(); + Composite_UT_osnetwork(); + Composite_UT_ostimer(); + OS_printf("End unit tests\n"); #endif - /* - ** Initialize the statically linked modules (if any) - ** This is only applicable to CMake build - classic build - ** does not have the logic to selectively include/exclude modules - ** - ** This is useless until we support cmake - */ - CFE_PSP_ModuleInit(); - - /* - ** Initialize the reserved memory - */ - CFE_PSP_InitProcessorReservedMemory(reset_type); - - OS_printf("CFE_PSP: PSP setup successful!\n"); - - OS_printf("CFE_PSP: Starting the cFE proper...\n"); - /* - ** Call cFE entry point. - */ - CFE_ES_MAIN_FUNCTION(reset_type, args.SubType, 1, CFE_ES_NONVOL_STARTUP_FILE); - - OS_printf("CFE_PSP: cFE started, main thread sleeping\n"); - - /* - ** Let the main thread sleep. - ** - ** OS_IdleLoop() will wait forever and return if - ** someone calls OS_ApplicationShutdown(TRUE) - */ - OS_IdleLoop(); - - PANIC("Application was shutdown!"); + /* + ** Initialize the statically linked modules (if any) + ** This is only applicable to CMake build - classic build + ** does not have the logic to selectively include/exclude modules + ** + ** This is useless until we support cmake + */ + CFE_PSP_ModuleInit(); + + /* + ** Initialize the reserved memory + */ + CFE_PSP_InitProcessorReservedMemory(reset_type); + + OS_printf("CFE_PSP: PSP setup successful!\n"); + + OS_printf("CFE_PSP: Starting the cFE proper...\n"); + /* + ** Call cFE entry point. + */ + CFE_ES_MAIN_FUNCTION(reset_type, args.SubType, 1, CFE_ES_NONVOL_STARTUP_FILE); + + OS_printf("CFE_PSP: cFE started, main thread sleeping\n"); + + /* + ** Let the main thread sleep. + ** + ** OS_IdleLoop() will wait forever and return if + ** someone calls OS_ApplicationShutdown(TRUE) + */ + OS_IdleLoop(); + + PANIC("Application was shutdown!"); } -void cos_init(void) { - command_line_set_defaults(&args); - - /* - ** Set the reset type - */ - if (strncmp("PR", args.ResetType, 2 ) == 0) - { - reset_type = CFE_PSP_RST_TYPE_PROCESSOR; - OS_printf("CFE_PSP: Starting the cFE with a PROCESSOR reset.\n"); - } - else - { - reset_type = CFE_PSP_RST_TYPE_POWERON; - OS_printf("CFE_PSP: Starting the cFE with a POWER ON reset.\n"); - } - - CFE_PSP_SpacecraftId = args.SpacecraftId; - CFE_PSP_CpuId = args.CpuId; - /* - ** Initialize the OS API - */ - OS_printf("CFE_PSP: Initializing the OS API...\n"); - OS_API_Init(); - OS_printf("CFE_PSP: The the OS API was successfully initialized!\n"); - - OS_printf("CFE_PSP: Delegating to scheduler setup... \n"); - OS_SchedulerStart(&cos_init_delegate); +void +cos_init(void) +{ + command_line_set_defaults(&args); + + /* + ** Set the reset type + */ + if (strncmp("PR", args.ResetType, 2) == 0) { + reset_type = CFE_PSP_RST_TYPE_PROCESSOR; + OS_printf("CFE_PSP: Starting the cFE with a PROCESSOR reset.\n"); + } else { + reset_type = CFE_PSP_RST_TYPE_POWERON; + OS_printf("CFE_PSP: Starting the cFE with a POWER ON reset.\n"); + } + + CFE_PSP_SpacecraftId = args.SpacecraftId; + CFE_PSP_CpuId = args.CpuId; + /* + ** Initialize the OS API + */ + OS_printf("CFE_PSP: Initializing the OS API...\n"); + OS_API_Init(); + OS_printf("CFE_PSP: The the OS API was successfully initialized!\n"); + + OS_printf("CFE_PSP: Delegating to scheduler setup... \n"); + OS_SchedulerStart(&cos_init_delegate); } diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.c b/src/components/implementation/no_interface/cFE_booter/cFE_util.c index f4a37415ae..1cdb29f917 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.c @@ -10,37 +10,23 @@ #include "gen/osapi.h" #include "cFE_util.h" -void llprint(const char *s, int len) +void +llprint(const char *s, int len) { call_cap(PRINT_CAP_TEMP, (int)s, len, 0, 0); } -void panic_impl(const char* function, char* message){ +void +panic_impl(const char *function, char *message) +{ printc("cFE panic in %s: %s", function, message); assert(0); } -void print_with_error_name(char* message, int32 error) { +void +print_with_error_name(char *message, int32 error) +{ os_err_name_t local_name; OS_GetErrorName(error, &local_name); printc("%s, error %s\n", message, local_name); } - -void free(void* ptr) { - PANIC("No free implementation!"); -} - -void* realloc(void* ptr, size_t new_size) { - PANIC("No realloc implementation!"); - return NULL; -} - -int __isoc99_sscanf(const char *buf, const char *fmt, ...) { - int count; - va_list ap; - - va_start(ap, fmt); - count = vsscanf(buf, fmt, ap); - va_end(ap); - return count; -} diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.h b/src/components/implementation/no_interface/cFE_booter/cFE_util.h index f109962394..17589f5abb 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.h +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.h @@ -14,19 +14,17 @@ #include "gen/common_types.h" // These variables store the global SPACECRAFT_ID and CPU_ID -uint32 CFE_PSP_SpacecraftId; -uint32 CFE_PSP_CpuId; +uint32 CFE_PSP_SpacecraftId; +uint32 CFE_PSP_CpuId; void llprint(const char *s, int len); -int __attribute__((format(printf,1,2))) printc(char *fmt, ...); +int __attribute__((format(printf, 1, 2))) printc(char *fmt, ...); #define PANIC(a) panic_impl(__func__, a) -void panic_impl(const char* function, char* message); +void panic_impl(const char *function, char *message); -void print_with_error_name(char* message, int32 error); - -int __isoc99_sscanf(const char *str, const char *format, ...); +void print_with_error_name(char *message, int32 error); #endif diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 96d2cb3d8c..bd4d379a23 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -16,22 +16,23 @@ */ int have_initialized = 0; -int32 OS_API_Init(void) +int32 +OS_API_Init(void) { - if(!have_initialized) { - cos_defcompinfo_init(); - struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); - struct cos_compinfo *ci = cos_compinfo_get(defci); - cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); + if (!have_initialized) { + cos_defcompinfo_init(); + struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); + struct cos_compinfo * ci = cos_compinfo_get(defci); + cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); - OS_FS_Init(); + OS_FS_Init(); - OS_ModuleTableInit(); + OS_ModuleTableInit(); - have_initialized = 1; - } + have_initialized = 1; + } - return OS_SUCCESS; + return OS_SUCCESS; } /* @@ -39,351 +40,367 @@ int32 OS_API_Init(void) ** instance of OSAL. It would typically be used during an orderly shutdown but may also ** be helpful for testing purposes. */ -void OS_DeleteAllObjects(void) -{ - uint32 i; - - // FIXME: Add deleting tasks when we have a way of iterating through them - // for (i = 0; i < OS_MAX_TASKS; ++i) - // { - // OS_TaskDelete(i); - // } - for (i = 0; i < OS_MAX_QUEUES; ++i) - { - OS_QueueDelete(i); - } - for (i = 0; i < OS_MAX_MUTEXES; ++i) - { - OS_MutSemDelete(i); - } - for (i = 0; i < OS_MAX_COUNT_SEMAPHORES; ++i) - { - OS_CountSemDelete(i); - } - for (i = 0; i < OS_MAX_BIN_SEMAPHORES; ++i) - { - OS_BinSemDelete(i); - } - // for (i = 0; i < OS_MAX_TIMERS; ++i) - // { - // OS_TimerDelete(i); - // } - // for (i = 0; i < OS_MAX_MODULES; ++i) - // { - // OS_ModuleUnload(i); - // } - for (i = 0; i < OS_MAX_NUM_OPEN_FILES; ++i) - { - OS_close(i); - } -} +void +OS_DeleteAllObjects(void) +{ + uint32 i; + /* FIXME: Add deleting tasks when we have a way of iterating through them + * for (i = 0; i < OS_MAX_TASKS; ++i) + * { + * OS_TaskDelete(i); + * } + * for (i = 0; i < OS_MAX_TIMERS; ++i) + * { + * OS_TimerDelete(i); + * } */ + for (i = 0; i < OS_MAX_QUEUES; ++i) { OS_QueueDelete(i); } + for (i = 0; i < OS_MAX_MUTEXES; ++i) { OS_MutSemDelete(i); } + for (i = 0; i < OS_MAX_COUNT_SEMAPHORES; ++i) { OS_CountSemDelete(i); } + for (i = 0; i < OS_MAX_BIN_SEMAPHORES; ++i) { OS_BinSemDelete(i); } + for (i = 0; i < OS_MAX_MODULES; ++i) { OS_ModuleUnload(i); } + for (i = 0; i < OS_MAX_NUM_OPEN_FILES; ++i) { OS_close(i); } +} /* ** OS Time/Tick related API */ -int32 OS_Milli2Ticks(uint32 milli_seconds) +int32 +OS_Milli2Ticks(uint32 milli_seconds) { - return (int32) (CFE_PSP_GetTimerTicksPerSecond() * milli_seconds) / 1000; + return (int32)(CFE_PSP_GetTimerTicksPerSecond() * milli_seconds) / 1000; } -int32 OS_Tick2Micros(void) +int32 +OS_Tick2Micros(void) { - return SL_MIN_PERIOD_US; + return SL_MIN_PERIOD_US; } -OS_time_t local_time; +OS_time_t local_time; microsec_t last_time_check; -OS_time_t OS_AdvanceTime(OS_time_t initial_time, microsec_t usec) { - microsec_t old_seconds = (microsec_t) initial_time.seconds; - microsec_t old_additional_usec = (microsec_t) initial_time.microsecs; +OS_time_t +OS_AdvanceTime(OS_time_t initial_time, microsec_t usec) +{ + microsec_t old_seconds = (microsec_t)initial_time.seconds; + microsec_t old_additional_usec = (microsec_t)initial_time.microsecs; - microsec_t old_usec = old_seconds * (1000 * 1000) + old_additional_usec; - microsec_t new_usec = old_usec + usec; + microsec_t old_usec = old_seconds * (1000 * 1000) + old_additional_usec; + microsec_t new_usec = old_usec + usec; - microsec_t new_seconds = new_usec / (1000 * 1000); - microsec_t new_additional_usec = new_usec % (1000 * 1000); + microsec_t new_seconds = new_usec / (1000 * 1000); + microsec_t new_additional_usec = new_usec % (1000 * 1000); - return (OS_time_t) { - .seconds = new_seconds, - .microsecs = new_additional_usec - }; + return (OS_time_t){.seconds = new_seconds, .microsecs = new_additional_usec}; } -int32 OS_GetLocalTime(OS_time_t *time_struct) +int32 +OS_GetLocalTime(OS_time_t *time_struct) { - if(!time_struct) { - return OS_INVALID_POINTER; - } + if (!time_struct) { return OS_INVALID_POINTER; } - if(last_time_check == 0) { - local_time = (OS_time_t) { - .seconds = 1181683060, - .microsecs = 0 - }; - last_time_check = sl_now_usec(); - } else { - microsec_t current_time = sl_now_usec(); - microsec_t elapsed_usec = current_time - last_time_check; + if (last_time_check == 0) { + local_time = (OS_time_t){.seconds = 1181683060, .microsecs = 0}; + last_time_check = sl_now_usec(); + } else { + microsec_t current_time = sl_now_usec(); + microsec_t elapsed_usec = current_time - last_time_check; - local_time = OS_AdvanceTime(local_time, elapsed_usec); - last_time_check = current_time; - } + local_time = OS_AdvanceTime(local_time, elapsed_usec); + last_time_check = current_time; + } - *time_struct = local_time; + *time_struct = local_time; - return OS_SUCCESS; + return OS_SUCCESS; -}/* end OS_GetLocalTime */ +} /* end OS_GetLocalTime */ -int32 OS_SetLocalTime(OS_time_t *time_struct) +int32 +OS_SetLocalTime(OS_time_t *time_struct) { - if(!time_struct) { - return OS_INVALID_POINTER; - } + if (!time_struct) { return OS_INVALID_POINTER; } - local_time = *time_struct; - last_time_check = sl_now_usec(); + local_time = *time_struct; + last_time_check = sl_now_usec(); - return OS_SUCCESS; + return OS_SUCCESS; } /*end OS_SetLocalTime */ /* ** Exception API */ -int32 OS_ExcAttachHandler(uint32 ExceptionNumber, - void (*ExceptionHandler)(uint32, const void *,uint32), - int32 parameter) +int32 +OS_ExcAttachHandler(uint32 ExceptionNumber, void (*ExceptionHandler)(uint32, const void *, uint32), int32 parameter) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_ExcEnable (int32 ExceptionNumber) +int32 +OS_ExcEnable(int32 ExceptionNumber) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_ExcDisable (int32 ExceptionNumber) +int32 +OS_ExcDisable(int32 ExceptionNumber) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } /* ** Floating Point Unit API */ -int32 OS_FPUExcAttachHandler(uint32 ExceptionNumber, void * ExceptionHandler, - int32 parameter) +int32 +OS_FPUExcAttachHandler(uint32 ExceptionNumber, void *ExceptionHandler, int32 parameter) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_FPUExcEnable(int32 ExceptionNumber) +int32 +OS_FPUExcEnable(int32 ExceptionNumber) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_FPUExcDisable(int32 ExceptionNumber) +int32 +OS_FPUExcDisable(int32 ExceptionNumber) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_FPUExcSetMask(uint32 mask) +int32 +OS_FPUExcSetMask(uint32 mask) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_FPUExcGetMask(uint32 *mask) +int32 +OS_FPUExcGetMask(uint32 *mask) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } /* ** Interrupt API */ -int32 OS_IntAttachHandler(uint32 InterruptNumber, osal_task_entry InterruptHandler, int32 parameter) +int32 +OS_IntAttachHandler(uint32 InterruptNumber, osal_task_entry InterruptHandler, int32 parameter) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_IntUnlock(int32 IntLevel) +int32 +OS_IntUnlock(int32 IntLevel) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_IntLock(void) +int32 +OS_IntLock(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_IntEnable(int32 Level) +int32 +OS_IntEnable(int32 Level) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_IntDisable(int32 Level) +int32 +OS_IntDisable(int32 Level) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_IntSetMask(uint32 mask) +int32 +OS_IntSetMask(uint32 mask) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_IntGetMask(uint32 *mask) +int32 +OS_IntGetMask(uint32 *mask) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_IntAck(int32 InterruptNumber) +int32 +OS_IntAck(int32 InterruptNumber) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } /* ** Shared memory API */ -int32 OS_ShMemInit(void) +int32 +OS_ShMemInit(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_ShMemCreate(uint32 *Id, uint32 NBytes, const char* SegName) +int32 +OS_ShMemCreate(uint32 *Id, uint32 NBytes, const char *SegName) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_ShMemSemTake(uint32 Id) +int32 +OS_ShMemSemTake(uint32 Id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_ShMemSemGive(uint32 Id) +int32 +OS_ShMemSemGive(uint32 Id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_ShMemAttach(cpuaddr * Address, uint32 Id) +int32 +OS_ShMemAttach(cpuaddr *Address, uint32 Id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_ShMemGetIdByName(uint32 *ShMemId, const char *SegName ) +int32 +OS_ShMemGetIdByName(uint32 *ShMemId, const char *SegName) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } /* ** Heap API */ -int32 OS_HeapGetInfo(OS_heap_prop_t *heap_prop) +int32 +OS_HeapGetInfo(OS_heap_prop_t *heap_prop) { - // FIXME: Implement me! - return OS_ERR_NOT_IMPLEMENTED; + // FIXME: Implement me! + return OS_ERR_NOT_IMPLEMENTED; } /* ** API for useful debugging function +** (Implementation stolen from the posix osapi) */ -// Implementation stolen from the posix os api -int32 OS_GetErrorName(int32 error_num, os_err_name_t* err_name) -{ - /* - * Implementation note for developers: - * - * The size of the string literals below (including the terminating null) - * must fit into os_err_name_t. Always check the string length when - * adding or modifying strings in this function. If changing os_err_name_t - * then confirm these strings will fit. - */ - - os_err_name_t local_name; - uint32 return_code = OS_SUCCESS; - - if ( err_name == NULL ) - { - return(OS_INVALID_POINTER); - } - - switch (error_num) - { - case OS_SUCCESS: - strcpy(local_name,"OS_SUCCESS"); break; - case OS_ERROR: - strcpy(local_name,"OS_ERROR"); break; - case OS_INVALID_POINTER: - strcpy(local_name,"OS_INVALID_POINTER"); break; - case OS_ERROR_ADDRESS_MISALIGNED: - strcpy(local_name,"OS_ADDRESS_MISALIGNED"); break; - case OS_ERROR_TIMEOUT: - strcpy(local_name,"OS_ERROR_TIMEOUT"); break; - case OS_INVALID_INT_NUM: - strcpy(local_name,"OS_INVALID_INT_NUM"); break; - case OS_SEM_FAILURE: - strcpy(local_name,"OS_SEM_FAILURE"); break; - case OS_SEM_TIMEOUT: - strcpy(local_name,"OS_SEM_TIMEOUT"); break; - case OS_QUEUE_EMPTY: - strcpy(local_name,"OS_QUEUE_EMPTY"); break; - case OS_QUEUE_FULL: - strcpy(local_name,"OS_QUEUE_FULL"); break; - case OS_QUEUE_TIMEOUT: - strcpy(local_name,"OS_QUEUE_TIMEOUT"); break; - case OS_QUEUE_INVALID_SIZE: - strcpy(local_name,"OS_QUEUE_INVALID_SIZE"); break; - case OS_QUEUE_ID_ERROR: - strcpy(local_name,"OS_QUEUE_ID_ERROR"); break; - case OS_ERR_NAME_TOO_LONG: - strcpy(local_name,"OS_ERR_NAME_TOO_LONG"); break; - case OS_ERR_NO_FREE_IDS: - strcpy(local_name,"OS_ERR_NO_FREE_IDS"); break; - case OS_ERR_NAME_TAKEN: - strcpy(local_name,"OS_ERR_NAME_TAKEN"); break; - case OS_ERR_INVALID_ID: - strcpy(local_name,"OS_ERR_INVALID_ID"); break; - case OS_ERR_NAME_NOT_FOUND: - strcpy(local_name,"OS_ERR_NAME_NOT_FOUND"); break; - case OS_ERR_SEM_NOT_FULL: - strcpy(local_name,"OS_ERR_SEM_NOT_FULL"); break; - case OS_ERR_INVALID_PRIORITY: - strcpy(local_name,"OS_ERR_INVALID_PRIORITY"); break; - - default: strcpy(local_name,"ERROR_UNKNOWN"); - return_code = OS_ERROR; - } - - strcpy((char*) err_name, local_name); - - return return_code; +int32 +OS_GetErrorName(int32 error_num, os_err_name_t *err_name) +{ + /* + * Implementation note for developers: + * + * The size of the string literals below (including the terminating null) + * must fit into os_err_name_t. Always check the string length when + * adding or modifying strings in this function. If changing os_err_name_t + * then confirm these strings will fit. + */ + + os_err_name_t local_name; + uint32 return_code = OS_SUCCESS; + + if (err_name == NULL) { return (OS_INVALID_POINTER); } + + switch (error_num) { + case OS_SUCCESS: + strcpy(local_name, "OS_SUCCESS"); + break; + case OS_ERROR: + strcpy(local_name, "OS_ERROR"); + break; + case OS_INVALID_POINTER: + strcpy(local_name, "OS_INVALID_POINTER"); + break; + case OS_ERROR_ADDRESS_MISALIGNED: + strcpy(local_name, "OS_ADDRESS_MISALIGNED"); + break; + case OS_ERROR_TIMEOUT: + strcpy(local_name, "OS_ERROR_TIMEOUT"); + break; + case OS_INVALID_INT_NUM: + strcpy(local_name, "OS_INVALID_INT_NUM"); + break; + case OS_SEM_FAILURE: + strcpy(local_name, "OS_SEM_FAILURE"); + break; + case OS_SEM_TIMEOUT: + strcpy(local_name, "OS_SEM_TIMEOUT"); + break; + case OS_QUEUE_EMPTY: + strcpy(local_name, "OS_QUEUE_EMPTY"); + break; + case OS_QUEUE_FULL: + strcpy(local_name, "OS_QUEUE_FULL"); + break; + case OS_QUEUE_TIMEOUT: + strcpy(local_name, "OS_QUEUE_TIMEOUT"); + break; + case OS_QUEUE_INVALID_SIZE: + strcpy(local_name, "OS_QUEUE_INVALID_SIZE"); + break; + case OS_QUEUE_ID_ERROR: + strcpy(local_name, "OS_QUEUE_ID_ERROR"); + break; + case OS_ERR_NAME_TOO_LONG: + strcpy(local_name, "OS_ERR_NAME_TOO_LONG"); + break; + case OS_ERR_NO_FREE_IDS: + strcpy(local_name, "OS_ERR_NO_FREE_IDS"); + break; + case OS_ERR_NAME_TAKEN: + strcpy(local_name, "OS_ERR_NAME_TAKEN"); + break; + case OS_ERR_INVALID_ID: + strcpy(local_name, "OS_ERR_INVALID_ID"); + break; + case OS_ERR_NAME_NOT_FOUND: + strcpy(local_name, "OS_ERR_NAME_NOT_FOUND"); + break; + case OS_ERR_SEM_NOT_FULL: + strcpy(local_name, "OS_ERR_SEM_NOT_FULL"); + break; + case OS_ERR_INVALID_PRIORITY: + strcpy(local_name, "OS_ERR_INVALID_PRIORITY"); + break; + + default: + strcpy(local_name, "ERROR_UNKNOWN"); + return_code = OS_ERROR; + } + + strcpy((char *)err_name, local_name); + + return return_code; } @@ -392,36 +409,40 @@ int32 OS_GetErrorName(int32 error_num, os_err_name_t* err_name) */ int is_printf_enabled = TRUE; -void OS_printf(const char *string, ...) +void +OS_printf(const char *string, ...) { - if(is_printf_enabled) { - char s[OS_BUFFER_SIZE]; - va_list arg_ptr; - int ret, len = OS_BUFFER_SIZE; + if (is_printf_enabled) { + char s[OS_BUFFER_SIZE]; + va_list arg_ptr; + int ret, len = OS_BUFFER_SIZE; - va_start(arg_ptr, string); - ret = vsnprintf(s, len, string, arg_ptr); - va_end(arg_ptr); - llprint(s, ret); - } + va_start(arg_ptr, string); + ret = vsnprintf(s, len, string, arg_ptr); + va_end(arg_ptr); + llprint(s, ret); + } } -void OS_sprintf(char *str, const char *format, ...) +void +OS_sprintf(char *str, const char *format, ...) { - va_list arg_ptr; - va_start(arg_ptr, format); - vsprintf(str, format, arg_ptr); - va_end(arg_ptr); + va_list arg_ptr; + va_start(arg_ptr, format); + vsprintf(str, format, arg_ptr); + va_end(arg_ptr); } -void OS_printf_disable(void) +void +OS_printf_disable(void) { - is_printf_enabled = FALSE; + is_printf_enabled = FALSE; } -void OS_printf_enable(void) +void +OS_printf_enable(void) { - is_printf_enabled = TRUE; + is_printf_enabled = TRUE; } /* @@ -429,13 +450,8 @@ void OS_printf_enable(void) ** Normally embedded applications run forever, but for debugging purposes ** (unit testing for example) this is needed in order to end the test */ -void OS_ApplicationExit(int32 Status) +void +OS_ApplicationExit(int32 Status) { - PANIC("Application exit invoked!"); + PANIC("Application exit invoked!"); } - -/* TODO: Linker test, delete me. */ -void call_inv(void) { } - -/* TODO: Linker test, delete me. */ -void call(void) { } diff --git a/src/components/implementation/no_interface/cFE_booter/osfiles.c b/src/components/implementation/no_interface/cFE_booter/osfiles.c index 2bedf62446..697fb94622 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfiles.c +++ b/src/components/implementation/no_interface/cFE_booter/osfiles.c @@ -6,212 +6,225 @@ ******************************************************************************/ /* * Initializes the File System functions -*/ + */ -int32 OS_FS_Init(void) +int32 +OS_FS_Init(void) { - os_dirent_t d; + os_dirent_t d; - uint32 ret = 0; - ret = tar_load(); - if (ret != OS_FS_SUCCESS) return ret; - ret = fs_init("/ramdev0", "RAM", 512, 4096); - if (ret != OS_FS_SUCCESS) return ret; - return tar_parse(); + uint32 ret = 0; + ret = tar_load(); + if (ret != OS_FS_SUCCESS) return ret; + ret = fs_init("/ramdev0", "RAM", 512, 4096); + if (ret != OS_FS_SUCCESS) return ret; + return tar_parse(); } /* * Creates a file specified by path -*/ -int32 OS_creat(const char *path, int32 access) + */ +int32 +OS_creat(const char *path, int32 access) { - int32 ret = path_isvalid(path); - if (access != OS_READ_WRITE && access != OS_WRITE_ONLY) return OS_FS_ERROR; - if (ret != OS_FS_SUCCESS) return ret; - return file_create((char *) path, access); + int32 ret = path_isvalid(path); + if (access != OS_READ_WRITE && access != OS_WRITE_ONLY) return OS_FS_ERROR; + if (ret != OS_FS_SUCCESS) return ret; + return file_create((char *)path, access); } /* * Open a file for reading/writing. Returns file descriptor -*/ -int32 OS_open(const char *path, int32 access, uint32 mode) + */ +int32 +OS_open(const char *path, int32 access, uint32 mode) { - if (access != OS_READ_WRITE && access != OS_WRITE_ONLY && access != OS_READ_ONLY) { - return OS_FS_ERROR; - } - int32 ret = path_exists(path); - if (ret != OS_FS_SUCCESS) return ret; - return file_open((char *)path, access); + if (access != OS_READ_WRITE && access != OS_WRITE_ONLY && access != OS_READ_ONLY) { return OS_FS_ERROR; } + int32 ret = path_exists(path); + if (ret != OS_FS_SUCCESS) return ret; + return file_open((char *)path, access); } /* * Closes an open file. -*/ -int32 OS_close(int32 filedes) + */ +int32 +OS_close(int32 filedes) { - if (chk_fd(filedes) != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_FD; - return file_close(filedes); + if (chk_fd(filedes) != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_FD; + return file_close(filedes); } /* * Reads nbytes bytes from file into buffer -*/ -int32 OS_read(int32 filedes, void *buffer, uint32 nbytes) + */ +int32 +OS_read(int32 filedes, void *buffer, uint32 nbytes) { - if (chk_fd(filedes) != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_FD; - return file_read(filedes, buffer, nbytes); + if (chk_fd(filedes) != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_FD; + return file_read(filedes, buffer, nbytes); } /* * Write nybytes bytes of buffer into the file -*/ -int32 OS_write(int32 filedes, void *buffer, uint32 nbytes) + */ +int32 +OS_write(int32 filedes, void *buffer, uint32 nbytes) { - return file_write(filedes, buffer, nbytes); + return file_write(filedes, buffer, nbytes); } /* * Changes the permissions of a file * This is not used by the cFE and UT tests that it returns NOT_IMPLEMENTED -*/ -int32 OS_chmod(const char *path, uint32 access) + */ +int32 +OS_chmod(const char *path, uint32 access) { - return OS_ERR_NOT_IMPLEMENTED; + return OS_ERR_NOT_IMPLEMENTED; } /* * Returns file status information in filestats -*/ -int32 OS_stat(const char *path, os_fstat_t *filestats) + */ +int32 +OS_stat(const char *path, os_fstat_t *filestats) { - if (!filestats || !path) return OS_FS_ERR_INVALID_POINTER; - int32 ret = path_exists(path); - if (ret != OS_FS_SUCCESS) return ret; - return file_stat((char *) path, filestats); + if (!filestats || !path) return OS_FS_ERR_INVALID_POINTER; + int32 ret = path_exists(path); + if (ret != OS_FS_SUCCESS) return ret; + return file_stat((char *)path, filestats); } /* * Seeks to the specified position of an open file -*/ -int32 OS_lseek(int32 filedes, int32 offset, uint32 whence) + */ +int32 +OS_lseek(int32 filedes, int32 offset, uint32 whence) { - return file_lseek(filedes, offset, whence); + return file_lseek(filedes, offset, whence); } /* * Removes a file from the file system -*/ -int32 OS_remove(const char *path) + */ +int32 +OS_remove(const char *path) { - int32 ret = path_exists(path); - if (ret != OS_FS_SUCCESS) return ret; - return file_remove((char *)path); + int32 ret = path_exists(path); + if (ret != OS_FS_SUCCESS) return ret; + return file_remove((char *)path); } /* * Renames a file in the file system -*/ -int32 OS_rename(const char *old_filename, const char *new_filename) { - if (!old_filename || !new_filename) return OS_FS_ERR_INVALID_POINTER; - int32 ret = path_exists(old_filename); - if (ret != OS_FS_SUCCESS) return ret; - ret = path_isvalid(new_filename); - if (ret != OS_FS_SUCCESS) return ret; - // if new filename already exists - if (path_exists(new_filename) == OS_SUCCESS) return OS_FS_ERR_PATH_INVALID; - return file_rename((char *)old_filename, (char *)new_filename); + */ +int32 +OS_rename(const char *old_filename, const char *new_filename) +{ + if (!old_filename || !new_filename) return OS_FS_ERR_INVALID_POINTER; + int32 ret = path_exists(old_filename); + if (ret != OS_FS_SUCCESS) return ret; + ret = path_isvalid(new_filename); + if (ret != OS_FS_SUCCESS) return ret; + // if new filename already exists + if (path_exists(new_filename) == OS_SUCCESS) return OS_FS_ERR_PATH_INVALID; + return file_rename((char *)old_filename, (char *)new_filename); } /* * copies a single file from src to dest -*/ -int32 OS_cp(const char *src, const char *dest) + */ +int32 +OS_cp(const char *src, const char *dest) { - if (!src || !dest) return OS_FS_ERR_INVALID_POINTER; - char *src_path = (char *)src; - char *dest_path = (char *)dest; + if (!src || !dest) return OS_FS_ERR_INVALID_POINTER; + char *src_path = (char *)src; + char *dest_path = (char *)dest; - if (strlen(src_path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; - if (strlen(dest_path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; - if (strlen(path_to_name(src_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; - if (strlen(path_to_name(dest_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; + if (strlen(src_path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + if (strlen(dest_path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + if (strlen(path_to_name(src_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; + if (strlen(path_to_name(dest_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; - int32 ret = path_exists(src_path); - if (ret != OS_FS_SUCCESS) return ret; - ret = path_isvalid(dest_path); - if (ret != OS_FS_SUCCESS) return ret; + int32 ret = path_exists(src_path); + if (ret != OS_FS_SUCCESS) return ret; + ret = path_isvalid(dest_path); + if (ret != OS_FS_SUCCESS) return ret; - return file_cp(src_path, dest_path); + return file_cp(src_path, dest_path); } /* * moves a single file from src to dest -*/ -int32 OS_mv(const char *src, const char *dest) + */ +int32 +OS_mv(const char *src, const char *dest) { - char *src_path = (char *)src; - char *dest_path = (char *)dest; + char *src_path = (char *)src; + char *dest_path = (char *)dest; - if (!src_path || !dest_path) return OS_FS_ERR_INVALID_POINTER; - if (strlen(src_path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; - if (strlen(dest_path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; - if (strlen(path_to_name(src_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; - if (strlen(path_to_name(dest_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; + if (!src_path || !dest_path) return OS_FS_ERR_INVALID_POINTER; + if (strlen(src_path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + if (strlen(dest_path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + if (strlen(path_to_name(src_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; + if (strlen(path_to_name(dest_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; - int32 ret = path_exists(src); - if (ret != OS_FS_SUCCESS) return ret; - ret = path_isvalid(dest); - if (ret != OS_FS_SUCCESS) return ret; + int32 ret = path_exists(src); + if (ret != OS_FS_SUCCESS) return ret; + ret = path_isvalid(dest); + if (ret != OS_FS_SUCCESS) return ret; - return file_mv(src_path, dest_path); + return file_mv(src_path, dest_path); } /* * Copies the info of an open file to the structure -*/ -int32 OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) + */ +int32 +OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) { - if (!fd_prop) return OS_FS_ERR_INVALID_POINTER; - if (filedes <= 0 || filedes > MAX_NUM_FILES) return OS_FS_ERR_INVALID_FD; + if (!fd_prop) return OS_FS_ERR_INVALID_POINTER; + if (filedes <= 0 || filedes > MAX_NUM_FILES) return OS_FS_ERR_INVALID_FD; - return file_FDGetInfo(filedes, fd_prop); + return file_FDGetInfo(filedes, fd_prop); } /* ** Check to see if a file is open */ -int32 OS_FileOpenCheck(char *Filename) +int32 +OS_FileOpenCheck(char *Filename) { - int32 ret = path_exists(Filename); - if (ret != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_POINTER; - - struct fsobj *file = file_find(Filename); - if (!file) return OS_INVALID_POINTER; - if (file->refcnt == 0) return OS_FS_ERROR; - return OS_FS_SUCCESS; + int32 ret = path_exists(Filename); + if (ret != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_POINTER; + struct fsobj *file = file_find(Filename); + if (!file) return OS_INVALID_POINTER; + if (file->refcnt == 0) return OS_FS_ERROR; + return OS_FS_SUCCESS; } /* ** Close all open files */ -int32 OS_CloseAllFiles(void) +int32 +OS_CloseAllFiles(void) { - uint32 i; - for (i = 1 ; i <= MAX_NUM_FILES ; i++) { - OS_close(i); - } - return OS_FS_SUCCESS; + uint32 i; + for (i = 1; i <= MAX_NUM_FILES; i++) { OS_close(i); } + return OS_FS_SUCCESS; } /* ** Close a file by filename */ -int32 OS_CloseFileByName(char *Filename) +int32 +OS_CloseFileByName(char *Filename) { - int32 ret = path_exists(Filename); - if (ret != OS_FS_SUCCESS) return ret; - return file_close_by_name(Filename); + int32 ret = path_exists(Filename); + if (ret != OS_FS_SUCCESS) return ret; + return file_close_by_name(Filename); } /****************************************************************************** @@ -221,60 +234,66 @@ int32 OS_CloseFileByName(char *Filename) /* * Makes a new directory * access is not used by cFE -*/ -int32 OS_mkdir(const char *path, uint32 access) + */ +int32 +OS_mkdir(const char *path, uint32 access) { - int32 ret = path_isvalid(path); - if (ret != OS_FS_SUCCESS) return ret; - return file_mkdir((char *)path); + int32 ret = path_isvalid(path); + if (ret != OS_FS_SUCCESS) return ret; + return file_mkdir((char *)path); } /* * Opens a directory for searching -*/ -os_dirp_t OS_opendir(const char *path) + */ +os_dirp_t +OS_opendir(const char *path) { - if(path_exists(path) != OS_FS_SUCCESS) return NULL; - int32 FD = dir_open((char *)path); - if (FD == 0) return NULL; - return (os_dirp_t) FD; + if (path_exists(path) != OS_FS_SUCCESS) return NULL; + int32 FD = dir_open((char *)path); + if (FD == 0) return NULL; + return (os_dirp_t)FD; } /* * Closes an open directory -*/ -int32 OS_closedir(os_dirp_t directory) + */ +int32 +OS_closedir(os_dirp_t directory) { - if (!directory) return OS_FS_ERR_INVALID_POINTER; - return dir_close((int32) directory); + if (!directory) return OS_FS_ERR_INVALID_POINTER; + return dir_close((int32)directory); } /* * Rewinds an open directory -*/ -void OS_rewinddir(os_dirp_t directory) + */ +void +OS_rewinddir(os_dirp_t directory) { - dir_rewind((int32) directory); - return; + dir_rewind((int32)directory); + return; } /* * Reads the next object in the directory -*/ -os_dirent_t *OS_readdir(os_dirp_t directory) + */ +os_dirent_t * +OS_readdir(os_dirp_t directory) { - if (!directory) return NULL; - return dir_read((int32) directory); + if (!directory) return NULL; + return dir_read((int32)directory); } /* * Removes an empty directory from the file system. -*/ -int32 OS_rmdir(const char *path) + */ +int32 +OS_rmdir(const char *path) { - int32 ret = path_exists(path); - if (ret != OS_FS_SUCCESS) return ret; - return file_rmdir((char *)path); + int32 ret = path_exists(path); + if (ret != OS_FS_SUCCESS) return ret; + return file_rmdir((char *)path); } /****************************************************************************** @@ -282,23 +301,24 @@ int32 OS_rmdir(const char *path) ******************************************************************************/ /* * Makes a file system -*/ -int32 OS_mkfs(char *address, char *devname, char *volname, - uint32 blocksize, uint32 numblocks) + */ +int32 +OS_mkfs(char *address, char *devname, char *volname, uint32 blocksize, uint32 numblocks) { - if (address) return OS_FS_ERR_INVALID_POINTER; - if (!devname || !volname) return OS_FS_ERR_INVALID_POINTER; - if (strlen(devname) >= OS_FS_DEV_NAME_LEN || strlen(volname) >= OS_FS_VOL_NAME_LEN) - return OS_FS_ERR_PATH_TOO_LONG; - return fs_init(devname, volname, blocksize, numblocks); + if (address) return OS_FS_ERR_INVALID_POINTER; + if (!devname || !volname) return OS_FS_ERR_INVALID_POINTER; + if (strlen(devname) >= OS_FS_DEV_NAME_LEN || strlen(volname) >= OS_FS_VOL_NAME_LEN) + return OS_FS_ERR_PATH_TOO_LONG; + return fs_init(devname, volname, blocksize, numblocks); } /* * Mounts a file system -*/ -int32 OS_mount(const char *devname, char *mountpoint) + */ +int32 +OS_mount(const char *devname, char *mountpoint) { - if (!devname || !mountpoint) return OS_FS_ERR_INVALID_POINTER; - return fs_mount((char *)devname, mountpoint); + if (!devname || !mountpoint) return OS_FS_ERR_INVALID_POINTER; + return fs_mount((char *)devname, mountpoint); } /* @@ -306,82 +326,90 @@ int32 OS_mount(const char *devname, char *mountpoint) * address will be null if wants to initialize an empty fs, non-null to load an fs from memory * we could easily load a tar from memory but if an application wants to load a filesystem it * is safer to panic as we do not know what format the application is attempting to load -*/ -int32 OS_initfs(char *address, char *devname, char *volname, uint32 blocksize, uint32 numblocks) + */ +int32 +OS_initfs(char *address, char *devname, char *volname, uint32 blocksize, uint32 numblocks) { - if (address) PANIC("No support for loading a filesystem from arbitrary memory"); - return OS_FS_SUCCESS; + if (address) PANIC("No support for loading a filesystem from arbitrary memory"); + return OS_FS_SUCCESS; } /* * removes a file system -*/ -int32 OS_rmfs(char *devname) + */ +int32 +OS_rmfs(char *devname) { - if (!devname) return OS_FS_ERR_INVALID_POINTER; - return fs_remove(devname); + if (!devname) return OS_FS_ERR_INVALID_POINTER; + return fs_remove(devname); } /* * Unmounts a mounted file system -*/ -int32 OS_unmount(const char *mountpoint) + */ +int32 +OS_unmount(const char *mountpoint) { - if (!mountpoint) return OS_FS_ERR_INVALID_POINTER; - int32 ret = path_exists(mountpoint); - if (ret != OS_FS_SUCCESS) return ret; - return fs_unmount((char *)mountpoint); + if (!mountpoint) return OS_FS_ERR_INVALID_POINTER; + int32 ret = path_exists(mountpoint); + if (ret != OS_FS_SUCCESS) return ret; + return fs_unmount((char *)mountpoint); } /* * Returns the number of free blocks in a file system -*/ -int32 OS_fsBlocksFree(const char *name) + */ +int32 +OS_fsBlocksFree(const char *name) { - return OS_ERR_NOT_IMPLEMENTED; + return OS_ERR_NOT_IMPLEMENTED; } -int32 OS_fsBytesFree(const char *name, uint64 *bytes_free) +int32 +OS_fsBytesFree(const char *name, uint64 *bytes_free) { - return OS_ERR_NOT_IMPLEMENTED; + return OS_ERR_NOT_IMPLEMENTED; } /* - * * Checks the health of a file system and repairs it if neccesary -*/ -os_fshealth_t OS_chkfs(const char *name, boolean repair) + */ +os_fshealth_t +OS_chkfs(const char *name, boolean repair) { - return OS_ERR_NOT_IMPLEMENTED; + return OS_ERR_NOT_IMPLEMENTED; } /* * Returns in the parameter the physical drive underneith the mount point -*/ -int32 OS_FS_GetPhysDriveName(char * PhysDriveName, char * MountPoint) + */ +int32 +OS_FS_GetPhysDriveName(char *PhysDriveName, char *MountPoint) { - if (!PhysDriveName || !MountPoint) return OS_FS_ERR_INVALID_POINTER; - int32 ret = path_exists(MountPoint); - if (ret != OS_FS_SUCCESS) return ret; - return fs_get_drive_name(PhysDriveName, MountPoint); + if (!PhysDriveName || !MountPoint) return OS_FS_ERR_INVALID_POINTER; + int32 ret = path_exists(MountPoint); + if (ret != OS_FS_SUCCESS) return ret; + return fs_get_drive_name(PhysDriveName, MountPoint); } /* * This is currently not used by osal * Translates a OSAL Virtual file system path to a host Local path -*/ -int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) + */ +int32 +OS_TranslatePath(const char *VirtualPath, char *LocalPath) { - return path_translate((char *) VirtualPath, LocalPath); + return path_translate((char *)VirtualPath, LocalPath); } /* ** Returns information about the file system in an os_fsinfo_t */ -int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) +int32 +OS_GetFsInfo(os_fsinfo_t *filesys_info) { - if (!filesys_info) return OS_FS_ERR_INVALID_POINTER; - return fs_get_info(filesys_info); + if (!filesys_info) return OS_FS_ERR_INVALID_POINTER; + return fs_get_info(filesys_info); } /****************************************************************************** @@ -390,7 +418,8 @@ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info) /* executes the shell command passed into is and writes the output of that * command to the file specified by the given OSAPI file descriptor */ -int32 OS_ShellOutputToFile(char* Cmd, int32 OS_fd) +int32 +OS_ShellOutputToFile(char *Cmd, int32 OS_fd) { - return OS_ERR_NOT_IMPLEMENTED; + return OS_ERR_NOT_IMPLEMENTED; } diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.c b/src/components/implementation/no_interface/cFE_booter/osfilesys.c index 482c89dd29..91d6d14cf0 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.c +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.c @@ -1,10 +1,10 @@ #include "osfilesys.h" #include "tar.h" -struct fs filesystems[MAX_NUM_FS]; -struct fs *openfs = &filesystems[0]; +struct fs filesystems[MAX_NUM_FS]; +struct fs * openfs = &filesystems[0]; struct fsobj files[MAX_NUM_FILES]; -struct fd fd_tbl[OS_MAX_NUM_OPEN_FILES + 1]; +struct fd fd_tbl[OS_MAX_NUM_OPEN_FILES + 1]; /* * Notes on this version: @@ -27,602 +27,593 @@ struct fd fd_tbl[OS_MAX_NUM_OPEN_FILES + 1]; ******************************************************************************/ // checks if a file descriptor is valid and in use -int32 chk_fd(int32 FD) -{ - if (FD > OS_MAX_NUM_OPEN_FILES) return OS_FS_ERR_INVALID_FD; - if (FD <= 0) return OS_FS_ERR_INVALID_FD; - - struct fd *filedes = &fd_tbl[FD]; - if (!filedes->file) return OS_FS_ERR_INVALID_FD; - if (filedes->ino == 0 || filedes->file->ino == 0) return OS_FS_ERR_INVALID_FD; - assert(filedes->ino == filedes->file->ino); - return OS_FS_SUCCESS; -} - -//finds the next free file -uint32 file_get_new(struct fsobj **o) -{ - uint32 count = 0; - while (count < MAX_NUM_FILES && files[count].ino) { - count++; - } - if (count == MAX_NUM_FILES) return OS_FS_ERROR; - *o = &files[count]; - - **o = (struct fsobj) { - //ino needs to be unique and nonzero, so ino is defined as index+1 - .ino = count + 1 - }; - return OS_FS_SUCCESS; -} - -uint32 file_insert(struct fsobj *o, char *path) -{ - assert(o && path && openfs); - - //paths should always begin with '/' but we do not need it here - if (path[0] != '/') return OS_FS_ERR_PATH_INVALID; - path++; - - if (!openfs->root) { - if (strcmp(o->name, path) != 0) return OS_FS_ERR_PATH_INVALID; - openfs->root = o; - return OS_FS_SUCCESS; - } - assert(openfs->root->ino); - struct fsobj *cur = openfs->root; - - // token is the current directory in path - char path_temp[OS_MAX_PATH_LEN * 2]; - strcpy(path_temp, path); - const char delim[2] = "/"; - char *token = strtok(path_temp, delim); - - if (strcmp(token, cur->name) != 0) return OS_FS_ERR_PATH_INVALID; - - //loop terminates when it finds a place to put o or determines path is invalid - while (1) { - if (token == NULL) { - return OS_FS_ERR_PATH_INVALID; - } - assert(cur->name); - - //if there is no child, then insert as child - if (!cur->child) { - // if the next part of the path is not o->name or there is a part after it, bad path - token = strtok(NULL, delim); - if (strcmp(token, o->name) != 0 || strtok(NULL, delim) != NULL) { - return OS_FS_ERR_PATH_INVALID; - } - - o->parent = cur; - cur->child = o; - o->next = NULL; - o->prev = NULL; - return OS_FS_SUCCESS; - } - cur = cur->child; - token = strtok(NULL, delim); - - //precondition: cur is the first in a non-empty list of children - //postcondition: cur is an ancestor of o or o has been inserted in list - // while cur is not ancestor of o - while (strcmp(token, cur->name) != 0) { - if (cur->next == NULL) { - // if the next part of the path is o->name or there is a part after it, bad path - if (strcmp(token, o->name) != 0 || strtok(NULL, delim) != NULL) { - return OS_FS_ERR_PATH_INVALID; - } - // insert o as the last child in a linked list of children - cur->next = o; - o->prev = cur; - o->parent = cur->parent; - o->next = NULL; - return OS_FS_SUCCESS; - } - cur = cur->next; - } - } - PANIC("Unreachable Statement"); - return 0; +int32 +chk_fd(int32 FD) +{ + if (FD > OS_MAX_NUM_OPEN_FILES) return OS_FS_ERR_INVALID_FD; + if (FD <= 0) return OS_FS_ERR_INVALID_FD; + + struct fd *filedes = &fd_tbl[FD]; + if (!filedes->file) return OS_FS_ERR_INVALID_FD; + if (filedes->ino == 0 || filedes->file->ino == 0) return OS_FS_ERR_INVALID_FD; + assert(filedes->ino == filedes->file->ino); + return OS_FS_SUCCESS; +} + +// finds the next free file +uint32 +file_get_new(struct fsobj **o) +{ + uint32 count = 0; + while (count < MAX_NUM_FILES && files[count].ino) { count++; } + if (count == MAX_NUM_FILES) return OS_FS_ERROR; + *o = &files[count]; + + **o = (struct fsobj){// ino needs to be unique and nonzero, so ino is defined as index+1 + .ino = count + 1}; + return OS_FS_SUCCESS; +} + +uint32 +file_insert(struct fsobj *o, char *path) +{ + assert(o && path && openfs); + + // paths should always begin with '/' but we do not need it here + if (path[0] != '/') return OS_FS_ERR_PATH_INVALID; + path++; + + if (!openfs->root) { + if (strcmp(o->name, path) != 0) return OS_FS_ERR_PATH_INVALID; + openfs->root = o; + return OS_FS_SUCCESS; + } + assert(openfs->root->ino); + struct fsobj *cur = openfs->root; + + // token is the current directory in path + char path_temp[OS_MAX_PATH_LEN * 2]; + strcpy(path_temp, path); + const char delim[2] = "/"; + char * token = strtok(path_temp, delim); + + if (strcmp(token, cur->name) != 0) return OS_FS_ERR_PATH_INVALID; + + // loop terminates when it finds a place to put o or determines path is invalid + while (1) { + if (token == NULL) { return OS_FS_ERR_PATH_INVALID; } + assert(cur->name); + + // if there is no child, then insert as child + if (!cur->child) { + // if the next part of the path is not o->name or there is a part after it, bad path + token = strtok(NULL, delim); + if (strcmp(token, o->name) != 0 || strtok(NULL, delim) != NULL) { + return OS_FS_ERR_PATH_INVALID; + } + + o->parent = cur; + cur->child = o; + o->next = NULL; + o->prev = NULL; + return OS_FS_SUCCESS; + } + cur = cur->child; + token = strtok(NULL, delim); + + // precondition: cur is the first in a non-empty list of children + // postcondition: cur is an ancestor of o or o has been inserted in list + // while cur is not ancestor of o + while (strcmp(token, cur->name) != 0) { + if (cur->next == NULL) { + // if the next part of the path is o->name or there is a part after it, bad path + if (strcmp(token, o->name) != 0 || strtok(NULL, delim) != NULL) { + return OS_FS_ERR_PATH_INVALID; + } + // insert o as the last child in a linked list of children + cur->next = o; + o->prev = cur; + o->parent = cur->parent; + o->next = NULL; + return OS_FS_SUCCESS; + } + cur = cur->next; + } + } + PANIC("Unreachable Statement"); + return 0; } // Internally, FDs are considered unused when ino == 0 -static int32 fd_get(int32 ino) +static int32 +fd_get(int32 ino) { - uint32 count = 1; - struct fd *filedes; + uint32 count = 1; + struct fd *filedes; - while (count <= OS_MAX_NUM_OPEN_FILES + 1 && fd_tbl[count].ino != 0) { - count++; - } - if (count == OS_MAX_NUM_OPEN_FILES + 1) return OS_FS_ERROR; + while (count <= OS_MAX_NUM_OPEN_FILES + 1 && fd_tbl[count].ino != 0) { count++; } + if (count == OS_MAX_NUM_OPEN_FILES + 1) return OS_FS_ERROR; - filedes = &fd_tbl[count]; - filedes->ino = ino; - filedes->access = NONE; - return count; + filedes = &fd_tbl[count]; + filedes->ino = ino; + filedes->access = NONE; + return count; } -int32 file_open(char *path, enum fs_permissions permission) +int32 +file_open(char *path, enum fs_permissions permission) { - assert(openfs); - if (!openfs->root) return OS_FS_ERROR; - if (!path) return OS_FS_ERR_INVALID_POINTER; + assert(openfs); + if (!openfs->root) return OS_FS_ERROR; + if (!path) return OS_FS_ERR_INVALID_POINTER; - // find the file - struct fsobj *file = file_find(path); - if (!file) return OS_FS_ERR_PATH_INVALID; - if (file->type != FSOBJ_FILE) return OS_FS_ERROR; + // find the file + struct fsobj *file = file_find(path); + if (!file) return OS_FS_ERR_PATH_INVALID; + if (file->type != FSOBJ_FILE) return OS_FS_ERROR; - // get a new fd - int32 FD = fd_get(file->ino); - if (FD == OS_FS_ERROR) { - return OS_FS_ERR_NO_FREE_FDS; - } + // get a new fd + int32 FD = fd_get(file->ino); + if (FD == OS_FS_ERROR) { return OS_FS_ERR_NO_FREE_FDS; } - struct fd *filedes = &fd_tbl[FD]; + struct fd *filedes = &fd_tbl[FD]; - filedes->access = permission; - filedes->file = file; - filedes->position.file_pos.open_part = file->file_part; - filedes->position.file_pos.file_offset = 0; - filedes->position.file_pos.part_offset = 0; - file->refcnt++; - return FD; + filedes->access = permission; + filedes->file = file; + filedes->position.file_pos.open_part = file->file_part; + filedes->position.file_pos.file_offset = 0; + filedes->position.file_pos.part_offset = 0; + file->refcnt++; + return FD; } -int32 file_close(int32 FD) +int32 +file_close(int32 FD) { - int32 ret = chk_fd(FD); - if (ret != OS_FS_SUCCESS) return OS_FS_ERROR; + int32 ret = chk_fd(FD); + if (ret != OS_FS_SUCCESS) return OS_FS_ERROR; - struct fd *filedes = &fd_tbl[FD]; - if (filedes->ino == 0) return OS_FS_ERROR; + struct fd *filedes = &fd_tbl[FD]; + if (filedes->ino == 0) return OS_FS_ERROR; - uint32 index = filedes->ino - 1; - assert(files[index].refcnt > 0); - files[index].refcnt--; - filedes->ino = 0; - return OS_FS_SUCCESS; + uint32 index = filedes->ino - 1; + assert(files[index].refcnt > 0); + files[index].refcnt--; + filedes->ino = 0; + return OS_FS_SUCCESS; } -int32 file_close_by_name(char *path) +int32 +file_close_by_name(char *path) { - struct fsobj *file = file_find(path); - int i; + struct fsobj *file = file_find(path); + int i; - for (i = 0 ; i < OS_MAX_NUM_OPEN_FILES + 1 ; i++) { - if (fd_tbl[i].file == file){ - assert(fd_tbl[i].ino = file->ino); - file_close(i); - return OS_FS_SUCCESS; - } - } - return OS_FS_ERROR; + for (i = 0; i < OS_MAX_NUM_OPEN_FILES + 1; i++) { + if (fd_tbl[i].file == file) { + assert(fd_tbl[i].ino = file->ino); + file_close(i); + return OS_FS_SUCCESS; + } + } + return OS_FS_ERROR; } // converts from the cFE defined permission constants to internal permission type // unknown permissions return NONE, cFE should treat none as an error -enum fs_permissions permission_cFE_to_cos(uint32 permission) { - switch (permission) { - case OS_READ_WRITE : - return READ & WRITE; - case OS_WRITE_ONLY : - return WRITE; - case OS_READ_ONLY : - return READ; - default : - PANIC("Invalid permission from cFE"); - } - PANIC("unreachable statement"); - return 0; -} - -uint32 permission_cos_to_cFE(enum fs_permissions permission) { - switch (permission) { - case READ & WRITE : - return OS_READ_WRITE; - case WRITE : - return OS_WRITE_ONLY; - case READ : - return OS_READ_ONLY; - default : - PANIC("Invalid permission in existing file"); - } - PANIC("unreachable statement"); - return 0; +enum fs_permissions +permission_cFE_to_cos(uint32 permission) +{ + switch (permission) { + case OS_READ_WRITE: + return READ & WRITE; + case OS_WRITE_ONLY: + return WRITE; + case OS_READ_ONLY: + return READ; + default: + PANIC("Invalid permission from cFE"); + } + PANIC("unreachable statement"); + return 0; +} + +uint32 +permission_cos_to_cFE(enum fs_permissions permission) +{ + switch (permission) { + case READ &WRITE: + return OS_READ_WRITE; + case WRITE: + return OS_WRITE_ONLY; + case READ: + return OS_READ_ONLY; + default: + PANIC("Invalid permission in existing file"); + } + PANIC("unreachable statement"); + return 0; } // checks if a path is the right format for a path, and if it exists -int32 path_exists(const char *path) +int32 +path_exists(const char *path) { - int32 ret = path_isvalid(path); - if (ret != OS_FS_SUCCESS) return ret; - if (file_find((char *)path) == NULL) return OS_FS_ERROR; - return OS_FS_SUCCESS; + int32 ret = path_isvalid(path); + if (ret != OS_FS_SUCCESS) return ret; + if (file_find((char *)path) == NULL) return OS_FS_ERROR; + return OS_FS_SUCCESS; } // checks if a path is the correct format, for example to be inserted -int32 path_isvalid(const char *path) +int32 +path_isvalid(const char *path) { - if (path == NULL) return OS_FS_ERR_INVALID_POINTER; - if (strlen(path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; - if (strlen(path_to_name((char *)path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; - if (path[0] != '/') return OS_FS_ERR_PATH_INVALID; - assert(openfs); + if (path == NULL) return OS_FS_ERR_INVALID_POINTER; + if (strlen(path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; + if (strlen(path_to_name((char *)path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; + if (path[0] != '/') return OS_FS_ERR_PATH_INVALID; + assert(openfs); - if (openfs->root) { - assert(openfs->root->name); - if (memcmp(openfs->root->name, path + 1, strlen(openfs->root->name))) { - return OS_FS_ERR_PATH_INVALID; - } - } - return OS_FS_SUCCESS; + if (openfs->root) { + assert(openfs->root->name); + if (memcmp(openfs->root->name, path + 1, strlen(openfs->root->name))) { return OS_FS_ERR_PATH_INVALID; } + } + return OS_FS_SUCCESS; } -int32 path_translate(char *virt, char *local) +int32 +path_translate(char *virt, char *local) { - if (!virt || !local) return OS_FS_ERR_INVALID_POINTER; - int32 ret = path_isvalid(virt); - if (ret != OS_FS_SUCCESS) return ret; - if (!openfs->root) return OS_FS_ERR_PATH_INVALID; - ret = path_exists(virt); - if (ret != OS_FS_SUCCESS) return ret; - strcpy(local, virt); - return OS_FS_SUCCESS; + if (!virt || !local) return OS_FS_ERR_INVALID_POINTER; + int32 ret = path_isvalid(virt); + if (ret != OS_FS_SUCCESS) return ret; + if (!openfs->root) return OS_FS_ERR_PATH_INVALID; + ret = path_exists(virt); + if (ret != OS_FS_SUCCESS) return ret; + strcpy(local, virt); + return OS_FS_SUCCESS; } /****************************************************************************** ** f_part Level Methods ******************************************************************************/ -uint32 part_get_new(struct f_part **part) -{ - struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); - struct cos_compinfo *ci = &defci->ci; - - *part = (void*)memmgr_heap_page_alloc(); - - assert(part != NULL); - (*part)->next = NULL; - (*part)->prev = NULL; - (*part)->file = NULL; - (*part)->data = (char *) *part + sizeof(struct f_part); - return OS_FS_SUCCESS; -} - -int32 file_read(int32 FD, void *buffer, uint32 nbytes) -{ - if (!buffer) return OS_FS_ERR_INVALID_POINTER; - int32 ret = chk_fd(FD); - if (ret != OS_FS_SUCCESS) return ret; - - struct fd *filedes = &fd_tbl[FD]; - - struct fsobj *o = filedes->file; - assert(o->refcnt >= 1); - if (o->type != FSOBJ_FILE) return OS_FS_ERR_INVALID_FD; - struct file_position *position = &filedes->position.file_pos; - struct f_part *part = position->open_part; - - // nbytes > number of bytes left in file, only number left are read - if (nbytes > o->size - position->file_offset) { - nbytes = o->size - position->file_offset; - } - - if (nbytes == OS_FS_SUCCESS) return 0; - uint32 bytes_to_read = nbytes; - - if (o->memtype == DYNAMIC){ - while (1) { - //read_size is the length of a continuous segment to be read from - uint32 read_size = F_PART_DATA_SIZE - position->file_offset; - part = position->open_part; - assert(part); - - if (bytes_to_read > read_size) { - memcpy(buffer, &part->data[position->part_offset], read_size); - - buffer += read_size; - bytes_to_read -= read_size; - position->file_offset += read_size; - - if (!part->next) { - position->part_offset = F_PART_DATA_SIZE; - return nbytes - bytes_to_read; - } - position->open_part = part->next; - position->part_offset = 0; - - } else if (bytes_to_read == read_size) { - memcpy(buffer, &part->data[position->part_offset], read_size); - position->file_offset += read_size; - if (!part->next) { - position->part_offset = F_PART_DATA_SIZE; - return nbytes; - } - position->open_part = part->next; - position->part_offset = 0; - return nbytes; - - // bytes_to_read < the continuous space left on f_part - } else { - memcpy(buffer, position->open_part->data + position->part_offset, bytes_to_read); - position->part_offset += bytes_to_read; - position->file_offset += bytes_to_read; - return nbytes; - } - } - } else if (o->memtype == STATIC) { - memcpy(buffer, &part->data[position->file_offset], bytes_to_read); - position->part_offset += bytes_to_read; - position->file_offset += bytes_to_read; - return nbytes; - } else { - PANIC("Memtype is neither static nor dynamic"); - } - - PANIC("Unreachable Statement"); - return 0; -} - -int32 file_write(int32 FD, void *buffer, uint32 nbytes) -{ - if (!buffer) return OS_FS_ERR_INVALID_POINTER; - int32 ret = chk_fd(FD); - if (ret != OS_FS_SUCCESS) return ret; - - struct fd *filedes = &fd_tbl[FD]; - struct fsobj *o = filedes->file; - struct file_position *position = &filedes->position.file_pos; - - if (o->refcnt < 1) return OS_FS_ERROR; - if (o->memtype == STATIC) return OS_FS_ERROR; - if (o->type == FSOBJ_DIR) return OS_FS_ERROR; - if (nbytes == 0) return 0; - - uint32 bytes_to_write = nbytes; - uint32 bytes_remaining = F_PART_DATA_SIZE - position->part_offset; - - //while there are enough bytes to be written to fill a f_part - while (bytes_to_write > bytes_remaining) { - memcpy(position->open_part->data + position->part_offset, buffer, bytes_remaining); - position->file_offset += bytes_remaining; - buffer += bytes_remaining; - bytes_to_write -= bytes_remaining; - position->part_offset = 0; - if (position->open_part->next == NULL) { - struct f_part *part; - part_get_new(&part); - part->file = o; - part->next = NULL; - part->prev = position->open_part; - position->open_part->next = part; - } - - position->open_part = position->open_part->next; - bytes_remaining = F_PART_DATA_SIZE - position->part_offset; - } - //bytes_to_write < bytes_remaining - memcpy(position->open_part->data, buffer, bytes_to_write); - position->part_offset += bytes_to_write; - position->file_offset += bytes_to_write; - if (o->size < position->file_offset) { - o->size = position->file_offset; - } - return nbytes; -} - -struct fsobj *file_find(char *path) -{ - assert(path); - //paths should always begin with '/' dir names do not - if (path[0] != '/') return NULL; - path++; - - // token is the current directory in path - char path_temp[OS_MAX_PATH_LEN * 2]; - strcpy(path_temp, path); - const char delim[2] = "/"; - char *token = strtok(path_temp, delim); - - if(!openfs || !openfs->root) return NULL; - struct fsobj *cur = openfs->root; - assert(cur && cur->name); - if (strcmp(token, cur->name) != 0) return NULL; - - while (1) { - // iterate through linked list of children until ancestor is found - while (strcmp(token, cur->name) != 0) { - if (!cur->next) return NULL; - cur = cur->next; - } - token = strtok(NULL, delim); - if (token == NULL) return cur; - if (!cur->child) return NULL; - cur = cur->child; - } - PANIC("Unreachable Statement"); - return NULL; -} - -int32 file_create(char *path, enum fs_permissions permission) -{ - assert(path); - - struct fsobj *o; - if (file_get_new(&o) != OS_FS_SUCCESS) return OS_FS_ERROR; - o->name = path_to_name(path); - o->type = FSOBJ_FILE; - o->size = 0; - o->permission = permission; - o->memtype = DYNAMIC; - - struct f_part *part; - part_get_new(&part); - - o->file_part = part; - part->file = o; - part->data = (char *) part + sizeof(struct f_part); - if (file_insert(o, path) != OS_FS_SUCCESS){ - o->ino = 0; - return OS_FS_ERR_PATH_INVALID; - } - return file_open(path, permission); -} - -int32 file_remove(char *path) -{ - struct fsobj *file = file_find(path); - if (!file) return OS_FS_ERR_PATH_INVALID; - file_rm(file); - return OS_FS_SUCCESS; -} - -int32 file_rename(char *old_filename, char *new_filename) -{ - struct fsobj *file = file_find(old_filename); - if (!file) return OS_FS_ERR_PATH_INVALID; - file->name = path_to_name(new_filename); - return OS_FS_SUCCESS; +uint32 +part_get_new(struct f_part **part) +{ + struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); + struct cos_compinfo * ci = &defci->ci; + + *part = (void *)memmgr_heap_page_alloc(); + + assert(part != NULL); + (*part)->next = NULL; + (*part)->prev = NULL; + (*part)->file = NULL; + (*part)->data = (char *)*part + sizeof(struct f_part); + return OS_FS_SUCCESS; +} + +int32 +file_read(int32 FD, void *buffer, uint32 nbytes) +{ + if (!buffer) return OS_FS_ERR_INVALID_POINTER; + int32 ret = chk_fd(FD); + if (ret != OS_FS_SUCCESS) return ret; + + struct fd *filedes = &fd_tbl[FD]; + + struct fsobj *o = filedes->file; + assert(o->refcnt >= 1); + if (o->type != FSOBJ_FILE) return OS_FS_ERR_INVALID_FD; + struct file_position *position = &filedes->position.file_pos; + struct f_part * part = position->open_part; + + // nbytes > number of bytes left in file, only number left are read + if (nbytes > o->size - position->file_offset) { nbytes = o->size - position->file_offset; } + + if (nbytes == OS_FS_SUCCESS) return 0; + uint32 bytes_to_read = nbytes; + + if (o->memtype == DYNAMIC) { + while (1) { + // read_size is the length of a continuous segment to be read from + uint32 read_size = F_PART_DATA_SIZE - position->file_offset; + part = position->open_part; + assert(part); + + if (bytes_to_read > read_size) { + memcpy(buffer, &part->data[position->part_offset], read_size); + + buffer += read_size; + bytes_to_read -= read_size; + position->file_offset += read_size; + + if (!part->next) { + position->part_offset = F_PART_DATA_SIZE; + return nbytes - bytes_to_read; + } + position->open_part = part->next; + position->part_offset = 0; + + } else if (bytes_to_read == read_size) { + memcpy(buffer, &part->data[position->part_offset], read_size); + position->file_offset += read_size; + if (!part->next) { + position->part_offset = F_PART_DATA_SIZE; + return nbytes; + } + position->open_part = part->next; + position->part_offset = 0; + return nbytes; + + // bytes_to_read < the continuous space left on f_part + } else { + memcpy(buffer, position->open_part->data + position->part_offset, bytes_to_read); + position->part_offset += bytes_to_read; + position->file_offset += bytes_to_read; + return nbytes; + } + } + } else if (o->memtype == STATIC) { + memcpy(buffer, &part->data[position->file_offset], bytes_to_read); + position->part_offset += bytes_to_read; + position->file_offset += bytes_to_read; + return nbytes; + } else { + PANIC("Memtype is neither static nor dynamic"); + } + + PANIC("Unreachable Statement"); + return 0; +} + +int32 +file_write(int32 FD, void *buffer, uint32 nbytes) +{ + if (!buffer) return OS_FS_ERR_INVALID_POINTER; + int32 ret = chk_fd(FD); + if (ret != OS_FS_SUCCESS) return ret; + + struct fd * filedes = &fd_tbl[FD]; + struct fsobj * o = filedes->file; + struct file_position *position = &filedes->position.file_pos; + + if (o->refcnt < 1) return OS_FS_ERROR; + if (o->memtype == STATIC) return OS_FS_ERROR; + if (o->type == FSOBJ_DIR) return OS_FS_ERROR; + if (nbytes == 0) return 0; + + uint32 bytes_to_write = nbytes; + uint32 bytes_remaining = F_PART_DATA_SIZE - position->part_offset; + + // while there are enough bytes to be written to fill a f_part + while (bytes_to_write > bytes_remaining) { + memcpy(position->open_part->data + position->part_offset, buffer, bytes_remaining); + position->file_offset += bytes_remaining; + buffer += bytes_remaining; + bytes_to_write -= bytes_remaining; + position->part_offset = 0; + if (position->open_part->next == NULL) { + struct f_part *part; + part_get_new(&part); + part->file = o; + part->next = NULL; + part->prev = position->open_part; + position->open_part->next = part; + } + + position->open_part = position->open_part->next; + bytes_remaining = F_PART_DATA_SIZE - position->part_offset; + } + // bytes_to_write < bytes_remaining + memcpy(position->open_part->data, buffer, bytes_to_write); + position->part_offset += bytes_to_write; + position->file_offset += bytes_to_write; + if (o->size < position->file_offset) { o->size = position->file_offset; } + return nbytes; +} + +struct fsobj * +file_find(char *path) +{ + assert(path); + // paths should always begin with '/' dir names do not + if (path[0] != '/') return NULL; + path++; + + // token is the current directory in path + char path_temp[OS_MAX_PATH_LEN * 2]; + strcpy(path_temp, path); + const char delim[2] = "/"; + char * token = strtok(path_temp, delim); + + if (!openfs || !openfs->root) return NULL; + struct fsobj *cur = openfs->root; + assert(cur && cur->name); + if (strcmp(token, cur->name) != 0) return NULL; + + while (1) { + // iterate through linked list of children until ancestor is found + while (strcmp(token, cur->name) != 0) { + if (!cur->next) return NULL; + cur = cur->next; + } + token = strtok(NULL, delim); + if (token == NULL) return cur; + if (!cur->child) return NULL; + cur = cur->child; + } + PANIC("Unreachable Statement"); + return NULL; +} + +int32 +file_create(char *path, enum fs_permissions permission) +{ + assert(path); + + struct fsobj *o; + if (file_get_new(&o) != OS_FS_SUCCESS) return OS_FS_ERROR; + o->name = path_to_name(path); + o->type = FSOBJ_FILE; + o->size = 0; + o->permission = permission; + o->memtype = DYNAMIC; + + struct f_part *part; + part_get_new(&part); + + o->file_part = part; + part->file = o; + part->data = (char *)part + sizeof(struct f_part); + if (file_insert(o, path) != OS_FS_SUCCESS) { + o->ino = 0; + return OS_FS_ERR_PATH_INVALID; + } + return file_open(path, permission); +} + +int32 +file_remove(char *path) +{ + struct fsobj *file = file_find(path); + if (!file) return OS_FS_ERR_PATH_INVALID; + file_rm(file); + return OS_FS_SUCCESS; +} + +int32 +file_rename(char *old_filename, char *new_filename) +{ + struct fsobj *file = file_find(old_filename); + if (!file) return OS_FS_ERR_PATH_INVALID; + file->name = path_to_name(new_filename); + return OS_FS_SUCCESS; } // This is part of but not a full posix implementation, // stat has a lot of fields not applicable to us -int32 file_stat(char *path, os_fstat_t *filestats) -{ - struct fsobj *file = file_find(path); - if (!file) return OS_FS_ERROR; - *filestats = (os_fstat_t) { - .st_dev = 0, - .st_ino = file->ino, - .st_size = file->size, - .st_blksize = F_PART_DATA_SIZE - }; - - if (file->type == FSOBJ_FILE) { - filestats->st_mode = S_IFREG; - } - if (file->type == FSOBJ_DIR) { - filestats->st_mode = S_IFDIR; - } - - return OS_FS_SUCCESS; -} - -int32 file_lseek(int32 FD, int32 offset, uint32 whence) -{ - int32 ret = chk_fd(FD); - if (ret != OS_FS_SUCCESS) return ret; - - struct fd *filedes = &fd_tbl[FD]; - struct fsobj *o = filedes->file; - struct file_position *position = &filedes->position.file_pos; - - uint32 target_offset = 0; - - // wasnt sure if it should be legal to pass negative offset, went with yes - if (whence == SEEK_SET) { - if (offset < 0) return OS_FS_ERROR; - target_offset = offset; - } else if (whence == SEEK_CUR) { - if (offset + (int32) position->file_offset < 0) return OS_FS_ERROR; - target_offset = offset + position->file_offset; - } else if (whence == SEEK_END) { - if (offset + (int32) position->file_offset < 0) return OS_FS_ERROR; - target_offset = offset + o->size; - } else { - return OS_FS_ERROR; - } - // you cannot write past the end of a static file - if ( target_offset > o->size && o->memtype == STATIC) { - return OS_FS_ERROR; - } - - position->open_part = o->file_part; - position->file_offset = 0; - - while ( target_offset - position->file_offset > F_PART_DATA_SIZE) { - // seeking past the end of a file writes zeros until that position - if (position->open_part->next == NULL) { - struct f_part *part; - part_get_new(&part); - part->file = o; - part->next = NULL; - part->prev = position->open_part; - position->open_part->next = part; - } - position->open_part = position->open_part->next; - position->file_offset += F_PART_DATA_SIZE; - } - position->file_offset += target_offset % F_PART_DATA_SIZE; - position->part_offset = target_offset % F_PART_DATA_SIZE; - - if (position->file_offset > o->size) { - o->size = position->file_offset; - } - return target_offset; -} - -int32 file_cp(char *src, char *dest) -{ - static char copy_buffer[F_PART_DATA_SIZE]; - - int32 fd_src = file_open(src, READ); - if (chk_fd(fd_src) != OS_FS_SUCCESS) return fd_src; - - // if the dest already exists, overwrite it - int32 fd_dest = file_open(dest, WRITE); - if (chk_fd(fd_dest) == OS_FS_SUCCESS) { - //writing size to zero effectivly deletes all the old data - fd_tbl[fd_dest].file->size = 0; - } else { - fd_dest = file_create(dest, fd_tbl[fd_src].file->permission); - } - if (chk_fd(fd_dest) != OS_FS_SUCCESS) return fd_dest; - - int32 to_copy = fd_tbl[fd_src].file->size; - int32 read_size = 0, write_size = 0; - - // TODO: copy buffer is aggressively not thread safe, take a lock - while(to_copy > 0) { - if (to_copy > (int32) F_PART_DATA_SIZE) { - read_size = F_PART_DATA_SIZE; - } else { - read_size = to_copy; - } - read_size = file_read(fd_src, copy_buffer, read_size); - write_size = file_write(fd_dest, copy_buffer, read_size); - if (read_size == 0 || write_size != read_size) return OS_FS_ERROR; - to_copy -= write_size; - } - - file_close(fd_src); - file_close(fd_dest); - - return OS_FS_SUCCESS; -} - -int32 file_mv(char *src, char *dest) -{ - struct fsobj *file = file_find(src); - - if (!file) return OS_FS_ERROR; - - if (file->next) { - file->next->prev = file->prev; - } - if (file->prev) { - file->prev->next = file->next; - } - if (file->parent->child == file) { - file->parent->child = file->next; - } - - file->name = path_to_name(dest); - if (file_insert(file, dest) != OS_FS_SUCCESS) return OS_FS_ERROR; - return OS_FS_SUCCESS; +int32 +file_stat(char *path, os_fstat_t *filestats) +{ + struct fsobj *file = file_find(path); + if (!file) return OS_FS_ERROR; + *filestats = + (os_fstat_t){.st_dev = 0, .st_ino = file->ino, .st_size = file->size, .st_blksize = F_PART_DATA_SIZE}; + + if (file->type == FSOBJ_FILE) { filestats->st_mode = S_IFREG; } + if (file->type == FSOBJ_DIR) { filestats->st_mode = S_IFDIR; } + + return OS_FS_SUCCESS; +} + +int32 +file_lseek(int32 FD, int32 offset, uint32 whence) +{ + int32 ret = chk_fd(FD); + if (ret != OS_FS_SUCCESS) return ret; + + struct fd * filedes = &fd_tbl[FD]; + struct fsobj * o = filedes->file; + struct file_position *position = &filedes->position.file_pos; + + uint32 target_offset = 0; + + // wasnt sure if it should be legal to pass negative offset, went with yes + if (whence == SEEK_SET) { + if (offset < 0) return OS_FS_ERROR; + target_offset = offset; + } else if (whence == SEEK_CUR) { + if (offset + (int32)position->file_offset < 0) return OS_FS_ERROR; + target_offset = offset + position->file_offset; + } else if (whence == SEEK_END) { + if (offset + (int32)position->file_offset < 0) return OS_FS_ERROR; + target_offset = offset + o->size; + } else { + return OS_FS_ERROR; + } + // you cannot write past the end of a static file + if (target_offset > o->size && o->memtype == STATIC) { return OS_FS_ERROR; } + + position->open_part = o->file_part; + position->file_offset = 0; + + while (target_offset - position->file_offset > F_PART_DATA_SIZE) { + // seeking past the end of a file writes zeros until that position + if (position->open_part->next == NULL) { + struct f_part *part; + part_get_new(&part); + part->file = o; + part->next = NULL; + part->prev = position->open_part; + position->open_part->next = part; + } + position->open_part = position->open_part->next; + position->file_offset += F_PART_DATA_SIZE; + } + position->file_offset += target_offset % F_PART_DATA_SIZE; + position->part_offset = target_offset % F_PART_DATA_SIZE; + + if (position->file_offset > o->size) { o->size = position->file_offset; } + return target_offset; +} + +int32 +file_cp(char *src, char *dest) +{ + static char copy_buffer[F_PART_DATA_SIZE]; + + int32 fd_src = file_open(src, READ); + if (chk_fd(fd_src) != OS_FS_SUCCESS) return fd_src; + + // if the dest already exists, overwrite it + int32 fd_dest = file_open(dest, WRITE); + if (chk_fd(fd_dest) == OS_FS_SUCCESS) { + // writing size to zero effectivly deletes all the old data + fd_tbl[fd_dest].file->size = 0; + } else { + fd_dest = file_create(dest, fd_tbl[fd_src].file->permission); + } + if (chk_fd(fd_dest) != OS_FS_SUCCESS) return fd_dest; + + int32 to_copy = fd_tbl[fd_src].file->size; + int32 read_size = 0, write_size = 0; + + // TODO: copy buffer is aggressively not thread safe, take a lock + while (to_copy > 0) { + if (to_copy > (int32)F_PART_DATA_SIZE) { + read_size = F_PART_DATA_SIZE; + } else { + read_size = to_copy; + } + read_size = file_read(fd_src, copy_buffer, read_size); + write_size = file_write(fd_dest, copy_buffer, read_size); + if (read_size == 0 || write_size != read_size) return OS_FS_ERROR; + to_copy -= write_size; + } + + file_close(fd_src); + file_close(fd_dest); + + return OS_FS_SUCCESS; +} + +int32 +file_mv(char *src, char *dest) +{ + struct fsobj *file = file_find(src); + + if (!file) return OS_FS_ERROR; + + if (file->next) { file->next->prev = file->prev; } + if (file->prev) { file->prev->next = file->next; } + if (file->parent->child == file) { file->parent->child = file->next; } + + file->name = path_to_name(dest); + if (file_insert(file, dest) != OS_FS_SUCCESS) return OS_FS_ERROR; + return OS_FS_SUCCESS; } /* @@ -630,19 +621,20 @@ int32 file_mv(char *src, char *dest) * perhaps it would be a good idea to track path in fsobj * but it looks like cFE uses this only to check is fd is valid */ -int32 file_FDGetInfo(int32 FD, OS_FDTableEntry *fd_prop) +int32 +file_FDGetInfo(int32 FD, OS_FDTableEntry *fd_prop) { - int32 ret = chk_fd(FD); - if (ret != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_FD; + int32 ret = chk_fd(FD); + if (ret != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_FD; - struct fd *filedes = &fd_tbl[FD]; - if (filedes->ino == 0) return OS_FS_ERR_INVALID_FD; + struct fd *filedes = &fd_tbl[FD]; + if (filedes->ino == 0) return OS_FS_ERR_INVALID_FD; - fd_prop->OSfd = FD; - memcpy(&fd_prop->Path, filedes->file->name, strlen(filedes->file->name)); - fd_prop->User = 0; - fd_prop->IsValid = 1; - return OS_FS_SUCCESS; + fd_prop->OSfd = FD; + memcpy(&fd_prop->Path, filedes->file->name, strlen(filedes->file->name)); + fd_prop->User = 0; + fd_prop->IsValid = 1; + return OS_FS_SUCCESS; } @@ -650,298 +642,300 @@ int32 file_FDGetInfo(int32 FD, OS_FDTableEntry *fd_prop) ** Dirent Level Methods ******************************************************************************/ -int32 dir_open(char *path) +int32 +dir_open(char *path) { - struct fsobj *file; - file = file_find(path); - if (!file) return 0; - if (file->ino == 0) return 0; - if (file->type != FSOBJ_DIR) return 0; + struct fsobj *file; + file = file_find(path); + if (!file) return 0; + if (file->ino == 0) return 0; + if (file->type != FSOBJ_DIR) return 0; - int32 FD = fd_get(file->ino); - if (FD > OS_MAX_NUM_OPEN_FILES + 1 || FD <= 0) return 0; - file->refcnt++; + int32 FD = fd_get(file->ino); + if (FD > OS_MAX_NUM_OPEN_FILES + 1 || FD <= 0) return 0; + file->refcnt++; - struct fd *filedes = &fd_tbl[FD]; - filedes->access = READ; - filedes->file = file; + struct fd *filedes = &fd_tbl[FD]; + filedes->access = READ; + filedes->file = file; - struct dir_position *position = &filedes->position.dir_pos; - position->open_dir = file; - position->cur = file; - position->status = NORMAL; + struct dir_position *position = &filedes->position.dir_pos; + position->open_dir = file; + position->cur = file; + position->status = NORMAL; - return FD; + return FD; } -uint32 dir_close(int32 FD) +uint32 +dir_close(int32 FD) { - if (FD > OS_MAX_NUM_OPEN_FILES + 1 || FD <= 0) return OS_FS_ERROR; - struct fd *filedes = &fd_tbl[FD]; - - filedes->ino = 0; - return OS_FS_SUCCESS; -} + if (FD > OS_MAX_NUM_OPEN_FILES + 1 || FD <= 0) return OS_FS_ERROR; + struct fd *filedes = &fd_tbl[FD]; -void dir_rewind(int32 FD) -{ - if (FD >= OS_MAX_NUM_OPEN_FILES || FD <= 0) return; - struct fd *filedes = &fd_tbl[FD]; - - if (filedes->ino == 0) return; - if (filedes->file->type != FSOBJ_DIR) return; - - // cur == open_dir indicates that stream is in initial position, prior to first read - filedes->position.dir_pos.cur = filedes->position.dir_pos.open_dir; - filedes->position.dir_pos.status = NORMAL; + filedes->ino = 0; + return OS_FS_SUCCESS; } - -os_dirent_t *dir_read(int32 FD) -{ - if (FD > OS_MAX_NUM_OPEN_FILES + 1 || FD <= 0) return NULL; - struct fd *filedes = &fd_tbl[FD]; - - if (filedes->ino == 0) return NULL; - if (filedes->file->type != FSOBJ_DIR) return NULL; - - os_dirent_t *dir = &filedes->position.dir_pos.dirent; - - switch (filedes->position.dir_pos.status) { - case NORMAL : - break; - - case END_OF_STREAM : - return NULL; - - case PARENT_DIR_LINK : - filedes->position.dir_pos.cur = NULL; - filedes->position.dir_pos.status = END_OF_STREAM; - return NULL; - - case CUR_DIR_LINK : - strcpy(dir->d_name, ".."); - dir->d_ino = 0; - filedes->position.dir_pos.status = PARENT_DIR_LINK; - return dir; - } - - if (filedes->position.dir_pos.cur == filedes->position.dir_pos.open_dir) { - filedes->position.dir_pos.cur = filedes->position.dir_pos.open_dir->child; - } else { - filedes->position.dir_pos.cur = filedes->position.dir_pos.cur->next; - } - - if (!filedes->position.dir_pos.cur) { - filedes->position.dir_pos.status = CUR_DIR_LINK; - strcpy(dir->d_name, "."); - dir->d_ino = 0; - } else { - strcpy(dir->d_name, filedes->position.dir_pos.cur->name); - dir->d_ino = filedes->position.dir_pos.cur->ino; - } - - return (os_dirent_t *) dir; -} - -int32 file_mkdir(char *path) -{ - assert(path); - struct fsobj *o; - if (file_get_new(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; - o->name = path_to_name(path); - o->type = FSOBJ_DIR; - o->next = NULL; - o->prev = NULL; - o->parent = NULL; - o->child = NULL; - o->size = 0; - if (file_insert(o, path) != OS_FS_SUCCESS) return OS_FS_ERR_PATH_INVALID; - return OS_FS_SUCCESS; -} - -int32 file_rmdir(char *path) -{ - assert(path); - struct fsobj *root = file_find(path); - if (!root) return OS_FS_ERROR; - struct fsobj *cur = root; - while (root->child) { - // if cur is the last leaf in a list - if (!cur->next && !cur->child) { - if (cur->prev != NULL) { - assert(cur->prev->next == cur); - cur = cur->prev; - file_rm(cur->next); - } - else { - assert(cur->parent->child == cur); - cur = cur->parent; - file_rm(cur->child); - } - } else if (cur->child != NULL) { - cur = cur->child; - } else { //cur->next !=NULL - cur = cur->next; - } - } - file_rm(root); - return OS_FS_SUCCESS; -} - -int32 file_rm(struct fsobj *o) -{ - // TODO, pass an error back out of library if someone implicitly tries to close open file - //assert(o->refcnt == 0); - assert(o && o->child == NULL); - // if o is first in list of children, update parent link to it - if (o->prev == NULL && o->parent) { - assert(o->parent->child == o); - // if next = null this still works - o->parent->child = o->next; - } - - // update link from prev still work if next or prev = null - if (o->prev) { - assert(o->prev->next == o); - o->prev->next = o->next; - } - // update link from next - if (o->next) { - assert(o->next->prev == o); - o->next->prev = o->prev; - } - // there should now be no links within the fs to o - // we do not do deallocate file data but we do reuse fsobj - *o = (struct fsobj) { - .name = NULL - }; - - return OS_FS_SUCCESS; + +void +dir_rewind(int32 FD) +{ + if (FD >= OS_MAX_NUM_OPEN_FILES || FD <= 0) return; + struct fd *filedes = &fd_tbl[FD]; + + if (filedes->ino == 0) return; + if (filedes->file->type != FSOBJ_DIR) return; + + // cur == open_dir indicates that stream is in initial position, prior to first read + filedes->position.dir_pos.cur = filedes->position.dir_pos.open_dir; + filedes->position.dir_pos.status = NORMAL; +} + +os_dirent_t * +dir_read(int32 FD) +{ + if (FD > OS_MAX_NUM_OPEN_FILES + 1 || FD <= 0) return NULL; + struct fd *filedes = &fd_tbl[FD]; + + if (filedes->ino == 0) return NULL; + if (filedes->file->type != FSOBJ_DIR) return NULL; + + os_dirent_t *dir = &filedes->position.dir_pos.dirent; + + switch (filedes->position.dir_pos.status) { + case NORMAL: + break; + + case END_OF_STREAM: + return NULL; + + case PARENT_DIR_LINK: + filedes->position.dir_pos.cur = NULL; + filedes->position.dir_pos.status = END_OF_STREAM; + return NULL; + + case CUR_DIR_LINK: + strcpy(dir->d_name, ".."); + dir->d_ino = 0; + filedes->position.dir_pos.status = PARENT_DIR_LINK; + return dir; + } + + if (filedes->position.dir_pos.cur == filedes->position.dir_pos.open_dir) { + filedes->position.dir_pos.cur = filedes->position.dir_pos.open_dir->child; + } else { + filedes->position.dir_pos.cur = filedes->position.dir_pos.cur->next; + } + + if (!filedes->position.dir_pos.cur) { + filedes->position.dir_pos.status = CUR_DIR_LINK; + strcpy(dir->d_name, "."); + dir->d_ino = 0; + } else { + strcpy(dir->d_name, filedes->position.dir_pos.cur->name); + dir->d_ino = filedes->position.dir_pos.cur->ino; + } + + return (os_dirent_t *)dir; +} + +int32 +file_mkdir(char *path) +{ + assert(path); + struct fsobj *o; + if (file_get_new(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + o->name = path_to_name(path); + o->type = FSOBJ_DIR; + o->next = NULL; + o->prev = NULL; + o->parent = NULL; + o->child = NULL; + o->size = 0; + if (file_insert(o, path) != OS_FS_SUCCESS) return OS_FS_ERR_PATH_INVALID; + return OS_FS_SUCCESS; +} + +int32 +file_rmdir(char *path) +{ + assert(path); + struct fsobj *root = file_find(path); + if (!root) return OS_FS_ERROR; + struct fsobj *cur = root; + while (root->child) { + // if cur is the last leaf in a list + if (!cur->next && !cur->child) { + if (cur->prev != NULL) { + assert(cur->prev->next == cur); + cur = cur->prev; + file_rm(cur->next); + } else { + assert(cur->parent->child == cur); + cur = cur->parent; + file_rm(cur->child); + } + } else if (cur->child != NULL) { + cur = cur->child; + } else { // cur->next !=NULL + cur = cur->next; + } + } + file_rm(root); + return OS_FS_SUCCESS; +} + +int32 +file_rm(struct fsobj *o) +{ + // TODO, pass an error back out of library if someone implicitly tries to close open file + // assert(o->refcnt == 0); + assert(o && o->child == NULL); + // if o is first in list of children, update parent link to it + if (o->prev == NULL && o->parent) { + assert(o->parent->child == o); + // if next = null this still works + o->parent->child = o->next; + } + + // update link from prev still work if next or prev = null + if (o->prev) { + assert(o->prev->next == o); + o->prev->next = o->next; + } + // update link from next + if (o->next) { + assert(o->next->prev == o); + o->next->prev = o->prev; + } + // there should now be no links within the fs to o + // we do not do deallocate file data but we do reuse fsobj + *o = (struct fsobj){.name = NULL}; + + return OS_FS_SUCCESS; } // close all of the open FDs associated with file -int32 file_close_by_ino(int32 ino) +int32 +file_close_by_ino(int32 ino) { - int i; - for(i = 1 ; i <= OS_MAX_NUM_OPEN_FILES ; i++) { - if(fd_tbl[i].ino == ino) { - file_close(i); - } - } - return OS_FS_SUCCESS; + int i; + for (i = 1; i <= OS_MAX_NUM_OPEN_FILES; i++) { + if (fd_tbl[i].ino == ino) { file_close(i); } + } + return OS_FS_SUCCESS; } /****************************************************************************** ** fs Level Methods ******************************************************************************/ -uint32 fs_mount(char *devname, char *mountpoint) -{ - assert(devname); - uint32 i; - for (i=0 ; i < MAX_NUM_FS && filesystems[i].devname != NULL ; i++) { - if (!strcmp(filesystems[i].devname, devname)) { - // This is a bad hack that I have not found a solution to - // basically mount should fail if already mounted - // but to load tar I need to pre-mount the first filesystem - if (strcmp(mountpoint, "/ram") && filesystems[i].root) return OS_FS_ERROR; - struct fsobj *o; - if (file_get_new(&o)) return OS_FS_ERROR; - filesystems[i].mountpoint = mountpoint; - openfs = &filesystems[i]; - if (!filesystems[i].root) { - file_mkdir(mountpoint); - } - assert(strcmp(openfs->mountpoint, mountpoint) == 0); - return OS_FS_SUCCESS; - } - } - return OS_FS_ERROR; -} - -uint32 fs_unmount(char *mountpoint) { - uint32 i; - assert(mountpoint); - for (i = 0 ; i < MAX_NUM_FS && filesystems[i].mountpoint != NULL ; i++) { - if (mountpoint != NULL && !strcmp(filesystems[i].mountpoint, mountpoint)) { - filesystems[i].mountpoint = NULL; - return OS_FS_SUCCESS; - } - } - return OS_FS_ERROR; -} - -uint32 fs_init(char *devname, char *volname, uint32 blocksize, uint32 numblocks) -{ - uint32 count = 0, ret = 0; - if (!devname) return OS_FS_ERR_INVALID_POINTER; - if (blocksize == 0 || numblocks == 0) return OS_FS_ERROR; - if (strlen(devname) >= OS_FS_DEV_NAME_LEN || strlen(volname) >= OS_FS_VOL_NAME_LEN) - return OS_FS_ERROR; - - while (count < MAX_NUM_FS && filesystems[count].devname) { - count++; - } - if (count == MAX_NUM_FS) return OS_FS_ERR_DEVICE_NOT_FREE; - - filesystems[count] = (struct fs) { - .devname = devname, - .volname = volname, - .mountpoint = "", - .blocksize = blocksize, - .numblocks = numblocks, - .root = NULL - }; - - openfs = &filesystems[count]; - return OS_FS_SUCCESS; -} - -int32 fs_remove(char *devname) -{ - if (!devname) return OS_FS_ERR_INVALID_POINTER; - - uint32 i; - for (i = 0 ; i < MAX_NUM_FS && filesystems[i].devname != NULL ; i++) { - if (devname && filesystems[i].devname && !strcmp(filesystems[i].devname,devname)) { - filesystems[i].devname = NULL; - filesystems[i].volname = NULL; - filesystems[i].mountpoint = NULL; - filesystems[i].blocksize = 0; - filesystems[i].numblocks = 0; - filesystems[i].root = NULL; - return OS_FS_SUCCESS; - } - } - return OS_FS_ERROR; - -} - -int32 fs_get_drive_name(char *PhysDriveName, char *MountPoint) -{ - uint32 i; - for (i = 0 ; i < MAX_NUM_FS && filesystems[i].devname != NULL ; i++) { - if (filesystems[i].mountpoint && !strcmp(filesystems[i].mountpoint,MountPoint)) { - char *new_name = "Ram FS\n"; - memcpy(PhysDriveName, new_name, strlen(new_name)); - return OS_FS_SUCCESS; - } - } - return OS_FS_ERROR; -} - -int32 fs_get_info(os_fsinfo_t *filesys_info) -{ - filesys_info->MaxFds = MAX_NUM_FILES; - uint32 i, count = 0; - for (i = 0 ; i < MAX_NUM_FILES ; i++) { - if (files[i].ino == 0) count++; - } - filesys_info->FreeFds = count; - filesys_info->MaxVolumes = MAX_NUM_FS; - for (i = 0, count = 0 ; i < MAX_NUM_FS ; i++){ - if (!filesystems[i].devname) count++; - } - filesys_info->FreeVolumes = count; - return OS_FS_SUCCESS; +uint32 +fs_mount(char *devname, char *mountpoint) +{ + assert(devname); + uint32 i; + for (i = 0; i < MAX_NUM_FS && filesystems[i].devname != NULL; i++) { + if (!strcmp(filesystems[i].devname, devname)) { + // This is a bad hack that I have not found a solution to + // basically mount should fail if already mounted + // but to load tar I need to pre-mount the first filesystem + if (strcmp(mountpoint, "/ram") && filesystems[i].root) return OS_FS_ERROR; + struct fsobj *o; + if (file_get_new(&o)) return OS_FS_ERROR; + filesystems[i].mountpoint = mountpoint; + openfs = &filesystems[i]; + if (!filesystems[i].root) { file_mkdir(mountpoint); } + assert(strcmp(openfs->mountpoint, mountpoint) == 0); + return OS_FS_SUCCESS; + } + } + return OS_FS_ERROR; +} + +uint32 +fs_unmount(char *mountpoint) +{ + uint32 i; + assert(mountpoint); + for (i = 0; i < MAX_NUM_FS && filesystems[i].mountpoint != NULL; i++) { + if (mountpoint != NULL && !strcmp(filesystems[i].mountpoint, mountpoint)) { + filesystems[i].mountpoint = NULL; + return OS_FS_SUCCESS; + } + } + return OS_FS_ERROR; +} + +uint32 +fs_init(char *devname, char *volname, uint32 blocksize, uint32 numblocks) +{ + uint32 count = 0, ret = 0; + if (!devname) return OS_FS_ERR_INVALID_POINTER; + if (blocksize == 0 || numblocks == 0) return OS_FS_ERROR; + if (strlen(devname) >= OS_FS_DEV_NAME_LEN || strlen(volname) >= OS_FS_VOL_NAME_LEN) return OS_FS_ERROR; + + while (count < MAX_NUM_FS && filesystems[count].devname) { count++; } + if (count == MAX_NUM_FS) return OS_FS_ERR_DEVICE_NOT_FREE; + + filesystems[count] = (struct fs){.devname = devname, + .volname = volname, + .mountpoint = "", + .blocksize = blocksize, + .numblocks = numblocks, + .root = NULL}; + + openfs = &filesystems[count]; + return OS_FS_SUCCESS; +} + +int32 +fs_remove(char *devname) +{ + if (!devname) return OS_FS_ERR_INVALID_POINTER; + + uint32 i; + for (i = 0; i < MAX_NUM_FS && filesystems[i].devname != NULL; i++) { + if (devname && filesystems[i].devname && !strcmp(filesystems[i].devname, devname)) { + filesystems[i].devname = NULL; + filesystems[i].volname = NULL; + filesystems[i].mountpoint = NULL; + filesystems[i].blocksize = 0; + filesystems[i].numblocks = 0; + filesystems[i].root = NULL; + return OS_FS_SUCCESS; + } + } + return OS_FS_ERROR; +} + +int32 +fs_get_drive_name(char *PhysDriveName, char *MountPoint) +{ + uint32 i; + for (i = 0; i < MAX_NUM_FS && filesystems[i].devname != NULL; i++) { + if (filesystems[i].mountpoint && !strcmp(filesystems[i].mountpoint, MountPoint)) { + char *new_name = "Ram FS\n"; + memcpy(PhysDriveName, new_name, strlen(new_name)); + return OS_FS_SUCCESS; + } + } + return OS_FS_ERROR; +} + +int32 +fs_get_info(os_fsinfo_t *filesys_info) +{ + filesys_info->MaxFds = MAX_NUM_FILES; + uint32 i, count = 0; + for (i = 0; i < MAX_NUM_FILES; i++) { + if (files[i].ino == 0) count++; + } + filesys_info->FreeFds = count; + filesys_info->MaxVolumes = MAX_NUM_FS; + for (i = 0, count = 0; i < MAX_NUM_FS; i++) { + if (!filesystems[i].devname) count++; + } + filesys_info->FreeVolumes = count; + return OS_FS_SUCCESS; } diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.h b/src/components/implementation/no_interface/cFE_booter/osfilesys.h index f4040a54dc..08281c7f56 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.h +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.h @@ -20,30 +20,33 @@ #define MAX_NUM_DIRENT 10 // a page is 4096, size of f_part is 5 values * 4 bytes -#define F_PART_DATA_SIZE (4096-sizeof(struct f_part)) +#define F_PART_DATA_SIZE (4096 - sizeof(struct f_part)) -enum fsobj_type { - FSOBJ_FILE, - FSOBJ_DIR, +enum fsobj_type +{ + FSOBJ_FILE, + FSOBJ_DIR, }; -enum fs_permissions { - NONE = 0, - READ = 0x001, - WRITE = 0x010, - EXECUTE = 0x100, - ALL = READ | WRITE | EXECUTE, +enum fs_permissions +{ + NONE = 0, + READ = 0x001, + WRITE = 0x010, + EXECUTE = 0x100, + ALL = READ | WRITE | EXECUTE, }; struct file_position { - struct f_part *open_part; //part of file being read/written to - uint32 part_offset; //offset into part's data - uint32 file_offset; //position within file as a whole + struct f_part *open_part; // part of file being read/written to + uint32 part_offset; // offset into part's data + uint32 file_offset; // position within file as a whole }; -enum fpart_alloc_type { - STATIC, - DYNAMIC, +enum fpart_alloc_type +{ + STATIC, + DYNAMIC, }; /* @@ -53,90 +56,90 @@ enum fpart_alloc_type { */ struct fsobj { - char *name; - int32 ino; // 0 for free file - enum fsobj_type type; /* dir vs file, determines the type of FD position */ - size_t size; - uint32 refcnt; //number of filedes which have it opened - enum fs_permissions permission; // most permissive possible status it may be opened with - enum fpart_alloc_type memtype; - struct f_part *file_part; - struct fsobj *next, *prev; - struct fsobj *child, *parent; // child != NULL iff type = dir + char * name; + int32 ino; // 0 for free file + enum fsobj_type type; /* dir vs file, determines the type of FD position */ + size_t size; + uint32 refcnt; // number of filedes which have it opened + enum fs_permissions permission; // most permissive possible status it may be opened with + enum fpart_alloc_type memtype; + struct f_part * file_part; + struct fsobj * next, *prev; + struct fsobj * child, *parent; // child != NULL iff type = dir }; struct f_part { - struct fsobj *file; - struct f_part *next, *prev; - char *data; + struct fsobj * file; + struct f_part *next, *prev; + char * data; }; /* - * The state of a directory stream is either iterating through list of files, - * at one of two special paths, or at the end of the stream. The two special - * paths are '.' and '..' and the occur at the end of the list of files + * The state of a directory stream is either iterating through list of files, + * at one of two special paths, or at the end of the stream. The two special + * paths are '.' and '..' and the occur at the end of the list of files */ -enum dir_stream_status { - NORMAL, - CUR_DIR_LINK, - PARENT_DIR_LINK, - END_OF_STREAM, +enum dir_stream_status +{ + NORMAL, + CUR_DIR_LINK, + PARENT_DIR_LINK, + END_OF_STREAM, }; // offset into linked list of children struct dir_position { - struct fsobj *open_dir; /* Stream is children of open_dir */ - struct fsobj *cur; /* refers to current (last returned) file in dir stream */ - enum dir_stream_status status; /* indicates if special file or end of stream */ - os_dirent_t dirent; /* I really don't like storing this here. */ + struct fsobj * open_dir; /* Stream is children of open_dir */ + struct fsobj * cur; /* refers to current (last returned) file in dir stream */ + enum dir_stream_status status; /* indicates if special file or end of stream */ + os_dirent_t dirent; /* I really don't like storing this here. */ }; /* * The type being used must be consistent with fsobj->type */ union fd_position { - struct dir_position dir_pos; - struct file_position file_pos; + struct dir_position dir_pos; + struct file_position file_pos; }; // Currently this filedes is used only for dir streams, and not real filedes // TODO: Switch non-dir to table based filedes struct fd { - int32 ino; - enum fs_permissions access; /* must be < or == permissive as file->permission */ - union fd_position position; /* the type of position is determined by file->type */ - struct fsobj *file; + int32 ino; + enum fs_permissions access; /* must be < or == permissive as file->permission */ + union fd_position position; /* the type of position is determined by file->type */ + struct fsobj * file; }; struct fs { - char *devname; - char *volname; - char *mountpoint; - uint32 blocksize; - uint32 numblocks; - struct fsobj *root; + char * devname; + char * volname; + char * mountpoint; + uint32 blocksize; + uint32 numblocks; + struct fsobj *root; }; -static char *path_to_name(char *path) +static char * +path_to_name(char *path) { - assert(path); - uint32 path_len = strlen(path), offset; - assert(path_len > 1); - - //remove one or more '/' at the end of path - while(path[strlen(path) - 1] == '/'){ - path[strlen(path) - 1] = 0; - } - - // iterate from right to left through the path until you find a '/' - // everything you have iterated through is the name of the file - for ( offset = path_len - 2 ; path[offset] != '/' && offset > 0 ; offset--) { - //do nothing - } - char *name = path + offset +1; - - assert(0 < strlen(name)); - return name; + assert(path); + uint32 path_len = strlen(path), offset; + assert(path_len > 1); + + // remove one or more '/' at the end of path + while (path[strlen(path) - 1] == '/') { path[strlen(path) - 1] = 0; } + + // iterate from right to left through the path until you find a '/' + // everything you have iterated through is the name of the file + for (offset = path_len - 2; path[offset] != '/' && offset > 0; offset--) { + // do nothing + } + char *name = path + offset + 1; + + assert(0 < strlen(name)); + return name; } /****************************************************************************** @@ -189,7 +192,7 @@ uint32 permission_COS_to_cFE(enum fs_permissions permission); /****************************************************************************** ** dirent Level Methods ******************************************************************************/ -//int32 newfd_get(int32 ino); +// int32 newfd_get(int32 ino); int32 dir_open(char *path); diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index 1f103513bf..89812d8511 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -12,36 +12,40 @@ #include "cFE_util.h" #include "ostask.h" -thdid_t id_overrides[SL_MAX_NUM_THDS] = { 0 }; +thdid_t id_overrides[SL_MAX_NUM_THDS] = {0}; -int32 OS_ModuleTableInit(void) +int32 +OS_ModuleTableInit(void) { - return OS_SUCCESS; + return OS_SUCCESS; } -int32 OS_ModuleLoad(uint32 *module_id, const char *module_name, const char *filename) +int32 +OS_ModuleLoad(uint32 *module_id, const char *module_name, const char *filename) { - return OS_SUCCESS; + return OS_SUCCESS; } -int32 OS_ModuleUnload(uint32 module_id) +int32 +OS_ModuleUnload(uint32 module_id) { - return OS_SUCCESS; + return OS_SUCCESS; } -void launch_other_component(int child_id, int is_library) +void +launch_other_component(int child_id, int is_library) { - struct cos_defcompinfo child_dci; - cos_defcompinfo_childid_init(&child_dci, child_id); - - struct sl_thd *t = sl_thd_initaep_alloc(&child_dci, NULL, 0, 0, 0); - if (is_library) { - sl_thd_param_set(t, sched_param_pack(SCHEDP_PRIO, 1)); - sl_thd_yield(sl_thd_thdid(t)); - } else { - id_overrides[sl_thd_thdid(t)] = sl_thdid(); - while(1) sl_thd_yield(sl_thd_thdid(t)); - } + struct cos_defcompinfo child_dci; + cos_defcompinfo_childid_init(&child_dci, child_id); + + struct sl_thd *t = sl_thd_initaep_alloc(&child_dci, NULL, 0, 0, 0); + if (is_library) { + sl_thd_param_set(t, sched_param_pack(SCHEDP_PRIO, 1)); + sl_thd_yield(sl_thd_thdid(t)); + } else { + id_overrides[sl_thd_thdid(t)] = sl_thdid(); + while (1) sl_thd_yield(sl_thd_thdid(t)); + } } // Component proxy hack @@ -51,52 +55,56 @@ void launch_other_component(int child_id, int is_library) // 3) Add an init routine in the component // 4) Add a proxy here -void sample_lib_proxy() +void +sample_lib_proxy() { - launch_other_component(1, 1); + launch_other_component(1, 1); } -void sample_app_proxy() +void +sample_app_proxy() { - launch_other_component(3, 0); + launch_other_component(3, 0); } -void sch_lab_proxy() +void +sch_lab_proxy() { - launch_other_component(5, 0); + launch_other_component(5, 0); } struct symbol_proxy { - char* symbol_name; - void* proxy; + char *symbol_name; + void *proxy; }; #define NUM_PROXIES 3 -struct symbol_proxy proxies[NUM_PROXIES] = { - {"SAMPLE_LibInit", sample_lib_proxy}, - {"SAMPLE_AppMain", sample_app_proxy}, - {"SCH_Lab_AppMain", sch_lab_proxy} -}; +struct symbol_proxy proxies[NUM_PROXIES] = {{"SAMPLE_LibInit", sample_lib_proxy}, + {"SAMPLE_AppMain", sample_app_proxy}, + {"SCH_Lab_AppMain", sch_lab_proxy}}; -int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) +int32 +OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) { int i; for (i = 0; i < NUM_PROXIES; i++) { if (!strcmp(symbol_name, proxies[i].symbol_name)) { - *symbol_address = (cpuaddr) proxies[i].proxy; + *symbol_address = (cpuaddr)proxies[i].proxy; return OS_SUCCESS; } } - return OS_ERROR; + return OS_ERROR; } -int32 OS_ModuleInfo(uint32 module_id, OS_module_prop_t *module_info) +int32 +OS_ModuleInfo(uint32 module_id, OS_module_prop_t *module_info) { - return OS_ERR_NOT_IMPLEMENTED; + return OS_ERR_NOT_IMPLEMENTED; } -int32 OS_SymbolTableDump(const char *filename, uint32 size_limit) +int32 +OS_SymbolTableDump(const char *filename, uint32 size_limit) { - /* Not needed. */ - return OS_ERR_NOT_IMPLEMENTED; + /* Not needed. */ + return OS_ERR_NOT_IMPLEMENTED; } diff --git a/src/components/implementation/no_interface/cFE_booter/osnetwork.c b/src/components/implementation/no_interface/cFE_booter/osnetwork.c index c269ef9de7..8d72b5164c 100644 --- a/src/components/implementation/no_interface/cFE_booter/osnetwork.c +++ b/src/components/implementation/no_interface/cFE_booter/osnetwork.c @@ -6,102 +6,118 @@ /* ** Networking API */ -int32 OS_SocketOpen(uint32 *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t Type) +int32 +OS_SocketOpen(uint32 *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t Type) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_SocketClose(uint32 sock_id) +int32 +OS_SocketClose(uint32 sock_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_SocketBind(uint32 sock_id, const OS_SockAddr_t *Addr) +int32 +OS_SocketBind(uint32 sock_id, const OS_SockAddr_t *Addr) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_SocketConnect(uint32 sock_id, const OS_SockAddr_t *Addr, int32 timeout) +int32 +OS_SocketConnect(uint32 sock_id, const OS_SockAddr_t *Addr, int32 timeout) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_SocketAccept(uint32 sock_id, uint32 *connsock_id, OS_SockAddr_t *Addr, int32 timeout) +int32 +OS_SocketAccept(uint32 sock_id, uint32 *connsock_id, OS_SockAddr_t *Addr, int32 timeout) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_SocketRecvFrom(uint32 sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout) +int32 +OS_SocketRecvFrom(uint32 sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_SocketSendTo(uint32 sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr) +int32 +OS_SocketSendTo(uint32 sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_SocketGetIdByName (uint32 *sock_id, const char *sock_name) +int32 +OS_SocketGetIdByName(uint32 *sock_id, const char *sock_name) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_SocketGetInfo (uint32 sock_id, OS_socket_prop_t *sock_prop) +int32 +OS_SocketGetInfo(uint32 sock_id, OS_socket_prop_t *sock_prop) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain) +int32 +OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_SocketAddrToString(char *buffer, uint32 buflen, const OS_SockAddr_t *Addr) +int32 +OS_SocketAddrToString(char *buffer, uint32 buflen, const OS_SockAddr_t *Addr) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_SocketAddrFromString(OS_SockAddr_t *Addr, const char *string) +int32 +OS_SocketAddrFromString(OS_SockAddr_t *Addr, const char *string) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_SocketAddrGetPort(uint16 *PortNum, const OS_SockAddr_t *Addr) +int32 +OS_SocketAddrGetPort(uint16 *PortNum, const OS_SockAddr_t *Addr) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum) +int32 +OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } /* ** OS_NetworkGetID is currently [[deprecated]] as its behavior is ** unknown and not consistent across operating systems. */ -int32 OS_NetworkGetID(void) +int32 +OS_NetworkGetID(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_NetworkGetHostName(char *host_name, uint32 name_len) +int32 +OS_NetworkGetHostName(char *host_name, uint32 name_len) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } diff --git a/src/components/implementation/no_interface/cFE_booter/osqueue.c b/src/components/implementation/no_interface/cFE_booter/osqueue.c index 2750beea1e..33a9c38adf 100644 --- a/src/components/implementation/no_interface/cFE_booter/osqueue.c +++ b/src/components/implementation/no_interface/cFE_booter/osqueue.c @@ -15,20 +15,20 @@ struct sl_lock queue_lock = SL_LOCK_STATIC_INIT(); // The main queue data structure. struct queue { - // Whether or not the index of this queue is already taken. - int32 used; + // Whether or not the index of this queue is already taken. + int32 used; - // The number of elements allowed in the queue. - uint32 depth; + // The number of elements allowed in the queue. + uint32 depth; - // The size, in bytes, of each element in the queue. - uint32 data_size; + // The size, in bytes, of each element in the queue. + uint32 data_size; - // The name of the queue. For display purposes only. - char name[OS_MAX_API_NAME]; + // The name of the queue. For display purposes only. + char name[OS_MAX_API_NAME]; - uint32 head; - uint32 tail; + uint32 head; + uint32 tail; }; // The global queue bank. @@ -38,153 +38,132 @@ struct queue queues[OS_MAX_QUEUES]; char queue_data[OS_MAX_QUEUES][MAX_QUEUE_DATA_SIZE]; int32 -OS_QueueCreate(uint32* queue_id, const char* queue_name, uint32 queue_depth, uint32 data_size, uint32 flags) +OS_QueueCreate(uint32 *queue_id, const char *queue_name, uint32 queue_depth, uint32 data_size, uint32 flags) { - int32 i; - uint32 qid; - - // Check validity of parameters. - if (queue_id == NULL || queue_name == NULL) { - return OS_INVALID_POINTER; - } - - // Check name length. - if (strlen(queue_name) >= OS_MAX_API_NAME) { - return OS_ERR_NAME_TOO_LONG; - } - - // Check to see if the name is already taken. - for (i = 0 ; i < OS_MAX_QUEUES ; i++) { - if ((queues[i].used == TRUE) && strcmp((char*)queue_name, queues[i].name) == 0) { - return OS_ERR_NAME_TAKEN; - } - } - - // Calculate the queue ID. - for (qid = 0 ; qid < OS_MAX_QUEUES ; qid++) { - if (queues[qid].used == FALSE) { - break; - } - } - - // Fail if there are too many queues. - if (qid >= OS_MAX_QUEUES || queues[qid].used == TRUE) { - return OS_ERR_NO_FREE_IDS; - } - - // OS_ERROR may also be returned in the event that an OS call fails, but none are used here. - - *queue_id = qid; - queues[*queue_id].used = TRUE; - queues[*queue_id].depth = queue_depth; - queues[*queue_id].data_size = data_size; - strcpy(queues[*queue_id].name, queue_name); - - return OS_SUCCESS; + int32 i; + uint32 qid; + + // Check validity of parameters. + if (queue_id == NULL || queue_name == NULL) { return OS_INVALID_POINTER; } + + // Check name length. + if (strlen(queue_name) >= OS_MAX_API_NAME) { return OS_ERR_NAME_TOO_LONG; } + + // Check to see if the name is already taken. + for (i = 0; i < OS_MAX_QUEUES; i++) { + if ((queues[i].used == TRUE) && strcmp((char *)queue_name, queues[i].name) == 0) { + return OS_ERR_NAME_TAKEN; + } + } + + // Calculate the queue ID. + for (qid = 0; qid < OS_MAX_QUEUES; qid++) { + if (queues[qid].used == FALSE) { break; } + } + + // Fail if there are too many queues. + if (qid >= OS_MAX_QUEUES || queues[qid].used == TRUE) { return OS_ERR_NO_FREE_IDS; } + + // OS_ERROR may also be returned in the event that an OS call fails, but none are used here. + + *queue_id = qid; + queues[*queue_id].used = TRUE; + queues[*queue_id].depth = queue_depth; + queues[*queue_id].data_size = data_size; + strcpy(queues[*queue_id].name, queue_name); + + return OS_SUCCESS; } int32 -OS_QueueDelete(uint32 queue_id) { - if (queue_id > OS_MAX_QUEUES) { - return OS_ERR_INVALID_ID; - } - // Check if there is a queue to be deleted at the ID. - if (queues[queue_id].used == FALSE) { - return OS_ERR_INVALID_ID; - } - - // Reset all values in the queue. - queues[queue_id].used = FALSE; - queues[queue_id].depth = 0; - queues[queue_id].data_size = 0; - strcpy(queues[queue_id].name, ""); - queues[queue_id].head = 0; - queues[queue_id].tail = 0; - - // OS_ERROR may also be returned in the event that an OS call fails, but none are used here. - - return OS_SUCCESS; +OS_QueueDelete(uint32 queue_id) +{ + if (queue_id > OS_MAX_QUEUES) { return OS_ERR_INVALID_ID; } + // Check if there is a queue to be deleted at the ID. + if (queues[queue_id].used == FALSE) { return OS_ERR_INVALID_ID; } + + // Reset all values in the queue. + queues[queue_id].used = FALSE; + queues[queue_id].depth = 0; + queues[queue_id].data_size = 0; + strcpy(queues[queue_id].name, ""); + queues[queue_id].head = 0; + queues[queue_id].tail = 0; + + // OS_ERROR may also be returned in the event that an OS call fails, but none are used here. + + return OS_SUCCESS; } int32 -OS_QueuePoll(uint32 queue_id, void* data, uint32 size, uint32* size_copied) +OS_QueuePoll(uint32 queue_id, void *data, uint32 size, uint32 *size_copied) { - uint32 i; + uint32 i; - // Check if there are messages to be received. - if (queues[queue_id].head == queues[queue_id].tail) { - return OS_QUEUE_EMPTY; - } + // Check if there are messages to be received. + if (queues[queue_id].head == queues[queue_id].tail) { return OS_QUEUE_EMPTY; } - // TODO: Implement logic for returning OS_QUEUE_TIMEOUT (waiting on mutex implementation). + // TODO: Implement logic for returning OS_QUEUE_TIMEOUT (waiting on mutex implementation). - if (size < queues[queue_id].data_size) { - return OS_QUEUE_INVALID_SIZE; - } + if (size < queues[queue_id].data_size) { return OS_QUEUE_INVALID_SIZE; } - // A helper reference to the currently selected queue. - struct queue* cur = &queues[queue_id]; + // A helper reference to the currently selected queue. + struct queue *cur = &queues[queue_id]; - // Walk through the bytes at the head of the queue and write them to buffer `data`. - for (i = 0; i < size; i++) { - *((char*)data + i) = queue_data[queue_id][cur->head * cur->data_size + i]; - } + // Walk through the bytes at the head of the queue and write them to buffer `data`. + for (i = 0; i < size; i++) { *((char *)data + i) = queue_data[queue_id][cur->head * cur->data_size + i]; } - // Advance the queue head, wrapping if it is passed `depth`. - cur->head = (cur->head + 1) % cur->depth; + // Advance the queue head, wrapping if it is passed `depth`. + cur->head = (cur->head + 1) % cur->depth; - return OS_SUCCESS; + return OS_SUCCESS; } int32 -OS_QueueGet(uint32 queue_id, void* data, uint32 size, uint32* size_copied, int32 timeout) +OS_QueueGet(uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout) { - uint32 i; - int result = OS_ERROR; - - sl_lock_take(&queue_lock); - - // Check if the requested queue exists. - if (queue_id > OS_MAX_QUEUES || queues[queue_id].used == FALSE) { - result = OS_ERR_INVALID_ID; - goto exit; - } - - // Check for a NULL pointer. - if (data == NULL || size_copied == NULL) { - result = OS_INVALID_POINTER; - goto exit; - } - - /* FIXME: Block instead of poll */ - int32 intervals; - if (timeout == OS_CHECK) { - result = OS_QueuePoll(queue_id, data, size, size_copied); - goto exit; - } else if (timeout == OS_PEND) { - intervals = 0xFFFFFF; - } else { - intervals = timeout / 50 + 1; - } - - int32 inter = 0; - for (inter = 0; inter < intervals; inter++) { - result = OS_QueuePoll(queue_id, data, size, size_copied); - if (result == OS_SUCCESS) { - goto exit; - } - sl_lock_release(&queue_lock); - OS_TaskDelay(50); - sl_lock_take(&queue_lock); - } - assert(result != OS_ERROR); + uint32 i; + int result = OS_ERROR; + + sl_lock_take(&queue_lock); + + // Check if the requested queue exists. + if (queue_id > OS_MAX_QUEUES || queues[queue_id].used == FALSE) { + result = OS_ERR_INVALID_ID; + goto exit; + } + + // Check for a NULL pointer. + if (data == NULL || size_copied == NULL) { + result = OS_INVALID_POINTER; + goto exit; + } + + /* FIXME: Block instead of poll */ + int32 intervals; + if (timeout == OS_CHECK) { + result = OS_QueuePoll(queue_id, data, size, size_copied); + goto exit; + } else if (timeout == OS_PEND) { + intervals = 0xFFFFFF; + } else { + intervals = timeout / 50 + 1; + } + + int32 inter = 0; + for (inter = 0; inter < intervals; inter++) { + result = OS_QueuePoll(queue_id, data, size, size_copied); + if (result == OS_SUCCESS) { goto exit; } + sl_lock_release(&queue_lock); + OS_TaskDelay(50); + sl_lock_take(&queue_lock); + } + assert(result != OS_ERROR); exit: - sl_lock_release(&queue_lock); - if (result != OS_SUCCESS && timeout != OS_CHECK) { - return OS_QUEUE_TIMEOUT; - } - return result; + sl_lock_release(&queue_lock); + if (result != OS_SUCCESS && timeout != OS_CHECK) { return OS_QUEUE_TIMEOUT; } + return result; } /* @@ -192,97 +171,75 @@ OS_QueueGet(uint32 queue_id, void* data, uint32 size, uint32* size_copied, int32 * the behavior of the queue if it is full. */ int32 -OS_QueuePut(uint32 queue_id, const void* data, uint32 size, uint32 flags) +OS_QueuePut(uint32 queue_id, const void *data, uint32 size, uint32 flags) { - if (queue_id > OS_MAX_QUEUES) { - return OS_ERR_INVALID_ID; - } + if (queue_id > OS_MAX_QUEUES) { return OS_ERR_INVALID_ID; } - uint32 i; + uint32 i; - // Check if the requested queue exists. - if (queues[queue_id].used == FALSE) { - return OS_ERR_INVALID_ID; - } + // Check if the requested queue exists. + if (queues[queue_id].used == FALSE) { return OS_ERR_INVALID_ID; } - // Check for invalid pointers. - if (data == NULL) { - return OS_INVALID_POINTER; - } + // Check for invalid pointers. + if (data == NULL) { return OS_INVALID_POINTER; } - // Check if space remains in the queue. - if ((queues[queue_id].tail + 1) % queues[queue_id].depth == queues[queue_id].head) { - return OS_QUEUE_FULL; - } + // Check if space remains in the queue. + if ((queues[queue_id].tail + 1) % queues[queue_id].depth == queues[queue_id].head) { return OS_QUEUE_FULL; } - // A helper pointer to the currently selected queue. - struct queue* cur = &queues[queue_id]; + // A helper pointer to the currently selected queue. + struct queue *cur = &queues[queue_id]; - // Walk through the bytes in `data` and write them to the tail of the specified queue. - for (i = 0 ; i < size ; i++) { - queue_data[queue_id][cur->tail * cur->data_size + i] = *((char*)data + i); - } + // Walk through the bytes in `data` and write them to the tail of the specified queue. + for (i = 0; i < size; i++) { queue_data[queue_id][cur->tail * cur->data_size + i] = *((char *)data + i); } - // Advance the queue tail, wrapping if it is past `depth`. - cur->tail = (cur->tail + 1) % cur->depth; + // Advance the queue tail, wrapping if it is past `depth`. + cur->tail = (cur->tail + 1) % cur->depth; - return OS_SUCCESS; + return OS_SUCCESS; } int32 -OS_QueueGetIdByName(uint32* queue_id, const char* queue_name) +OS_QueueGetIdByName(uint32 *queue_id, const char *queue_name) { - uint32 i; - uint32 queue_found = FALSE; - - if (queue_id == NULL || queue_name == NULL) { - return OS_INVALID_POINTER; - } - - if (strlen(queue_name) > OS_MAX_API_NAME) { - return OS_ERR_NAME_TOO_LONG; - } - - for (i = 0 ; i < OS_MAX_QUEUES ; ++i) { - if (strcmp(queue_name, queues[i].name) == 0) { - *queue_id = i; - queue_found = TRUE; - break; - } - } - - if (queue_found == FALSE) { - return OS_ERR_NAME_NOT_FOUND; - } - - return OS_SUCCESS; + uint32 i; + uint32 queue_found = FALSE; + + if (queue_id == NULL || queue_name == NULL) { return OS_INVALID_POINTER; } + + if (strlen(queue_name) > OS_MAX_API_NAME) { return OS_ERR_NAME_TOO_LONG; } + + for (i = 0; i < OS_MAX_QUEUES; ++i) { + if (strcmp(queue_name, queues[i].name) == 0) { + *queue_id = i; + queue_found = TRUE; + break; + } + } + + if (queue_found == FALSE) { return OS_ERR_NAME_NOT_FOUND; } + + return OS_SUCCESS; } int32 -OS_QueueGetInfo(uint32 queue_id, OS_queue_prop_t* queue_prop) +OS_QueueGetInfo(uint32 queue_id, OS_queue_prop_t *queue_prop) { - if (queue_id > OS_MAX_QUEUES) { - return OS_ERR_INVALID_ID; - } + if (queue_id > OS_MAX_QUEUES) { return OS_ERR_INVALID_ID; } - if (queue_prop == NULL) { - return OS_INVALID_POINTER; - } + if (queue_prop == NULL) { return OS_INVALID_POINTER; } - if (queues[queue_id].used == FALSE) { - return OS_ERR_INVALID_ID; - } + if (queues[queue_id].used == FALSE) { return OS_ERR_INVALID_ID; } - // TODO: Identify creator; `0` is a dummy value. - queue_prop->creator = 0; + // TODO: Identify creator; `0` is a dummy value. + queue_prop->creator = 0; - strcpy(queue_prop->name, queues[queue_id].name); + strcpy(queue_prop->name, queues[queue_id].name); - /* - * NOTE: The OSAL documentation claims that there are two additional fields in `OS_queue_prop_t` called `free` - * and `id`. These members do not appear in our working version. - */ + /* + * NOTE: The OSAL documentation claims that there are two additional fields in `OS_queue_prop_t` called `free` + * and `id`. These members do not appear in our working version. + */ - return OS_SUCCESS; + return OS_SUCCESS; } diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index e1adafd630..a1ca721cde 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -14,7 +14,7 @@ void timer_fn_1hz(void *d) { - int first = 0; + int first = 0; cycles_t now, start; rdtscll(start); @@ -23,7 +23,8 @@ timer_fn_1hz(void *d) while (1) { rdtscll(now); if (now > start) { - CFE_TIME_Local1HzISR(); /* input param is signum. but CFE_PSP_TimerHandler doesn't seem to use it. */ + CFE_TIME_Local1HzISR(); /* input param is signum. but CFE_PSP_TimerHandler doesn't seem to use + it. */ } sl_thd_block_periodic(0); @@ -33,208 +34,187 @@ timer_fn_1hz(void *d) /* ** Internal Task helper functions */ -// We need to keep track of this to check if register or delete handler calls are invalid + #define MAIN_DELEGATE_THREAD_PRIORITY 2 + +/* We need to keep track of this to check if register or delete handler calls are invalid */ thdid_t main_delegate_thread_id; -void OS_SchedulerStart(cos_thd_fn_t main_delegate) { - sl_init(SL_MIN_PERIOD_US); +void +OS_SchedulerStart(cos_thd_fn_t main_delegate) +{ + sl_init(SL_MIN_PERIOD_US); - struct sl_thd* main_delegate_thread = sl_thd_alloc(main_delegate, NULL); - union sched_param_union sp = {.c = {.type = SCHEDP_PRIO, .value = MAIN_DELEGATE_THREAD_PRIORITY}}; - sl_thd_param_set(main_delegate_thread, sp.v); - main_delegate_thread_id = sl_thd_thdid(main_delegate_thread); + struct sl_thd * main_delegate_thread = sl_thd_alloc(main_delegate, NULL); + union sched_param_union sp = {.c = {.type = SCHEDP_PRIO, .value = MAIN_DELEGATE_THREAD_PRIORITY}}; + sl_thd_param_set(main_delegate_thread, sp.v); + main_delegate_thread_id = sl_thd_thdid(main_delegate_thread); - struct sl_thd_policy* policy = sl_mod_thd_policy_get(main_delegate_thread); - strcpy(policy->osal_task_prop.name, "MAIN_THREAD"); - policy->osal_task_prop.priority = MAIN_DELEGATE_THREAD_PRIORITY; - policy->osal_task_prop.OStask_id = (uint32) sl_thd_thdid(main_delegate_thread); + struct sl_thd_policy *policy = sl_mod_thd_policy_get(main_delegate_thread); + strcpy(policy->osal_task_prop.name, "MAIN_THREAD"); + policy->osal_task_prop.priority = MAIN_DELEGATE_THREAD_PRIORITY; + policy->osal_task_prop.OStask_id = (uint32)sl_thd_thdid(main_delegate_thread); - struct sl_thd *timer_thd = sl_thd_alloc(timer_fn_1hz, NULL); - union sched_param_union spperiod = {.c = {.type = SCHEDP_WINDOW, .value = HZ_PAUSE }}; - union sched_param_union spprio = {.c = {.type = SCHEDP_PRIO, .value = MAIN_DELEGATE_THREAD_PRIORITY+1}}; - sl_thd_param_set(timer_thd, spperiod.v); - sl_thd_param_set(timer_thd, spprio.v); + struct sl_thd * timer_thd = sl_thd_alloc(timer_fn_1hz, NULL); + union sched_param_union spperiod = {.c = {.type = SCHEDP_WINDOW, .value = HZ_PAUSE}}; + union sched_param_union spprio = {.c = {.type = SCHEDP_PRIO, .value = MAIN_DELEGATE_THREAD_PRIORITY + 1}}; + sl_thd_param_set(timer_thd, spperiod.v); + sl_thd_param_set(timer_thd, spprio.v); sl_sched_loop(); } -void osal_task_entry_wrapper(void* task_entry) { - ((osal_task_entry) task_entry)(); +void +osal_task_entry_wrapper(void *task_entry) +{ + ((osal_task_entry)task_entry)(); } -int is_valid_name(const char* name) { - int i; - for(i = 0; i < OS_MAX_API_NAME; i++) { - if(name[i] == '\0') { - return TRUE; - } - } - return FALSE; +int +is_valid_name(const char *name) +{ + int i; + for (i = 0; i < OS_MAX_API_NAME; i++) { + if (name[i] == '\0') { return TRUE; } + } + return FALSE; } -// TODO: Figure out how to check if thread names are taken -int is_thread_name_taken(const char* name) { - // for(int i = 0; i < num_tasks; i++) { - // thdid_t task_id = task_ids[i]; - // struct sl_thd_policy* task = sl_mod_thd_policy_get(sl_thd_lkup(task_id)); - // - // if(strcmp(task->name, name) == 0) { - // return TRUE; - // } - // } - return FALSE; +/* TODO: Figure out how to check if thread names are taken */ +int +is_thread_name_taken(const char *name) +{ + return FALSE; } /* ** Task API */ -// Necessary to control the number of created tasks -// TODO: Implement flags -int32 OS_TaskCreate(uint32 *task_id, const char *task_name, - osal_task_entry function_pointer, - uint32 *stack_pointer, - uint32 stack_size, - uint32 priority, uint32 flags) +/* NOTE: Flags here aren't implemented, but I can't find an implementation that does */ +int32 +OS_TaskCreate(uint32 *task_id, const char *task_name, osal_task_entry function_pointer, uint32 *stack_pointer, + uint32 stack_size, uint32 priority, uint32 flags) { - // TODO: Verify that we don't need to take the cs here - // Stack pointers can sometimes be null and that's ok for us - if(task_id == NULL || task_name == NULL || function_pointer == NULL){ - return OS_INVALID_POINTER; - } + /* TODO: Verify that we don't need to take the cs here */ - // Validate the name - if(!is_valid_name(task_name)) { - return OS_ERR_NAME_TOO_LONG; - } + if (task_id == NULL || task_name == NULL || function_pointer == NULL) { return OS_INVALID_POINTER; } - if(is_thread_name_taken(task_name)) { - return OS_ERR_NAME_TAKEN; - } + if (!is_valid_name(task_name)) { return OS_ERR_NAME_TOO_LONG; } - if(priority > 255 || priority < 1) { - return OS_ERR_INVALID_PRIORITY; - } + if (is_thread_name_taken(task_name)) { return OS_ERR_NAME_TAKEN; } - struct sl_thd* thd = sl_thd_alloc(osal_task_entry_wrapper, function_pointer); - assert(thd); - union sched_param_union sp = {.c = {.type = SCHEDP_PRIO, .value = priority}}; - sl_thd_param_set(thd, sp.v); + if (priority > 255 || priority < 1) { return OS_ERR_INVALID_PRIORITY; } - struct sl_thd_policy* policy = sl_mod_thd_policy_get(thd); - strcpy(policy->osal_task_prop.name, task_name); - policy->osal_task_prop.creator = OS_TaskGetId(); - policy->osal_task_prop.stack_size = stack_size; - policy->osal_task_prop.priority = priority; - policy->osal_task_prop.OStask_id = (uint32) sl_thd_thdid(thd); - policy->delete_handler = NULL; + struct sl_thd *thd = sl_thd_alloc(osal_task_entry_wrapper, function_pointer); + assert(thd); + union sched_param_union sp = {.c = {.type = SCHEDP_PRIO, .value = priority}}; + sl_thd_param_set(thd, sp.v); - *task_id = (uint32) sl_thd_thdid(thd); + struct sl_thd_policy *policy = sl_mod_thd_policy_get(thd); + strcpy(policy->osal_task_prop.name, task_name); + policy->osal_task_prop.creator = OS_TaskGetId(); + policy->osal_task_prop.stack_size = stack_size; + policy->osal_task_prop.priority = priority; + policy->osal_task_prop.OStask_id = (uint32)sl_thd_thdid(thd); + policy->delete_handler = NULL; - return OS_SUCCESS; + *task_id = (uint32)sl_thd_thdid(thd); + + return OS_SUCCESS; } -int32 OS_TaskDelete(uint32 task_id) +int32 +OS_TaskDelete(uint32 task_id) { - struct sl_thd* thd = sl_thd_lkup(task_id); - if(!thd) { - return OS_ERR_INVALID_ID; - } + struct sl_thd *thd = sl_thd_lkup(task_id); + if (!thd) { return OS_ERR_INVALID_ID; } - struct sl_thd_policy* thd_policy = sl_mod_thd_policy_get(thd); + struct sl_thd_policy *thd_policy = sl_mod_thd_policy_get(thd); - osal_task_entry delete_handler = thd_policy->delete_handler; - if(delete_handler) { - printc("Triggering delete handler @%p\n", (void *) delete_handler); - delete_handler(); - } + osal_task_entry delete_handler = thd_policy->delete_handler; + if (delete_handler) { delete_handler(); } - sl_thd_free(thd); + sl_thd_free(thd); - return OS_SUCCESS; + return OS_SUCCESS; } -uint32 OS_TaskGetId(void) +uint32 +OS_TaskGetId(void) { - thdid_t real_id = sl_thdid(); + thdid_t real_id = sl_thdid(); thdid_t possible_override = id_overrides[real_id]; - if(possible_override) return possible_override; + if (possible_override) return possible_override; return real_id; } -void OS_TaskExit(void) +void +OS_TaskExit(void) { - sl_thd_free(sl_thd_curr()); - PANIC("Should be unreachable!"); + sl_thd_free(sl_thd_curr()); + PANIC("Should be unreachable!"); } -int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer) +int32 +OS_TaskInstallDeleteHandler(osal_task_entry function_pointer) { - if(OS_TaskGetId() == main_delegate_thread_id) { - return OS_ERR_INVALID_ID; - } - sl_mod_thd_policy_get(sl_thd_curr())->delete_handler = function_pointer; - return OS_SUCCESS; + if (OS_TaskGetId() == main_delegate_thread_id) { return OS_ERR_INVALID_ID; } + sl_mod_thd_policy_get(sl_thd_curr())->delete_handler = function_pointer; + return OS_SUCCESS; } -int32 OS_TaskDelay(uint32 millisecond) +int32 +OS_TaskDelay(uint32 millisecond) { - cycles_t wakeup = sl_now() + sl_usec2cyc(millisecond * 1000); - sl_thd_block_timeout(0, wakeup); - return OS_SUCCESS; + cycles_t wakeup = sl_now() + sl_usec2cyc(millisecond * 1000); + sl_thd_block_timeout(0, wakeup); + return OS_SUCCESS; } -int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) +int32 +OS_TaskSetPriority(uint32 task_id, uint32 new_priority) { - if(new_priority > 255 || new_priority < 1) { - return OS_ERR_INVALID_PRIORITY; - } + if (new_priority > 255 || new_priority < 1) { return OS_ERR_INVALID_PRIORITY; } - struct sl_thd* thd = sl_thd_lkup(task_id); - if(!thd) { - return OS_ERR_INVALID_ID; - } + struct sl_thd *thd = sl_thd_lkup(task_id); + if (!thd) { return OS_ERR_INVALID_ID; } - union sched_param_union sp = {.c = {.type = SCHEDP_PRIO, .value = new_priority}}; - sl_thd_param_set(thd, sp.v); + union sched_param_union sp = {.c = {.type = SCHEDP_PRIO, .value = new_priority}}; + sl_thd_param_set(thd, sp.v); - return OS_SUCCESS; + return OS_SUCCESS; } -int32 OS_TaskRegister(void) +int32 +OS_TaskRegister(void) { - if(OS_TaskGetId() == main_delegate_thread_id) { - return OS_ERR_INVALID_ID; - } + if (OS_TaskGetId() == main_delegate_thread_id) { return OS_ERR_INVALID_ID; } - // Think it is safe for this to do nothing - return OS_SUCCESS; + return OS_SUCCESS; } -int32 OS_TaskGetIdByName(uint32 *task_id, const char *task_name) +int32 +OS_TaskGetIdByName(uint32 *task_id, const char *task_name) { - // FIXME: Implement this. Left as is so unit tests pass - return OS_ERR_NOT_IMPLEMENTED; + // FIXME: Implement this + return OS_ERR_NOT_IMPLEMENTED; } -int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) +int32 +OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) { - if(!task_prop) { - return OS_INVALID_POINTER; - } + if (!task_prop) { return OS_INVALID_POINTER; } - struct sl_thd* thd = sl_thd_lkup(task_id); - // TODO: Fix this ugly workaround - if (!thd || thd->state == SL_THD_FREE) { - return OS_ERR_INVALID_ID; - } - struct sl_thd_policy* thd_policy = sl_mod_thd_policy_get(thd); - assert(thd_policy); + struct sl_thd *thd = sl_thd_lkup(task_id); + // TODO: Fix this ugly workaround + if (!thd || thd->state == SL_THD_FREE) { return OS_ERR_INVALID_ID; } + struct sl_thd_policy *thd_policy = sl_mod_thd_policy_get(thd); + assert(thd_policy); - *task_prop = thd_policy->osal_task_prop; - return OS_SUCCESS; + *task_prop = thd_policy->osal_task_prop; + return OS_SUCCESS; } /* @@ -247,9 +227,10 @@ int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) ** This should be called from the BSP main routine / initial thread after all other ** board / application initialization has taken place and all other tasks are running. */ -void OS_IdleLoop(void) +void +OS_IdleLoop(void) { - while(1) sl_thd_block(0); + while (1) sl_thd_block(0); } /* @@ -258,9 +239,10 @@ void OS_IdleLoop(void) ** This is preferred over e.g. ApplicationExit() which exits immediately and does not ** provide for any means to clean up first. */ -void OS_ApplicationShutdown(uint8 flag) +void +OS_ApplicationShutdown(uint8 flag) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* @@ -268,174 +250,177 @@ void OS_ApplicationShutdown(uint8 flag) */ struct mutex { - int used; - struct sl_lock lock; - OS_mut_sem_prop_t prop; + int used; + struct sl_lock lock; + OS_mut_sem_prop_t prop; }; struct sl_lock mutex_data_lock = SL_LOCK_STATIC_INIT(); -struct mutex mutexes[OS_MAX_MUTEXES]; +struct mutex mutexes[OS_MAX_MUTEXES]; -int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) +int32 +OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) { - int32 result = OS_SUCCESS; + int32 result = OS_SUCCESS; - sl_lock_take(&mutex_data_lock); + sl_lock_take(&mutex_data_lock); - if (sem_id == NULL || sem_name == NULL) { - result = OS_INVALID_POINTER; - goto exit; - } + if (sem_id == NULL || sem_name == NULL) { + result = OS_INVALID_POINTER; + goto exit; + } - if (!is_valid_name(sem_name)) { - result = OS_ERR_NAME_TOO_LONG; - goto exit; - } + if (!is_valid_name(sem_name)) { + result = OS_ERR_NAME_TOO_LONG; + goto exit; + } - uint32 id; - for (id = 0; id < OS_MAX_MUTEXES; id++) { - if (mutexes[id].used && strcmp(sem_name, mutexes[id].prop.name) == 0) { - result = OS_ERR_NAME_TAKEN; - goto exit; - } - } + uint32 id; + for (id = 0; id < OS_MAX_MUTEXES; id++) { + if (mutexes[id].used && strcmp(sem_name, mutexes[id].prop.name) == 0) { + result = OS_ERR_NAME_TAKEN; + goto exit; + } + } - for (id = 0; id < OS_MAX_MUTEXES; id++) { - if(!mutexes[id].used) { - break; - } - } - if (id >= OS_MAX_MUTEXES || mutexes[id].used) { - result = OS_ERR_NO_FREE_IDS; - goto exit; - } + for (id = 0; id < OS_MAX_MUTEXES; id++) { + if (!mutexes[id].used) { break; } + } + if (id >= OS_MAX_MUTEXES || mutexes[id].used) { + result = OS_ERR_NO_FREE_IDS; + goto exit; + } - *sem_id = id; + *sem_id = id; - mutexes[id].used = TRUE; - sl_lock_init(&mutexes[id].lock); - mutexes[id].prop.creator = sl_thdid(); - strcpy(mutexes[id].prop.name, sem_name); + mutexes[id].used = TRUE; + sl_lock_init(&mutexes[id].lock); + mutexes[id].prop.creator = sl_thdid(); + strcpy(mutexes[id].prop.name, sem_name); exit: - sl_lock_release(&mutex_data_lock); - return result; + sl_lock_release(&mutex_data_lock); + return result; } -int32 OS_MutSemGive(uint32 sem_id) +int32 +OS_MutSemGive(uint32 sem_id) { - int32 result = OS_SUCCESS; + int32 result = OS_SUCCESS; - sl_lock_take(&mutex_data_lock); + sl_lock_take(&mutex_data_lock); - if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { - result = OS_ERR_INVALID_ID; - goto exit; - } + if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } - sl_lock_release(&mutexes[sem_id].lock); + sl_lock_release(&mutexes[sem_id].lock); exit: - sl_lock_release(&mutex_data_lock); + sl_lock_release(&mutex_data_lock); - return result; + return result; } -int32 OS_MutSemTake(uint32 sem_id) +int32 +OS_MutSemTake(uint32 sem_id) { - int32 result = OS_SUCCESS; + int32 result = OS_SUCCESS; - sl_lock_take(&mutex_data_lock); + sl_lock_take(&mutex_data_lock); - if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { - result = OS_ERR_INVALID_ID; - goto exit; - } + if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } - sl_lock_take(&mutexes[sem_id].lock); + sl_lock_take(&mutexes[sem_id].lock); exit: - sl_lock_release(&mutex_data_lock); + sl_lock_release(&mutex_data_lock); - return result; + return result; } -int32 OS_MutSemDelete(uint32 sem_id) +int32 +OS_MutSemDelete(uint32 sem_id) { - int32 result = OS_SUCCESS; - sl_lock_take(&mutex_data_lock); + int32 result = OS_SUCCESS; + sl_lock_take(&mutex_data_lock); - if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { - result = OS_ERR_INVALID_ID; - goto exit; - } + if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } - if (sl_lock_holder(&mutexes[sem_id].lock) != 0) { - result = OS_SEM_FAILURE; - goto exit; - } + if (sl_lock_holder(&mutexes[sem_id].lock) != 0) { + result = OS_SEM_FAILURE; + goto exit; + } - mutexes[sem_id].used = FALSE; + mutexes[sem_id].used = FALSE; - exit: - sl_lock_release(&mutex_data_lock); - return result; +exit: + sl_lock_release(&mutex_data_lock); + return result; } -int32 OS_MutSemGetIdByName(uint32 *sem_id, const char *sem_name) +int32 +OS_MutSemGetIdByName(uint32 *sem_id, const char *sem_name) { - int32 result = OS_SUCCESS; + int32 result = OS_SUCCESS; - sl_lock_take(&mutex_data_lock); + sl_lock_take(&mutex_data_lock); - if (sem_id == NULL || sem_name == NULL) { - result = OS_INVALID_POINTER; - goto exit; - } + if (sem_id == NULL || sem_name == NULL) { + result = OS_INVALID_POINTER; + goto exit; + } - if (strlen(sem_name) >= OS_MAX_API_NAME) { - result = OS_ERR_NAME_TOO_LONG; - goto exit; - } + if (strlen(sem_name) >= OS_MAX_API_NAME) { + result = OS_ERR_NAME_TOO_LONG; + goto exit; + } - int i; - for (i = 0; i < OS_MAX_MUTEXES; i++) { - if (mutexes[i].used && (strcmp (mutexes[i].prop.name, (char*) sem_name) == 0)) { - *sem_id = i; - goto exit; - } - } + int i; + for (i = 0; i < OS_MAX_MUTEXES; i++) { + if (mutexes[i].used && (strcmp(mutexes[i].prop.name, (char *)sem_name) == 0)) { + *sem_id = i; + goto exit; + } + } - /* The name was not found in the table, - * or it was, and the sem_id isn't valid anymore */ - result = OS_ERR_NAME_NOT_FOUND; + /* The name was not found in the table, + * or it was, and the sem_id isn't valid anymore */ + result = OS_ERR_NAME_NOT_FOUND; exit: - sl_lock_release(&mutex_data_lock); - return result; + sl_lock_release(&mutex_data_lock); + return result; } -int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) +int32 +OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) { - int32 result = OS_SUCCESS; - sl_lock_take(&mutex_data_lock); + int32 result = OS_SUCCESS; + sl_lock_take(&mutex_data_lock); - if(!mut_prop) - { - result = OS_INVALID_POINTER; - goto exit; - } + if (!mut_prop) { + result = OS_INVALID_POINTER; + goto exit; + } - if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { - result = OS_ERR_INVALID_ID; - goto exit; - } + if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } - *mut_prop = mutexes[sem_id].prop; + *mut_prop = mutexes[sem_id].prop; exit: - sl_lock_release(&mutex_data_lock); - return result; + sl_lock_release(&mutex_data_lock); + return result; } /* @@ -443,369 +428,367 @@ int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) */ struct semaphore { - int used; + int used; - uint32 count; - int epoch; - uint32 creator; - char name[OS_MAX_API_NAME]; + uint32 count; + int epoch; + uint32 creator; + char name[OS_MAX_API_NAME]; }; -struct sl_lock semaphore_data_lock = SL_LOCK_STATIC_INIT(); +struct sl_lock semaphore_data_lock = SL_LOCK_STATIC_INIT(); struct semaphore binary_semaphores[OS_MAX_BIN_SEMAPHORES]; struct semaphore counting_semaphores[OS_MAX_COUNT_SEMAPHORES]; // Generic semaphore methods -int32 OS_SemaphoreCreate(struct semaphore* semaphores, uint32 max_semaphores, - uint32 *sem_id, const char *sem_name, - uint32 sem_initial_value, uint32 options) -{ - int32 result = OS_SUCCESS; - - sl_lock_take(&semaphore_data_lock); - - if (sem_id == NULL || sem_name == NULL) { - result = OS_INVALID_POINTER; - goto exit; - } - - if (!is_valid_name(sem_name)) { - result = OS_ERR_NAME_TOO_LONG; - goto exit; - } - - uint32 id; - for (id = 0; id < max_semaphores; id++) { - if (semaphores[id].used && strcmp(sem_name, semaphores[id].name) == 0) { - result = OS_ERR_NAME_TAKEN; - goto exit; - } - } - - for (id = 0; id < max_semaphores; id++) { - if(!semaphores[id].used) { - break; - } - } - - if (id >= max_semaphores || semaphores[id].used) { - result = OS_ERR_NO_FREE_IDS; - goto exit; - } - - *sem_id = id; - semaphores[id].used = TRUE; - semaphores[id].creator = sl_thdid(); - semaphores[id].count = sem_initial_value; - strcpy(semaphores[id].name, sem_name); +int32 +OS_SemaphoreCreate(struct semaphore *semaphores, uint32 max_semaphores, uint32 *sem_id, const char *sem_name, + uint32 sem_initial_value, uint32 options) +{ + int32 result = OS_SUCCESS; + + sl_lock_take(&semaphore_data_lock); + + if (sem_id == NULL || sem_name == NULL) { + result = OS_INVALID_POINTER; + goto exit; + } + + if (!is_valid_name(sem_name)) { + result = OS_ERR_NAME_TOO_LONG; + goto exit; + } + + uint32 id; + for (id = 0; id < max_semaphores; id++) { + if (semaphores[id].used && strcmp(sem_name, semaphores[id].name) == 0) { + result = OS_ERR_NAME_TAKEN; + goto exit; + } + } + + for (id = 0; id < max_semaphores; id++) { + if (!semaphores[id].used) { break; } + } + + if (id >= max_semaphores || semaphores[id].used) { + result = OS_ERR_NO_FREE_IDS; + goto exit; + } + + *sem_id = id; + semaphores[id].used = TRUE; + semaphores[id].creator = sl_thdid(); + semaphores[id].count = sem_initial_value; + strcpy(semaphores[id].name, sem_name); exit: - sl_lock_release(&semaphore_data_lock); - return result; + sl_lock_release(&semaphore_data_lock); + return result; } -int32 OS_SemaphoreFlush(struct semaphore* semaphores, uint32 max_semaphores, uint32 sem_id) +int32 +OS_SemaphoreFlush(struct semaphore *semaphores, uint32 max_semaphores, uint32 sem_id) { + int32 result = OS_SUCCESS; - int32 result = OS_SUCCESS; + sl_lock_take(&semaphore_data_lock); - sl_lock_take(&semaphore_data_lock); - - if (sem_id >= max_semaphores || !semaphores[sem_id].used) { - result = OS_ERR_INVALID_ID; - goto exit; - } + if (sem_id >= max_semaphores || !semaphores[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } - semaphores[sem_id].epoch += 1; + semaphores[sem_id].epoch += 1; exit: - sl_lock_release(&semaphore_data_lock); - return result; + sl_lock_release(&semaphore_data_lock); + return result; } -int32 OS_SemaphoreGive(struct semaphore* semaphores, uint32 max_semaphores, uint32 sem_id) +int32 +OS_SemaphoreGive(struct semaphore *semaphores, uint32 max_semaphores, uint32 sem_id) { - int32 result = OS_SUCCESS; + int32 result = OS_SUCCESS; - sl_lock_take(&semaphore_data_lock); + sl_lock_take(&semaphore_data_lock); - if (sem_id >= max_semaphores || !semaphores[sem_id].used) { - result = OS_ERR_INVALID_ID; - goto exit; - } + if (sem_id >= max_semaphores || !semaphores[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } - // FIXME: Add some checks that the semaphore was actually taken by this thread - semaphores[sem_id].count += 1; + // FIXME: Add some checks that the semaphore was actually taken by this thread + semaphores[sem_id].count += 1; exit: - sl_lock_release(&semaphore_data_lock); - return result; - + sl_lock_release(&semaphore_data_lock); + return result; } -int32 OS_SemaphoreTake(struct semaphore* semaphores, uint32 max_semaphores, uint32 sem_id) +int32 +OS_SemaphoreTake(struct semaphore *semaphores, uint32 max_semaphores, uint32 sem_id) { - int32 result = OS_SUCCESS; + int32 result = OS_SUCCESS; - sl_lock_take(&semaphore_data_lock); + sl_lock_take(&semaphore_data_lock); - if (sem_id >= max_semaphores) { - result = OS_ERR_INVALID_ID; - goto exit; - } + if (sem_id >= max_semaphores) { + result = OS_ERR_INVALID_ID; + goto exit; + } - int starting_epoch = semaphores[sem_id].epoch; + int starting_epoch = semaphores[sem_id].epoch; - while (semaphores[sem_id].used && semaphores[sem_id].count == 0) { - if(semaphores[sem_id].epoch != starting_epoch) { - goto exit; - } - sl_lock_release(&semaphore_data_lock); + while (semaphores[sem_id].used && semaphores[sem_id].count == 0) { + if (semaphores[sem_id].epoch != starting_epoch) { goto exit; } + sl_lock_release(&semaphore_data_lock); - // TODO: Do something smarter than blocking for 3 millisecond - cycles_t timeout = sl_now() + sl_usec2cyc(3 * 1000); - sl_thd_block_timeout(0, timeout); + // TODO: Do something smarter than blocking for 3 millisecond + cycles_t timeout = sl_now() + sl_usec2cyc(3 * 1000); + sl_thd_block_timeout(0, timeout); - sl_lock_take(&semaphore_data_lock); - } + sl_lock_take(&semaphore_data_lock); + } - if (!semaphores[sem_id].used) { - result = OS_ERR_INVALID_ID; - goto exit; - } + if (!semaphores[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } - semaphores[sem_id].count -= 1; + semaphores[sem_id].count -= 1; exit: - sl_lock_release(&semaphore_data_lock); - return result; + sl_lock_release(&semaphore_data_lock); + return result; } -int32 OS_SemaphoreTimedWait(struct semaphore* semaphores, uint32 max_semaphores, - uint32 sem_id, uint32 msecs) +int32 +OS_SemaphoreTimedWait(struct semaphore *semaphores, uint32 max_semaphores, uint32 sem_id, uint32 msecs) { - int32 result = OS_SUCCESS; - microsec_t start_time = sl_now(); - microsec_t max_wait = msecs * 1000; + int32 result = OS_SUCCESS; + microsec_t start_time = sl_now(); + microsec_t max_wait = msecs * 1000; - sl_lock_take(&semaphore_data_lock); + sl_lock_take(&semaphore_data_lock); - if (sem_id >= max_semaphores) { - result = OS_ERR_INVALID_ID; - goto exit; - } + if (sem_id >= max_semaphores) { + result = OS_ERR_INVALID_ID; + goto exit; + } - while (semaphores[sem_id].used - && semaphores[sem_id].count == 0 - && (sl_now_usec() - start_time) < max_wait) { - sl_lock_release(&semaphore_data_lock); - // TODO: Do something smarter than blocking for 3 milliseconds - cycles_t timeout = sl_now() + sl_usec2cyc(3 * 1000); - sl_thd_block_timeout(0, timeout); - sl_lock_take(&semaphore_data_lock); - } + while (semaphores[sem_id].used && semaphores[sem_id].count == 0 && (sl_now_usec() - start_time) < max_wait) { + sl_lock_release(&semaphore_data_lock); + // TODO: Do something smarter than blocking for 3 milliseconds + cycles_t timeout = sl_now() + sl_usec2cyc(3 * 1000); + sl_thd_block_timeout(0, timeout); + sl_lock_take(&semaphore_data_lock); + } - if (!semaphores[sem_id].used) { - result = OS_ERR_INVALID_ID; - goto exit; - } + if (!semaphores[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } - if (semaphores[sem_id].count == 0) { - result = OS_SEM_TIMEOUT; - goto exit; - } + if (semaphores[sem_id].count == 0) { + result = OS_SEM_TIMEOUT; + goto exit; + } - semaphores[sem_id].count -= 1; + semaphores[sem_id].count -= 1; exit: - sl_lock_release(&semaphore_data_lock); + sl_lock_release(&semaphore_data_lock); - return result; + return result; } -int32 OS_SemaphoreDelete(struct semaphore* semaphores, uint32 max_semaphores, - uint32 sem_id) +int32 +OS_SemaphoreDelete(struct semaphore *semaphores, uint32 max_semaphores, uint32 sem_id) { - int32 result = OS_SUCCESS; - sl_lock_take(&semaphore_data_lock); + int32 result = OS_SUCCESS; + sl_lock_take(&semaphore_data_lock); - if (sem_id >= max_semaphores || !semaphores[sem_id].used) { - result = OS_ERR_INVALID_ID; - goto exit; - } + if (sem_id >= max_semaphores || !semaphores[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } - semaphores[sem_id].used = FALSE; + semaphores[sem_id].used = FALSE; - exit: - sl_lock_release(&semaphore_data_lock); +exit: + sl_lock_release(&semaphore_data_lock); - return result; + return result; } -int32 OS_SemaphoreGetIdByName(struct semaphore* semaphores, uint32 max_semaphores, - uint32 *sem_id, const char *sem_name) +int32 +OS_SemaphoreGetIdByName(struct semaphore *semaphores, uint32 max_semaphores, uint32 *sem_id, const char *sem_name) { - int32 result = OS_SUCCESS; + int32 result = OS_SUCCESS; - sl_lock_take(&semaphore_data_lock); + sl_lock_take(&semaphore_data_lock); - if (sem_id == NULL || sem_name == NULL) { - result = OS_INVALID_POINTER; - goto exit; - } + if (sem_id == NULL || sem_name == NULL) { + result = OS_INVALID_POINTER; + goto exit; + } - if (!is_valid_name(sem_name)) { - result = OS_ERR_NAME_TOO_LONG; - goto exit; - } + if (!is_valid_name(sem_name)) { + result = OS_ERR_NAME_TOO_LONG; + goto exit; + } - uint32 i; - for (i = 0; i < max_semaphores; i++) { - if (semaphores[i].used && (strcmp(semaphores[i].name, (char*) sem_name) == 0)) { - *sem_id = i; - goto exit; - } - } + uint32 i; + for (i = 0; i < max_semaphores; i++) { + if (semaphores[i].used && (strcmp(semaphores[i].name, (char *)sem_name) == 0)) { + *sem_id = i; + goto exit; + } + } - /* The name was not found in the table, - * or it was, and the sem_id isn't valid anymore */ - result = OS_ERR_NAME_NOT_FOUND; + /* The name was not found in the table, + * or it was, and the sem_id isn't valid anymore */ + result = OS_ERR_NAME_NOT_FOUND; exit: - sl_lock_release(&semaphore_data_lock); - return result; + sl_lock_release(&semaphore_data_lock); + return result; } - // Binary semaphore methods -int32 OS_BinSemCreate(uint32 *sem_id, const char *sem_name, - uint32 sem_initial_value, uint32 options) +int32 +OS_BinSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { - return OS_SemaphoreCreate(binary_semaphores, OS_MAX_BIN_SEMAPHORES, - sem_id, sem_name, sem_initial_value, options); + return OS_SemaphoreCreate(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id, sem_name, sem_initial_value, + options); } -int32 OS_BinSemFlush(uint32 sem_id) +int32 +OS_BinSemFlush(uint32 sem_id) { - return OS_SemaphoreFlush(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id); + return OS_SemaphoreFlush(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id); } -int32 OS_BinSemGive(uint32 sem_id) +int32 +OS_BinSemGive(uint32 sem_id) { - return OS_SemaphoreGive(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id); + return OS_SemaphoreGive(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id); } -int32 OS_BinSemTake(uint32 sem_id) +int32 +OS_BinSemTake(uint32 sem_id) { - return OS_SemaphoreTake(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id); + return OS_SemaphoreTake(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id); } -int32 OS_BinSemTimedWait(uint32 sem_id, uint32 msecs) +int32 +OS_BinSemTimedWait(uint32 sem_id, uint32 msecs) { - return OS_SemaphoreTimedWait(binary_semaphores, OS_MAX_BIN_SEMAPHORES, - sem_id, msecs); + return OS_SemaphoreTimedWait(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id, msecs); } -int32 OS_BinSemDelete(uint32 sem_id) +int32 +OS_BinSemDelete(uint32 sem_id) { - return OS_SemaphoreDelete(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id); + return OS_SemaphoreDelete(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id); } -int32 OS_BinSemGetIdByName(uint32 *sem_id, const char *sem_name) +int32 +OS_BinSemGetIdByName(uint32 *sem_id, const char *sem_name) { - return OS_SemaphoreGetIdByName(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id, sem_name); + return OS_SemaphoreGetIdByName(binary_semaphores, OS_MAX_BIN_SEMAPHORES, sem_id, sem_name); } -int32 OS_BinSemGetInfo(uint32 sem_id, OS_bin_sem_prop_t *bin_prop) +int32 +OS_BinSemGetInfo(uint32 sem_id, OS_bin_sem_prop_t *bin_prop) { - int32 result = OS_SUCCESS; - sl_lock_take(&semaphore_data_lock); + int32 result = OS_SUCCESS; + sl_lock_take(&semaphore_data_lock); - if(!bin_prop) - { - result = OS_INVALID_POINTER; - goto exit; - } + if (!bin_prop) { + result = OS_INVALID_POINTER; + goto exit; + } - if (sem_id >= OS_MAX_BIN_SEMAPHORES || !binary_semaphores[sem_id].used) { - result = OS_ERR_INVALID_ID; - goto exit; - } + if (sem_id >= OS_MAX_BIN_SEMAPHORES || !binary_semaphores[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } - *bin_prop = (OS_bin_sem_prop_t) { - .creator = binary_semaphores[sem_id].creator, - .value = binary_semaphores[sem_id].count - }; + *bin_prop = (OS_bin_sem_prop_t){.creator = binary_semaphores[sem_id].creator, + .value = binary_semaphores[sem_id].count}; - strcpy(bin_prop->name, binary_semaphores[sem_id].name); + strcpy(bin_prop->name, binary_semaphores[sem_id].name); exit: - sl_lock_release(&semaphore_data_lock); - return result; + sl_lock_release(&semaphore_data_lock); + return result; } -int32 OS_CountSemCreate(uint32 *sem_id, const char *sem_name, - uint32 sem_initial_value, uint32 options) +int32 +OS_CountSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { - return OS_SemaphoreCreate(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, - sem_id, sem_name, sem_initial_value, options); + return OS_SemaphoreCreate(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, sem_id, sem_name, sem_initial_value, + options); } -int32 OS_CountSemGive(uint32 sem_id) +int32 +OS_CountSemGive(uint32 sem_id) { - return OS_SemaphoreGive(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, sem_id); + return OS_SemaphoreGive(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, sem_id); } -int32 OS_CountSemTake(uint32 sem_id) +int32 +OS_CountSemTake(uint32 sem_id) { - return OS_SemaphoreTake(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, sem_id); + return OS_SemaphoreTake(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, sem_id); } -int32 OS_CountSemTimedWait(uint32 sem_id, uint32 msecs) +int32 +OS_CountSemTimedWait(uint32 sem_id, uint32 msecs) { - return OS_SemaphoreTimedWait(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, - sem_id, msecs); + return OS_SemaphoreTimedWait(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, sem_id, msecs); } -int32 OS_CountSemDelete(uint32 sem_id) +int32 +OS_CountSemDelete(uint32 sem_id) { - return OS_SemaphoreDelete(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, sem_id); + return OS_SemaphoreDelete(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, sem_id); } -int32 OS_CountSemGetIdByName(uint32 *sem_id, const char *sem_name) +int32 +OS_CountSemGetIdByName(uint32 *sem_id, const char *sem_name) { - return OS_SemaphoreGetIdByName(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, - sem_id, sem_name); + return OS_SemaphoreGetIdByName(counting_semaphores, OS_MAX_COUNT_SEMAPHORES, sem_id, sem_name); } -int32 OS_CountSemGetInfo(uint32 sem_id, OS_count_sem_prop_t *count_prop) +int32 +OS_CountSemGetInfo(uint32 sem_id, OS_count_sem_prop_t *count_prop) { - int32 result = OS_SUCCESS; - sl_lock_take(&semaphore_data_lock); + int32 result = OS_SUCCESS; + sl_lock_take(&semaphore_data_lock); - if(!count_prop) - { - result = OS_INVALID_POINTER; - goto exit; - } + if (!count_prop) { + result = OS_INVALID_POINTER; + goto exit; + } - if (sem_id >= OS_MAX_COUNT_SEMAPHORES || !counting_semaphores[sem_id].used) { - result = OS_ERR_INVALID_ID; - goto exit; - } + if (sem_id >= OS_MAX_COUNT_SEMAPHORES || !counting_semaphores[sem_id].used) { + result = OS_ERR_INVALID_ID; + goto exit; + } - *count_prop = (OS_count_sem_prop_t) { - .creator = counting_semaphores[sem_id].creator, - .value = counting_semaphores[sem_id].count - }; + *count_prop = (OS_count_sem_prop_t){.creator = counting_semaphores[sem_id].creator, + .value = counting_semaphores[sem_id].count}; - strcpy(count_prop->name, counting_semaphores[sem_id].name); + strcpy(count_prop->name, counting_semaphores[sem_id].name); exit: - sl_lock_release(&semaphore_data_lock); + sl_lock_release(&semaphore_data_lock); - return result; + return result; } diff --git a/src/components/implementation/no_interface/cFE_booter/ostimer.c b/src/components/implementation/no_interface/cFE_booter/ostimer.c index fe5a72ccb2..372994cfb5 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostimer.c +++ b/src/components/implementation/no_interface/cFE_booter/ostimer.c @@ -7,67 +7,79 @@ ** Timer API */ -int32 OS_TimerAPIInit(void) +int32 +OS_TimerAPIInit(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } // TODO: Verify this API really insn't necessary -int32 OS_TimeBaseCreate(uint32 *timer_id, const char *timebase_name, OS_TimerSync_t external_sync) +int32 +OS_TimeBaseCreate(uint32 *timer_id, const char *timebase_name, OS_TimerSync_t external_sync) { - return OS_ERR_NOT_IMPLEMENTED; + return OS_ERR_NOT_IMPLEMENTED; } -int32 OS_TimeBaseSet(uint32 timer_id, uint32 start_time, uint32 interval_time) +int32 +OS_TimeBaseSet(uint32 timer_id, uint32 start_time, uint32 interval_time) { - return OS_ERR_NOT_IMPLEMENTED; + return OS_ERR_NOT_IMPLEMENTED; } -int32 OS_TimeBaseDelete(uint32 timer_id) +int32 +OS_TimeBaseDelete(uint32 timer_id) { - return OS_ERR_NOT_IMPLEMENTED; + return OS_ERR_NOT_IMPLEMENTED; } -int32 OS_TimeBaseGetIdByName (uint32 *timer_id, const char *timebase_name) +int32 +OS_TimeBaseGetIdByName(uint32 *timer_id, const char *timebase_name) { - return OS_ERR_NOT_IMPLEMENTED; + return OS_ERR_NOT_IMPLEMENTED; } -int32 OS_TimerCreate(uint32 *timer_id, const char *timer_name, uint32 *clock_accuracy, OS_TimerCallback_t callback_ptr) +int32 +OS_TimerCreate(uint32 *timer_id, const char *timer_name, uint32 *clock_accuracy, OS_TimerCallback_t callback_ptr) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_TimerAdd(uint32 *timer_id, const char *timer_name, uint32 timebase_id, OS_ArgCallback_t callback_ptr, void *callback_arg) +int32 +OS_TimerAdd(uint32 *timer_id, const char *timer_name, uint32 timebase_id, OS_ArgCallback_t callback_ptr, + void *callback_arg) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_TimerSet(uint32 timer_id, uint32 start_time, uint32 interval_time) +int32 +OS_TimerSet(uint32 timer_id, uint32 start_time, uint32 interval_time) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_TimerDelete(uint32 timer_id) +int32 +OS_TimerDelete(uint32 timer_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_TimerGetIdByName(uint32 *timer_id, const char *timer_name) +int32 +OS_TimerGetIdByName(uint32 *timer_id, const char *timer_name) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } -int32 OS_TimerGetInfo(uint32 timer_id, OS_timer_prop_t *timer_prop) +int32 +OS_TimerGetInfo(uint32 timer_id, OS_timer_prop_t *timer_prop) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c index de311f571e..7fc914194c 100644 --- a/src/components/implementation/no_interface/cFE_booter/psp.c +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -17,18 +17,18 @@ * Define the PSP-supported capacities to be the maximum allowed, * (since the PC-linux PSP has the advantage of abundant disk space to hold this) */ -#define CFE_PSP_CDS_SIZE (GLOBAL_CONFIGDATA.CfeConfig->CdsSize) -#define CFE_PSP_RESET_AREA_SIZE (GLOBAL_CONFIGDATA.CfeConfig->ResetAreaSize) -#define CFE_PSP_USER_RESERVED_SIZE (GLOBAL_CONFIGDATA.CfeConfig->UserReservedSize) +#define CFE_PSP_CDS_SIZE (GLOBAL_CONFIGDATA.CfeConfig->CdsSize) +#define CFE_PSP_RESET_AREA_SIZE (GLOBAL_CONFIGDATA.CfeConfig->ResetAreaSize) +#define CFE_PSP_USER_RESERVED_SIZE (GLOBAL_CONFIGDATA.CfeConfig->UserReservedSize) #else -#include "gen/cfe_es.h" /* For memory sizes */ -#include "gen/cfe_platform_cfg.h" /* for processor ID */ +#include "gen/cfe_es.h" /* For memory sizes */ +#include "gen/cfe_platform_cfg.h" /* for processor ID */ -#define CFE_PSP_CDS_SIZE (CFE_ES_CDS_SIZE + 1024) -#define CFE_PSP_RESET_AREA_SIZE CFE_ES_RESET_AREA_SIZE -#define CFE_PSP_USER_RESERVED_SIZE CFE_ES_USER_RESERVED_SIZE +#define CFE_PSP_CDS_SIZE (CFE_ES_CDS_SIZE + 1024) +#define CFE_PSP_RESET_AREA_SIZE CFE_ES_RESET_AREA_SIZE +#define CFE_PSP_USER_RESERVED_SIZE CFE_ES_USER_RESERVED_SIZE #endif @@ -40,9 +40,10 @@ /* ** PSP entry point and reset routines */ -void CFE_PSP_Main(uint32 ModeId, char *StartupFilePath) +void +CFE_PSP_Main(uint32 ModeId, char *StartupFilePath) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* @@ -52,18 +53,20 @@ void CFE_PSP_Main(uint32 ModeId, char *StartupFilePath) ** The flight software (i.e. cFE ) should not call this routine. */ -void CFE_PSP_GetTime(OS_time_t *LocalTime) +void +CFE_PSP_GetTime(OS_time_t *LocalTime) { - OS_GetLocalTime(LocalTime); + OS_GetLocalTime(LocalTime); } /* This call gets the local time from the hardware on the Vxworks system * on the mcp750s * on the other os/hardware setup, it will get the time the normal way */ -void CFE_PSP_Restart(uint32 resetType) +void +CFE_PSP_Restart(uint32 resetType) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_Restart is the entry point back to the BSP to restart the processor. @@ -71,10 +74,11 @@ void CFE_PSP_Restart(uint32 resetType) */ -uint32 CFE_PSP_GetRestartType(uint32 *restartSubType ) +uint32 +CFE_PSP_GetRestartType(uint32 *restartSubType) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } /* ** CFE_PSP_GetRestartType returns the last reset type and if a pointer to a valid @@ -89,9 +93,10 @@ void CFE_PSP_FlushCaches(uint32 type, cpuaddr address, uint32 size); ** This is a BSP specific cache flush routine */ -uint32 CFE_PSP_GetProcessorId(void) +uint32 +CFE_PSP_GetProcessorId(void) { - return CFE_PSP_CpuId; + return CFE_PSP_CpuId; } /* ** CFE_PSP_GetProcessorId returns the CPU ID as defined by the specific board @@ -99,29 +104,32 @@ uint32 CFE_PSP_GetProcessorId(void) */ -uint32 CFE_PSP_GetSpacecraftId(void) +uint32 +CFE_PSP_GetSpacecraftId(void) { - return CFE_PSP_SpacecraftId; + return CFE_PSP_SpacecraftId; } /* ** CFE_PSP_GetSpacecraftId retuns the Spacecraft ID (if any ) */ -uint32 CFE_PSP_Get_Timer_Tick(void) +uint32 +CFE_PSP_Get_Timer_Tick(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } /* ** CFE_PSP_Get_Timer_Tick returns the underlying OS timer tick value ** It is used for the performance monitoring software */ -uint32 CFE_PSP_GetTimerTicksPerSecond(void) +uint32 +CFE_PSP_GetTimerTicksPerSecond(void) { - // (usec / sec) / (usec / tick) - return 1000000 / SL_MIN_PERIOD_US; + // (usec / sec) / (usec / tick) + return 1000000 / SL_MIN_PERIOD_US; } /* @@ -131,11 +139,12 @@ uint32 CFE_PSP_GetTimerTicksPerSecond(void) ** than 1000000 ticks per second or 1 us per tick */ -uint32 CFE_PSP_GetTimerLow32Rollover(void) +uint32 +CFE_PSP_GetTimerLow32Rollover(void) { - // This is a pessimistic assumption - // TODO: Figure out if we can be more optimistic - return 1000000; + // This is a pessimistic assumption + // TODO: Figure out if we can be more optimistic + return 1000000; } /* ** CFE_PSP_GetTimerLow32Rollover provides the number that the least significant @@ -145,29 +154,32 @@ uint32 CFE_PSP_GetTimerLow32Rollover(void) ** CFE_PSP_TIMER_LOW32_ROLLOVER will be 0. */ -void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32 *Tbl) +void +CFE_PSP_Get_Timebase(uint32 *Tbu, uint32 *Tbl) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_Get_Timebase */ -uint32 CFE_PSP_Get_Dec(void) +uint32 +CFE_PSP_Get_Dec(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } /* ** CFE_PSP_Get_Dec */ -int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType) +int32 +CFE_PSP_InitProcessorReservedMemory(uint32 RestartType) { - // Since all operations on reserved memory are unimplemented, it's safe to - // do nothing here - return 0; + // Since all operations on reserved memory are unimplemented, it's safe to + // do nothing here + return 0; } /* ** CFE_PSP_InitProcessorReservedMemory initializes all of the memory in the @@ -179,41 +191,38 @@ int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType) char CDS_MEMORY[CFE_ES_CDS_SIZE]; -int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS) +int32 +CFE_PSP_GetCDSSize(uint32 *SizeOfCDS) { - if (!SizeOfCDS) { - return CFE_PSP_ERROR; - } - *SizeOfCDS = CFE_ES_CDS_SIZE; - return CFE_PSP_SUCCESS; + if (!SizeOfCDS) { return CFE_PSP_ERROR; } + *SizeOfCDS = CFE_ES_CDS_SIZE; + return CFE_PSP_SUCCESS; } /* ** CFE_PSP_GetCDSSize fetches the size of the OS Critical Data Store area. */ -int32 CFE_PSP_WriteToCDS(void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumBytes) +int32 +CFE_PSP_WriteToCDS(void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumBytes) { - if (!PtrToDataToWrite) { - return CFE_PSP_ERROR; - } - sl_cs_enter(); - memcpy(CDS_MEMORY + CDSOffset, PtrToDataToWrite, NumBytes); - sl_cs_exit(); - return CFE_PSP_SUCCESS; + if (!PtrToDataToWrite) { return CFE_PSP_ERROR; } + sl_cs_enter(); + memcpy(CDS_MEMORY + CDSOffset, PtrToDataToWrite, NumBytes); + sl_cs_exit(); + return CFE_PSP_SUCCESS; } /* ** CFE_PSP_WriteToCDS writes to the CDS Block. */ -int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumBytes) +int32 +CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumBytes) { - if (!PtrToDataToRead) { - return CFE_PSP_ERROR; - } - sl_cs_enter(); - memcpy(PtrToDataToRead, CDS_MEMORY + CDSOffset, NumBytes); - sl_cs_exit(); - return CFE_PSP_SUCCESS; + if (!PtrToDataToRead) { return CFE_PSP_ERROR; } + sl_cs_enter(); + memcpy(PtrToDataToRead, CDS_MEMORY + CDSOffset, NumBytes); + sl_cs_exit(); + return CFE_PSP_SUCCESS; } /* ** CFE_PSP_ReadFromCDS reads from the CDS Block @@ -222,14 +231,13 @@ int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumByt // TODO: Make this dynamic based on constants char RESET_AREA[CFE_PSP_CDS_SIZE]; -int32 CFE_PSP_GetResetArea (cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) +int32 +CFE_PSP_GetResetArea(cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) { - if (!PtrToResetArea || !SizeOfResetArea) { - return CFE_PSP_ERROR; - } - *PtrToResetArea = (cpuaddr) RESET_AREA; - *SizeOfResetArea = CFE_PSP_CDS_SIZE; - return CFE_PSP_SUCCESS; + if (!PtrToResetArea || !SizeOfResetArea) { return CFE_PSP_ERROR; } + *PtrToResetArea = (cpuaddr)RESET_AREA; + *SizeOfResetArea = CFE_PSP_CDS_SIZE; + return CFE_PSP_SUCCESS; } /* ** CFE_PSP_GetResetArea returns the location and size of the ES Reset information area. @@ -237,10 +245,11 @@ int32 CFE_PSP_GetResetArea (cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) ** ER Log, System Log and reset related variables */ -int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea ) +int32 +CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } /* ** CFE_PSP_GetUserReservedArea returns the location and size of the memory used for the cFE @@ -248,111 +257,121 @@ int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea */ -int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk ) +int32 +CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk) { - if (!PtrToVolDisk || !SizeOfVolDisk) { - return CFE_PSP_ERROR; - } - *PtrToVolDisk = 0; - *SizeOfVolDisk = 0; - return CFE_PSP_SUCCESS; + if (!PtrToVolDisk || !SizeOfVolDisk) { return CFE_PSP_ERROR; } + *PtrToVolDisk = 0; + *SizeOfVolDisk = 0; + return CFE_PSP_SUCCESS; } /* ** CFE_PSP_GetVolatileDiskMem returns the location and size of the memory used for the cFE ** volatile disk. */ -int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *SizeOfKernelSegment) +int32 +CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *SizeOfKernelSegment) { - // TODO: Verify this is ok to remain unimplemented - return CFE_PSP_ERROR_NOT_IMPLEMENTED; + // TODO: Verify this is ok to remain unimplemented + return CFE_PSP_ERROR_NOT_IMPLEMENTED; } /* ** CFE_PSP_GetKernelTextSegmentInfo returns the location and size of the kernel memory. */ -int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFESegment) +int32 +CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFESegment) { - // TODO: Verify this is ok to remain unimplemented - return CFE_PSP_ERROR_NOT_IMPLEMENTED; + // TODO: Verify this is ok to remain unimplemented + return CFE_PSP_ERROR_NOT_IMPLEMENTED; } /* ** CFE_PSP_GetCFETextSegmentInfo returns the location and size of the kernel memory. */ -void CFE_PSP_WatchdogInit(void) +void +CFE_PSP_WatchdogInit(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_WatchdogInit configures the watchdog timer. */ -void CFE_PSP_WatchdogEnable(void) +void +CFE_PSP_WatchdogEnable(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_WatchdogEnable enables the watchdog timer. */ -void CFE_PSP_WatchdogDisable(void) +void +CFE_PSP_WatchdogDisable(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_WatchdogDisable disables the watchdog timer. */ -void CFE_PSP_WatchdogService(void) +void +CFE_PSP_WatchdogService(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_WatchdogService services the watchdog timer according to the ** value set in WatchDogSet. */ -uint32 CFE_PSP_WatchdogGet(void) +uint32 +CFE_PSP_WatchdogGet(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } /* ** CFE_PSP_WatchdogGet gets the watchdog time in milliseconds */ -void CFE_PSP_WatchdogSet(uint32 WatchdogValue) +void +CFE_PSP_WatchdogSet(uint32 WatchdogValue) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); // TODO: Implement me! } /* ** CFE_PSP_WatchdogSet sets the watchdog time in milliseconds */ -void CFE_PSP_Panic(int32 ErrorCode) +void +CFE_PSP_Panic(int32 ErrorCode) { - printc("Error code is %d\n", (int) ErrorCode); - PANIC("PANICKING!"); + printc("Error code is %d\n", (int)ErrorCode); + PANIC("PANICKING!"); } /* ** CFE_PSP_Panic is called by the cFE Core startup code when it needs to abort the ** cFE startup. This should not be called by applications. */ -int32 CFE_PSP_InitSSR(uint32 bus, uint32 device, char *DeviceName) +int32 +CFE_PSP_InitSSR(uint32 bus, uint32 device, char *DeviceName) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } /* ** CFE_PSP_InitSSR will initialize the Solid state recorder memory for a particular platform */ -int32 CFE_PSP_Decompress( char * srcFileName, char * dstFileName) +int32 +CFE_PSP_Decompress(char *srcFileName, char *dstFileName) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + PANIC("Unimplemented method!"); // TODO: Implement me! + return 0; } /* ** CFE_PSP_Decompress will uncompress the source file to the file specified in the @@ -360,10 +379,11 @@ int32 CFE_PSP_Decompress( char * srcFileName, char * dstFileName) ** be compressed using the "gzip" program available on almost all host platforms. */ -void CFE_PSP_AttachExceptions(void) +void +CFE_PSP_AttachExceptions(void) { - // For now it is safe for this to do nothing - // TODO: Actually implement exception handling + // For now it is safe for this to do nothing + // TODO: Actually implement exception handling } /* ** CFE_PSP_AttachExceptions will setup the exception environment for the chosen platform @@ -372,9 +392,10 @@ void CFE_PSP_AttachExceptions(void) */ -void CFE_PSP_SetDefaultExceptionEnvironment(void) +void +CFE_PSP_SetDefaultExceptionEnvironment(void) { - // TODO: Figure out if it is safe for us to just do nothing here + // TODO: Figure out if it is safe for us to just do nothing here } /* ** diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c index ffae7823bf..8e149fca45 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c +++ b/src/components/implementation/no_interface/cFE_booter/sl_mod_fprr.c @@ -5,30 +5,31 @@ #include #include -#define SL_FPRR_NPRIOS 257 -#define SL_FPRR_PRIO_HIGHEST 0 -#define SL_FPRR_PRIO_LOWEST (SL_FPRR_NPRIOS-1) +#define SL_FPRR_NPRIOS 257 +#define SL_FPRR_PRIO_HIGHEST 0 +#define SL_FPRR_PRIO_LOWEST (SL_FPRR_NPRIOS - 1) -#define SL_FPRR_PERIOD_US_MIN SL_MIN_PERIOD_US +#define SL_FPRR_PERIOD_US_MIN SL_MIN_PERIOD_US struct ps_list_head threads[SL_FPRR_NPRIOS]; /* No RR yet */ void sl_mod_execution(struct sl_thd_policy *t, cycles_t cycles) -{ } +{ +} struct sl_thd_policy * sl_mod_schedule(void) { - int i; + int i; struct sl_thd_policy *t; - for (i = 0 ; i < SL_FPRR_NPRIOS ; i++) { + for (i = 0; i < SL_FPRR_NPRIOS; i++) { if (ps_list_head_empty(&threads[i])) continue; t = ps_list_head_first_d(&threads[i], struct sl_thd_policy); - struct sl_thd *thd = sl_mod_thd_get(t); + struct sl_thd *thd = sl_mod_thd_get(t); /* * We want to move the selected thread to the back of the list. @@ -77,44 +78,43 @@ sl_mod_thd_create(struct sl_thd_policy *t) void sl_mod_thd_delete(struct sl_thd_policy *t) -{ ps_list_rem_d(t); } +{ + ps_list_rem_d(t); +} void sl_mod_thd_param_set(struct sl_thd_policy *t, sched_param_type_t type, unsigned int v) { switch (type) { - case SCHEDP_PRIO: - { + case SCHEDP_PRIO: { assert(v < SL_FPRR_NPRIOS); - ps_list_rem_d(t); /* if we're already on a list, and we're updating priority */ + ps_list_rem_d(t); /* if we're already on a list, and we're updating priority */ t->priority = v; ps_list_head_append_d(&threads[t->priority], t); sl_thd_setprio(sl_mod_thd_get(t), t->priority); break; } - case SCHEDP_WINDOW: - { + case SCHEDP_WINDOW: { struct sl_thd *td = sl_mod_thd_get(t); assert(v >= SL_FPRR_PERIOD_US_MIN); - t->period_usec = v; - t->period = sl_usec2cyc(v); + t->period_usec = v; + t->period = sl_usec2cyc(v); /* FIXME: synchronize periods for all tasks */ break; } - default: assert(0); + default: + assert(0); } } void sl_mod_init(void) { - int i; + int i; struct sl_thd *t; - for (i = 0 ; i < SL_FPRR_NPRIOS ; i++) { - ps_list_head_init(&threads[i]); - } + for (i = 0; i < SL_FPRR_NPRIOS; i++) { ps_list_head_init(&threads[i]); } } diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h b/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h index 985cb51711..c888b5e8f0 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h +++ b/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h @@ -16,15 +16,19 @@ struct sl_thd_policy { // cFE specific fields osal_task_entry delete_handler; - OS_task_prop_t osal_task_prop; + OS_task_prop_t osal_task_prop; }; static inline struct sl_thd * sl_mod_thd_get(struct sl_thd_policy *tp) -{ return &tp->thd; } +{ + return &tp->thd; +} static inline struct sl_thd_policy * sl_mod_thd_policy_get(struct sl_thd *t) -{ return ps_container(t, struct sl_thd_policy, thd); } +{ + return ps_container(t, struct sl_thd_policy, thd); +} #endif /* SL_CUSTOM_MOD_POLICY_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c b/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c index 10b99705c2..eee475aa3b 100644 --- a/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c +++ b/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c @@ -38,15 +38,18 @@ sl_thd_alloc_aep_backend(void) void sl_thd_free_backend(struct sl_thd_policy *t) -{ } +{ +} void sl_thd_index_add_backend(struct sl_thd_policy *t) -{ } +{ +} void sl_thd_index_rem_backend(struct sl_thd_policy *t) -{ } +{ +} struct sl_thd_policy * sl_thd_lookup_backend(thdid_t tid) @@ -60,7 +63,7 @@ sl_thd_init_backend(void) { assert(SL_MAX_NUM_THDS <= MAX_NUM_THREADS); - memset(__sl_threads, 0, sizeof(struct sl_thd_policy)*SL_MAX_NUM_THDS); - memset(__sl_aep_infos, 0, sizeof(struct cos_aep_info)*SL_MAX_NUM_THDS); + memset(__sl_threads, 0, sizeof(struct sl_thd_policy) * SL_MAX_NUM_THDS); + memset(__sl_aep_infos, 0, sizeof(struct cos_aep_info) * SL_MAX_NUM_THDS); __sl_aep_free_off = 0; } diff --git a/src/components/implementation/no_interface/cFE_booter/tar.c b/src/components/implementation/no_interface/cFE_booter/tar.c index f9d74047ec..37a81d9afd 100644 --- a/src/components/implementation/no_interface/cFE_booter/tar.c +++ b/src/components/implementation/no_interface/cFE_booter/tar.c @@ -3,35 +3,37 @@ #include #include -//should be overwritten by linking step in build process -__attribute__((weak)) char _binary_cFE_fs_tar_size = 0; +// should be overwritten by linking step in build process +__attribute__((weak)) char _binary_cFE_fs_tar_size = 0; __attribute__((weak)) char _binary_cFE_fs_tar_start = 0; -__attribute__((weak)) char _binary_cFE_fs_tar_end = 0; +__attribute__((weak)) char _binary_cFE_fs_tar_end = 0; -//locations and size of tar -char *tar_start; -char *tar_end; -size_t tar_size; +// locations and size of tar +char * tar_start; +char * tar_end; +size_t tar_size; -static uint32 round_to_blocksize(uint32 offset) +static uint32 +round_to_blocksize(uint32 offset) { - if (offset % TAR_BLOCKSIZE) return offset + (TAR_BLOCKSIZE - (offset % TAR_BLOCKSIZE)); - return offset; + if (offset % TAR_BLOCKSIZE) return offset + (TAR_BLOCKSIZE - (offset % TAR_BLOCKSIZE)); + return offset; } -//used to convert filesize in oct char string to dec, adapted from old fs code by gparmer -static uint32 oct_to_dec(char *oct) +// used to convert filesize in oct char string to dec, adapted from old fs code by gparmer +static uint32 +oct_to_dec(char *oct) { - int32 i, base; - int32 tot; - i = strlen(oct) - 1; - for (base = 1, tot = 0 ; i >= 0 ; i--, base *= 8) { - char val = oct[i]; - assert(val <= '7' && val >= '0'); - val = val - '0'; - tot = tot + (val * base); - } - return tot; + int32 i, base; + int32 tot; + i = strlen(oct) - 1; + for (base = 1, tot = 0; i >= 0; i--, base *= 8) { + char val = oct[i]; + assert(val <= '7' && val >= '0'); + val = val - '0'; + tot = tot + (val * base); + } + return tot; } @@ -43,23 +45,21 @@ static uint32 oct_to_dec(char *oct) * process. Next checks that the size is greater than 0. Finally checks that * the end of the tar is after the start */ -uint32 tar_load() +uint32 +tar_load() { - // First make sure that symbols have been overwritten by linking process - if (!_binary_cFE_fs_tar_start) - return OS_FS_ERR_DRIVE_NOT_CREATED; - // Next check that file size is greater than 0 - if (&_binary_cFE_fs_tar_size == 0) - return OS_FS_ERR_DRIVE_NOT_CREATED; - // Check that the end of the tar is after the start - if (&_binary_cFE_fs_tar_end < &_binary_cFE_fs_tar_start) - return OS_FS_ERR_DRIVE_NOT_CREATED; - - tar_size = (size_t) &_binary_cFE_fs_tar_size; - tar_start = &_binary_cFE_fs_tar_start; - tar_end = &_binary_cFE_fs_tar_end; - - return OS_FS_SUCCESS; + // First make sure that symbols have been overwritten by linking process + if (!_binary_cFE_fs_tar_start) return OS_FS_ERR_DRIVE_NOT_CREATED; + // Next check that file size is greater than 0 + if (&_binary_cFE_fs_tar_size == 0) return OS_FS_ERR_DRIVE_NOT_CREATED; + // Check that the end of the tar is after the start + if (&_binary_cFE_fs_tar_end < &_binary_cFE_fs_tar_start) return OS_FS_ERR_DRIVE_NOT_CREATED; + + tar_size = (size_t)&_binary_cFE_fs_tar_size; + tar_start = &_binary_cFE_fs_tar_start; + tar_end = &_binary_cFE_fs_tar_end; + + return OS_FS_SUCCESS; } @@ -69,65 +69,65 @@ uint32 tar_load() * Postcondition: A proper error code is returned OR the tar is represented in memory * at the currently open filesystem */ -uint32 tar_parse() +uint32 +tar_parse() { - assert(tar_start && tar_end); - assert(tar_size < INT32_MAX); - assert(tar_end - tar_start > 0); - assert(tar_size == (size_t) (tar_end - tar_start)); - uint32 offset = 0; - struct fsobj *o; - - while (offset + tar_start < tar_end) { - if (file_get_new(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; - - //tar ends after two empty records - if ( !(offset + tar_start)[0] && !(offset + tar_start)[TAR_BLOCKSIZE]) { - o->ino = 0; - return OS_FS_SUCCESS; - } - if (tar_hdr_read(offset, o)) return OS_FS_ERR_DRIVE_NOT_CREATED; - if (file_insert(o, offset + tar_start) != OS_FS_SUCCESS) return OS_FS_ERR_DRIVE_NOT_CREATED; - - /* - * data is aligned to 512 byte blocks. a header is 500 bytes, and - * the file's data begins exactly after the header - * therefor the next header is 500 + o->size rounded up to a mult of 512 - */ - offset += round_to_blocksize(o->size + 500); - } - //tar ends before two empty records are found - return OS_FS_ERROR; + assert(tar_start && tar_end); + assert(tar_size < INT32_MAX); + assert(tar_end - tar_start > 0); + assert(tar_size == (size_t)(tar_end - tar_start)); + uint32 offset = 0; + struct fsobj *o; + + while (offset + tar_start < tar_end) { + if (file_get_new(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + + // tar ends after two empty records + if (!(offset + tar_start)[0] && !(offset + tar_start)[TAR_BLOCKSIZE]) { + o->ino = 0; + return OS_FS_SUCCESS; + } + if (tar_hdr_read(offset, o)) return OS_FS_ERR_DRIVE_NOT_CREATED; + if (file_insert(o, offset + tar_start) != OS_FS_SUCCESS) return OS_FS_ERR_DRIVE_NOT_CREATED; + + /* + * data is aligned to 512 byte blocks. a header is 500 bytes, and + * the file's data begins exactly after the header + * therefor the next header is 500 + o->size rounded up to a mult of 512 + */ + offset += round_to_blocksize(o->size + 500); + } + // tar ends before two empty records are found + return OS_FS_ERROR; } /* * Copies information from a tar file header to a fsobj */ -uint32 tar_hdr_read(uint32 tar_offset, struct fsobj *file) +uint32 +tar_hdr_read(uint32 tar_offset, struct fsobj *file) { - assert(tar_offset < tar_size); - assert(file->ino > 0); - - struct f_part *part; - part_get_new(&part); - file->memtype = STATIC; - - char *location = tar_start; - location += tar_offset; - memmove(location + 1, location, strlen(location)); - location[0] = '/'; - file->name = path_to_name(location); - - if (*(location + strlen(location) - 1) == '/') { - file->type = FSOBJ_DIR; - file->size = 0; - } - else{ - file->type = FSOBJ_FILE; - file->size = oct_to_dec(location + 124); - file->file_part = part; - file->file_part->data = location + 500; - } - return OS_FS_SUCCESS; + assert(tar_offset < tar_size); + assert(file->ino > 0); + + struct f_part *part; + part_get_new(&part); + file->memtype = STATIC; + + char *location = tar_start; + location += tar_offset; + memmove(location + 1, location, strlen(location)); + location[0] = '/'; + file->name = path_to_name(location); + + if (*(location + strlen(location) - 1) == '/') { + file->type = FSOBJ_DIR; + file->size = 0; + } else { + file->type = FSOBJ_FILE; + file->size = oct_to_dec(location + 124); + file->file_part = part; + file->file_part->data = location + 500; + } + return OS_FS_SUCCESS; } - diff --git a/src/components/implementation/no_interface/cFE_booter/tar.h b/src/components/implementation/no_interface/cFE_booter/tar.h index fa18590392..57b62a6d4b 100644 --- a/src/components/implementation/no_interface/cFE_booter/tar.h +++ b/src/components/implementation/no_interface/cFE_booter/tar.h @@ -1,26 +1,25 @@ #define TAR_BLOCKSIZE 512 -#define INT32_MAX 0x7FFFFFF //2^31 - 1 +#define INT32_MAX 0x7FFFFFF // 2^31 - 1 // from GNU -struct posix_header -{ /* byte offset */ - char name[100]; /* 0 */ - char mode[8]; /* 100 */ - char uid[8]; /* 108 */ - char gid[8]; /* 116 */ - char size[12]; /* 124 */ - char mtime[12]; /* 136 */ - char chksum[8]; /* 148 */ - char typeflag; /* 156 */ - char linkname[100]; /* 157 */ - char magic[6]; /* 257 */ - char version[2]; /* 263 */ - char uname[32]; /* 265 */ - char gname[32]; /* 297 */ - char devmajor[8]; /* 329 */ - char devminor[8]; /* 337 */ - char prefix[155]; /* 345 */ - /* 500 */ +struct posix_header { /* byte offset */ + char name[100]; /* 0 */ + char mode[8]; /* 100 */ + char uid[8]; /* 108 */ + char gid[8]; /* 116 */ + char size[12]; /* 124 */ + char mtime[12]; /* 136 */ + char chksum[8]; /* 148 */ + char typeflag; /* 156 */ + char linkname[100]; /* 157 */ + char magic[6]; /* 257 */ + char version[2]; /* 263 */ + char uname[32]; /* 265 */ + char gname[32]; /* 297 */ + char devmajor[8]; /* 329 */ + char devminor[8]; /* 337 */ + char prefix[155]; /* 345 */ + /* 500 */ }; uint32 tar_load(); diff --git a/src/components/include/cFE_emu.h b/src/components/include/cFE_emu.h index 5d45d1057f..3a12a2f4d0 100644 --- a/src/components/include/cFE_emu.h +++ b/src/components/include/cFE_emu.h @@ -5,41 +5,41 @@ #define EMU_BUF_SIZE 512 union shared_region { - struct { - CFE_EVS_BinFilter_t filters[CFE_EVS_MAX_EVENT_FILTERS]; - uint16 NumEventFilters; - uint16 FilterScheme; - } cfe_evs_register; - struct { - CFE_SB_PipeId_t PipeId; - uint16 Depth; - char PipeName[OS_MAX_API_NAME]; - } cfe_sb_createPipe; - struct { - char MsgBuffer[EMU_BUF_SIZE]; - CFE_SB_MsgId_t MsgId; - uint16 Length; - boolean Clear; - } cfe_sb_initMsg; - struct { - char Msg[EMU_BUF_SIZE]; - uint16 EventID; - uint16 EventType; - } cfe_evs_sendEvent; - struct { - uint32 RunStatus; - } cfe_es_runLoop; - struct { - CFE_SB_PipeId_t PipeId; - int32 TimeOut; - char Msg[EMU_BUF_SIZE]; - } cfe_sb_rcvMsg; - struct { - CFE_SB_Msg_t Msg; - } cfe_sb_getMsgLen; - struct { - char Msg[EMU_BUF_SIZE]; - } cfe_sb_msg; + struct { + CFE_EVS_BinFilter_t filters[CFE_EVS_MAX_EVENT_FILTERS]; + uint16 NumEventFilters; + uint16 FilterScheme; + } cfe_evs_register; + struct { + CFE_SB_PipeId_t PipeId; + uint16 Depth; + char PipeName[OS_MAX_API_NAME]; + } cfe_sb_createPipe; + struct { + char MsgBuffer[EMU_BUF_SIZE]; + CFE_SB_MsgId_t MsgId; + uint16 Length; + boolean Clear; + } cfe_sb_initMsg; + struct { + char Msg[EMU_BUF_SIZE]; + uint16 EventID; + uint16 EventType; + } cfe_evs_sendEvent; + struct { + uint32 RunStatus; + } cfe_es_runLoop; + struct { + CFE_SB_PipeId_t PipeId; + int32 TimeOut; + char Msg[EMU_BUF_SIZE]; + } cfe_sb_rcvMsg; + struct { + CFE_SB_Msg_t Msg; + } cfe_sb_getMsgLen; + struct { + char Msg[EMU_BUF_SIZE]; + } cfe_sb_msg; }; int emu_backend_request_memory(spdid_t client); diff --git a/src/components/include/log.h b/src/components/include/log.h deleted file mode 100644 index b8813e8438..0000000000 --- a/src/components/include/log.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef LOG_H -#define LOG_H - -#include - -enum log_level { - FATAL = 0, - ERROR = 1, - WARNING = 2, - INFO = 3, - DEBUGGING = 4, - TRACE = 5 -}; - - -#ifndef LOGGING_LEVEL -#define LOGGING_LEVEL WARNING -#endif - -#define LOG_FATAL(...) do { if(LOGGING_LEVEL >= FATAL) printc(__VA_ARGS__) } while(0) - -#define LOG_ERROR(...) do { if(LOGGING_LEVEL >= ERROR) printc(__VA_ARGS__) } while(0) - -#define LOG_WARNING(...) do { if(LOGGING_LEVEL >= WARNING) printc(__VA_ARGS__) } while(0) - -#define LOG_INFO(...) do { if(LOGGING_LEVEL >= INFO) printc(__VA_ARGS__) } while(0) - -#define LOG_DEBUG(...) do { if(LOGGING_LEVEL >= DEBUG) printc(__VA_ARGS__) } while(0) - -#define LOG_TRACE(...) do { if(LOGGING_LEVEL >= TRACE) printc(__VA_ARGS__) } while(0) - - -#endif diff --git a/src/components/lib/cFE_emu.c b/src/components/lib/cFE_emu.c index ba76ae8ffd..6a9aab4936 100644 --- a/src/components/lib/cFE_emu.c +++ b/src/components/lib/cFE_emu.c @@ -10,104 +10,98 @@ #include union shared_region *shared_region; -spdid_t spdid; +spdid_t spdid; -void do_emulation_setup(spdid_t id) +void +do_emulation_setup(spdid_t id) { - spdid = id; + spdid = id; - int region_id = emu_backend_request_memory(id); + int region_id = emu_backend_request_memory(id); - vaddr_t client_addr = 0; - memmgr_shared_page_map(region_id, &client_addr); - assert(client_addr); - shared_region = (void*)client_addr; + vaddr_t client_addr = 0; + memmgr_shared_page_map(region_id, &client_addr); + assert(client_addr); + shared_region = (void *)client_addr; } // FIXME: Query the cFE to decide whether printf is enabled int is_printf_enabled = 1; -void OS_printf(const char *string, ...) +void +OS_printf(const char *string, ...) { - if(is_printf_enabled) { - char s[OS_BUFFER_SIZE]; - va_list arg_ptr; - int ret, len = OS_BUFFER_SIZE; - - va_start(arg_ptr, string); - ret = vsnprintf(s, len, string, arg_ptr); - va_end(arg_ptr); - cos_llprint(s, ret); - } + if (is_printf_enabled) { + char s[OS_BUFFER_SIZE]; + va_list arg_ptr; + int ret, len = OS_BUFFER_SIZE; + + va_start(arg_ptr, string); + ret = vsnprintf(s, len, string, arg_ptr); + va_end(arg_ptr); + cos_llprint(s, ret); + } } -int32 CFE_EVS_Register (void *Filters, /* Pointer to an array of filters */ - uint16 NumFilteredEvents, /* How many elements in the array? */ - uint16 FilterScheme) /* Filtering Algorithm to be implemented */ +int32 CFE_EVS_Register(void * Filters, /* Pointer to an array of filters */ + uint16 NumFilteredEvents, /* How many elements in the array? */ + uint16 FilterScheme) /* Filtering Algorithm to be implemented */ { - if (FilterScheme != CFE_EVS_BINARY_FILTER) - { - return CFE_EVS_UNKNOWN_FILTER; - } - CFE_EVS_BinFilter_t *bin_filters = Filters; - int i; - for (i = 0; i < NumFilteredEvents; i++) { - shared_region->cfe_evs_register.filters[i] = bin_filters[i]; - } - shared_region->cfe_evs_register.NumEventFilters = NumFilteredEvents; - shared_region->cfe_evs_register.FilterScheme = FilterScheme; - return emu_CFE_EVS_Register(spdid); + if (FilterScheme != CFE_EVS_BINARY_FILTER) { return CFE_EVS_UNKNOWN_FILTER; } + CFE_EVS_BinFilter_t *bin_filters = Filters; + int i; + for (i = 0; i < NumFilteredEvents; i++) { shared_region->cfe_evs_register.filters[i] = bin_filters[i]; } + shared_region->cfe_evs_register.NumEventFilters = NumFilteredEvents; + shared_region->cfe_evs_register.FilterScheme = FilterScheme; + return emu_CFE_EVS_Register(spdid); } -int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, - uint16 Depth, - const char *PipeName) +int32 +CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *PipeName) { - shared_region->cfe_sb_createPipe.Depth = Depth; - strncpy(shared_region->cfe_sb_createPipe.PipeName, PipeName, OS_MAX_API_NAME); - int32 ret = emu_CFE_SB_CreatePipe(spdid); - *PipeIdPtr = shared_region->cfe_sb_createPipe.PipeId; - return ret; + shared_region->cfe_sb_createPipe.Depth = Depth; + strncpy(shared_region->cfe_sb_createPipe.PipeName, PipeName, OS_MAX_API_NAME); + int32 ret = emu_CFE_SB_CreatePipe(spdid); + *PipeIdPtr = shared_region->cfe_sb_createPipe.PipeId; + return ret; } -void CFE_SB_InitMsg(void *MsgPtr, - CFE_SB_MsgId_t MsgId, - uint16 Length, - boolean Clear ) +void +CFE_SB_InitMsg(void *MsgPtr, CFE_SB_MsgId_t MsgId, uint16 Length, boolean Clear) { - char *source = MsgPtr; - assert(Length <= EMU_BUF_SIZE); - memcpy(shared_region->cfe_sb_initMsg.MsgBuffer, source, Length); - shared_region->cfe_sb_initMsg.MsgId = MsgId; - shared_region->cfe_sb_initMsg.Length = Length; - shared_region->cfe_sb_initMsg.Clear = Clear; - emu_CFE_SB_InitMsg(spdid); - memcpy(source, shared_region->cfe_sb_initMsg.MsgBuffer, Length); + char *source = MsgPtr; + assert(Length <= EMU_BUF_SIZE); + memcpy(shared_region->cfe_sb_initMsg.MsgBuffer, source, Length); + shared_region->cfe_sb_initMsg.MsgId = MsgId; + shared_region->cfe_sb_initMsg.Length = Length; + shared_region->cfe_sb_initMsg.Clear = Clear; + emu_CFE_SB_InitMsg(spdid); + memcpy(source, shared_region->cfe_sb_initMsg.MsgBuffer, Length); } -int32 CFE_EVS_SendEvent( uint16 EventID, - uint16 EventType, - const char *Spec, ... ) +int32 +CFE_EVS_SendEvent(uint16 EventID, uint16 EventType, const char *Spec, ...) { - va_list Ptr; - va_start(Ptr, Spec); - vsnprintf(shared_region->cfe_evs_sendEvent.Msg, sizeof(shared_region->cfe_evs_sendEvent.Msg), Spec, Ptr); - va_end(Ptr); + va_list Ptr; + va_start(Ptr, Spec); + vsnprintf(shared_region->cfe_evs_sendEvent.Msg, sizeof(shared_region->cfe_evs_sendEvent.Msg), Spec, Ptr); + va_end(Ptr); - shared_region->cfe_evs_sendEvent.EventID = EventID; - shared_region->cfe_evs_sendEvent.EventType = EventType; + shared_region->cfe_evs_sendEvent.EventID = EventID; + shared_region->cfe_evs_sendEvent.EventType = EventType; - return emu_CFE_EVS_SendEvent(spdid); + return emu_CFE_EVS_SendEvent(spdid); } -int32 CFE_ES_RunLoop(uint32 *RunStatus) +int32 +CFE_ES_RunLoop(uint32 *RunStatus) { - shared_region->cfe_es_runLoop.RunStatus = *RunStatus; - int32 result = emu_CFE_ES_RunLoop(spdid); - *RunStatus = shared_region->cfe_es_runLoop.RunStatus; - return result; + shared_region->cfe_es_runLoop.RunStatus = *RunStatus; + int32 result = emu_CFE_ES_RunLoop(spdid); + *RunStatus = shared_region->cfe_es_runLoop.RunStatus; + return result; } /* @@ -118,62 +112,66 @@ int32 CFE_ES_RunLoop(uint32 *RunStatus) * Therefore one buffer per pipe is acceptable */ struct { - char buf[EMU_BUF_SIZE]; + char buf[EMU_BUF_SIZE]; } pipe_buffers[CFE_SB_MAX_PIPES]; -int32 CFE_SB_RcvMsg(CFE_SB_MsgPtr_t *BufPtr, - CFE_SB_PipeId_t PipeId, - int32 TimeOut) +int32 +CFE_SB_RcvMsg(CFE_SB_MsgPtr_t *BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut) { - shared_region->cfe_sb_rcvMsg.PipeId = PipeId; - shared_region->cfe_sb_rcvMsg.TimeOut = TimeOut; - int32 result = emu_CFE_SB_RcvMsg(spdid); - if (result == CFE_SUCCESS) { - memcpy(pipe_buffers[PipeId].buf, shared_region->cfe_sb_rcvMsg.Msg, EMU_BUF_SIZE); - *BufPtr = (CFE_SB_MsgPtr_t)pipe_buffers[PipeId].buf; - } - return result; + shared_region->cfe_sb_rcvMsg.PipeId = PipeId; + shared_region->cfe_sb_rcvMsg.TimeOut = TimeOut; + int32 result = emu_CFE_SB_RcvMsg(spdid); + if (result == CFE_SUCCESS) { + memcpy(pipe_buffers[PipeId].buf, shared_region->cfe_sb_rcvMsg.Msg, EMU_BUF_SIZE); + *BufPtr = (CFE_SB_MsgPtr_t)pipe_buffers[PipeId].buf; + } + return result; } -uint16 CFE_SB_GetTotalMsgLength(CFE_SB_MsgPtr_t MsgPtr) +uint16 +CFE_SB_GetTotalMsgLength(CFE_SB_MsgPtr_t MsgPtr) { - shared_region->cfe_sb_getMsgLen.Msg = *MsgPtr; - return emu_CFE_SB_GetTotalMsgLength(spdid); + shared_region->cfe_sb_getMsgLen.Msg = *MsgPtr; + return emu_CFE_SB_GetTotalMsgLength(spdid); } -int32 CFE_SB_SendMsg(CFE_SB_Msg_t *MsgPtr) +int32 +CFE_SB_SendMsg(CFE_SB_Msg_t *MsgPtr) { - uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); - assert(msg_len <= EMU_BUF_SIZE); - char *msg_ptr = (char*)MsgPtr; - memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); - return emu_CFE_SB_SendMsg(spdid); + uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); + char *msg_ptr = (char *)MsgPtr; + memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); + return emu_CFE_SB_SendMsg(spdid); } -uint16 CFE_SB_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr) +uint16 +CFE_SB_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr) { - uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); - assert(msg_len <= EMU_BUF_SIZE); - char *msg_ptr = (char*)MsgPtr; - memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); - return emu_CFE_SB_GetCmdCode(spdid); + uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); + char *msg_ptr = (char *)MsgPtr; + memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); + return emu_CFE_SB_GetCmdCode(spdid); } -CFE_SB_MsgId_t CFE_SB_GetMsgId(CFE_SB_MsgPtr_t MsgPtr) +CFE_SB_MsgId_t +CFE_SB_GetMsgId(CFE_SB_MsgPtr_t MsgPtr) { - uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); - assert(msg_len <= EMU_BUF_SIZE); - char *msg_ptr = (char*)MsgPtr; - memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); - return emu_CFE_SB_GetMsgId(spdid); + uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); + char *msg_ptr = (char *)MsgPtr; + memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); + return emu_CFE_SB_GetMsgId(spdid); } -void CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr) +void +CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr) { - uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); - assert(msg_len <= EMU_BUF_SIZE); - char *msg_ptr = (char*)MsgPtr; - memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); - emu_CFE_SB_TimeStampMsg(spdid); - memcpy(msg_ptr, shared_region->cfe_sb_msg.Msg, (size_t)msg_len); + uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); + char *msg_ptr = (char *)MsgPtr; + memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); + emu_CFE_SB_TimeStampMsg(spdid); + memcpy(msg_ptr, shared_region->cfe_sb_msg.Msg, (size_t)msg_len); } diff --git a/src/components/lib/cos_asm_upcall.S b/src/components/lib/cos_asm_upcall.S index 80339b1dbd..e064d85b58 100644 --- a/src/components/lib/cos_asm_upcall.S +++ b/src/components/lib/cos_asm_upcall.S @@ -8,9 +8,9 @@ */ #define __ASM__ +#include #include "../../kernel/include/asm_ipc_defs.h" -#include #include #define IPRETURN 4 diff --git a/src/components/lib/cos_kernel_api.c b/src/components/lib/cos_kernel_api.c index 2e5e4c713a..861216e6e1 100644 --- a/src/components/lib/cos_kernel_api.c +++ b/src/components/lib/cos_kernel_api.c @@ -926,7 +926,6 @@ cos_thd_mod(struct cos_compinfo *ci, thdcap_t tc, void *tlsaddr) int cos_introspect(struct cos_compinfo *ci, capid_t cap, unsigned long op) { - assert(ci->captbl_cap); return call_cap_op(ci->captbl_cap, CAPTBL_OP_INTROSPECT, cap, (int)op, 0, 0); } diff --git a/src/kernel/include/inv.h b/src/kernel/include/inv.h index 8d56399d16..b9a26557f9 100644 --- a/src/kernel/include/inv.h +++ b/src/kernel/include/inv.h @@ -307,12 +307,10 @@ static inline void sret_ret(struct thread *thd, struct pt_regs *regs, struct cos_cpu_local_info *cos_info) { struct comp_info *ci; - unsigned long ip = 0, sp = 0; + unsigned long ip, sp; ci = thd_invstk_pop(thd, &ip, &sp, cos_info); - if (unlikely(!ci || !ip || !sp)) { - printk("cos: sync return failed, thd_invstk_pop(thd = %p, cos_info = %p) gives (ip = %p, sp = %p, ci = %p), which is invalid\n", - thd, cos_info, ip, sp, ci); + if (unlikely(!ci)) { __userregs_set(regs, 0xDEADDEAD, 0, 0); return; } From 0aa12f35a4d9b514f501f5eeeb9a8dae124cb669 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Fri, 23 Mar 2018 17:52:47 -0400 Subject: [PATCH 101/122] Refactor cFE_emu to use c_stubs instead of a library --- src/Makefile | 19 +- src/components/Makefile.comp | 3 +- .../no_interface/cFE_booter/Makefile | 2 +- .../no_interface/cFE_booter/cFE_emu_support.c | 2 + .../cFE_booter/sl_thd_static_backend.c | 69 ------- .../no_interface/sample_app/Makefile | 2 +- .../no_interface/sample_lib/Makefile | 2 +- .../no_interface/sch_lab/Makefile | 2 +- src/components/interface/cFE/Makefile | 1 + .../cFE/stubs/c_stub.c} | 0 src/components/lib/Makefile | 2 +- src/extern/Makefile | 21 +++ src/extern/cFE | 2 +- src/extern/make.py | 169 ------------------ 14 files changed, 35 insertions(+), 261 deletions(-) delete mode 100644 src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c rename src/components/{lib/cFE_emu.c => interface/cFE/stubs/c_stub.c} (100%) create mode 100644 src/extern/Makefile delete mode 100755 src/extern/make.py diff --git a/src/Makefile b/src/Makefile index a463970f15..b837c58f97 100644 --- a/src/Makefile +++ b/src/Makefile @@ -7,21 +7,7 @@ default: | all cp all: | extern comps plat extern: - $(info ) - $(info ***********************************************) - $(info *********** Building External Libs ************) - $(info ***********************************************) - $(info ) - $(shell cd extern && python make.py >&2) - -init_extern: - $(info ) - $(info ***********************************************) - $(info ********** Setting up External Libs ***********) - $(info ***********************************************) - $(info ) - bash -c 'cd extern/cFE/; source setvars.sh; cd ../..; make -C extern/cFE/build/cpu1 config' - $(shell cd extern && python make.py -p >&2) + $(MAKE) $(MAKEFLAGS) -C extern comps: $(info ) @@ -59,6 +45,9 @@ init: | ensure_config init_extern init_composite ensure_config: test -f PLATFORM_ID || $(MAKE) $(MAKEFLAGS) config +init_extern: + $(MAKE) $(MAKEFLAGS) -C extern init + init_composite: $(MAKE) $(MAKEFLAGS) -C components init $(MAKE) $(MAKEFLAGS) PLATFORM=$(shell cat PLATFORM_ID) -C platform init diff --git a/src/components/Makefile.comp b/src/components/Makefile.comp index 307bb1bea4..e635d29705 100644 --- a/src/components/Makefile.comp +++ b/src/components/Makefile.comp @@ -4,8 +4,7 @@ IMPLDIR=$(CDIR)/implementation/ INTERDIR=$(CDIR)/interface/ LIBDIR=$(CDIR)/lib/ MANDITORY_LIB=cos_manditory.o -# FIXME: Point the cFE includes at the actual cFE -CINC=-I./ -I$(CDIR)/include/ -I$(SHAREDINC) -I$(CDIR)/lib/ck/include -I$(CDIR)/lib/ps/ -I$(CDIR)/lib/libcxx/include -I$(CDIR)/implementation/no_interface/cFE_booter/gen +CINC=-I./ -I$(CDIR)/include/ -I$(SHAREDINC) -I$(CDIR)/lib/ck/include -I$(CDIR)/lib/ps/ -I$(CDIR)/lib/libcxx/include MUSLDIR=$(CDIR)/lib/musl-1.1.11 MUSLBIN=$(MUSLDIR)/bin diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index 2c3c2f430a..8e7f5e8e2b 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -4,7 +4,7 @@ COMPONENT=cFE_booter.o INTERFACES=cFE DEPENDENCIES=capmgr IF_LIB:=./composite_cFE.o ./cFE_fs.o $(wildcard test/*.o) -ADDITIONAL_LIBS=-lcobj_format -lcos_kernel_api -lcos_defkernel_api -lsl_capmgr -lsl_sched -lheap -lsl_lock +ADDITIONAL_LIBS=-lcobj_format $(LIBSLCAPMGR) -lheap -lsl_lock -lsl_thd_static_backend include ../../Makefile.subsubdir CFLAGS += -I./gen -I ./test/shared $(CPPFLAGS) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c index d7f2d6b594..1985deaa14 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -17,8 +17,10 @@ emu_backend_request_memory(spdid_t client) { vaddr_t our_addr = 0; int id = memmgr_shared_page_alloc(&our_addr); + assert(our_addr); shared_regions[client] = (void *)our_addr; + return id; } diff --git a/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c b/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c deleted file mode 100644 index eee475aa3b..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Redistribution of this file is permitted under the BSD two clause license. - * - * Copyright 2017, The George Washington University - * Author: Gabriel Parmer, gparmer@gwu.edu - */ - -#include -#include -#include -#include -#include - -static struct sl_thd_policy __sl_threads[SL_MAX_NUM_THDS]; - -static struct cos_aep_info __sl_aep_infos[SL_MAX_NUM_THDS]; -static u32_t __sl_aep_free_off; - -/* Default implementations of backend functions */ -struct sl_thd_policy * -sl_thd_alloc_backend(thdid_t tid) -{ - assert(tid < SL_MAX_NUM_THDS); - return &__sl_threads[tid]; -} - -struct cos_aep_info * -sl_thd_alloc_aep_backend(void) -{ - struct cos_aep_info *aep = NULL; - - assert(__sl_aep_free_off < SL_MAX_NUM_THDS); - aep = &__sl_aep_infos[__sl_aep_free_off]; - __sl_aep_free_off++; - - return aep; -} - -void -sl_thd_free_backend(struct sl_thd_policy *t) -{ -} - -void -sl_thd_index_add_backend(struct sl_thd_policy *t) -{ -} - -void -sl_thd_index_rem_backend(struct sl_thd_policy *t) -{ -} - -struct sl_thd_policy * -sl_thd_lookup_backend(thdid_t tid) -{ - assert(tid < SL_MAX_NUM_THDS); - return &__sl_threads[tid]; -} - -void -sl_thd_init_backend(void) -{ - assert(SL_MAX_NUM_THDS <= MAX_NUM_THREADS); - - memset(__sl_threads, 0, sizeof(struct sl_thd_policy) * SL_MAX_NUM_THDS); - memset(__sl_aep_infos, 0, sizeof(struct cos_aep_info) * SL_MAX_NUM_THDS); - __sl_aep_free_off = 0; -} diff --git a/src/components/implementation/no_interface/sample_app/Makefile b/src/components/implementation/no_interface/sample_app/Makefile index 5a2348489f..b8b0f29a9f 100644 --- a/src/components/implementation/no_interface/sample_app/Makefile +++ b/src/components/implementation/no_interface/sample_app/Makefile @@ -4,7 +4,7 @@ COMPONENT=sample_app.o INTERFACES= DEPENDENCIES=cFE capmgr IF_LIB:=./cFE_sample_app.o -ADDITIONAL_LIBS=-lcos_kernel_api -lcFE_emu +ADDITIONAL_LIBS=-lcos_kernel_api include ../../Makefile.subsubdir MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/sample_lib/Makefile b/src/components/implementation/no_interface/sample_lib/Makefile index d5caed804f..93af46b2e3 100644 --- a/src/components/implementation/no_interface/sample_lib/Makefile +++ b/src/components/implementation/no_interface/sample_lib/Makefile @@ -4,7 +4,7 @@ COMPONENT=sample_lib.o INTERFACES= DEPENDENCIES=cFE capmgr IF_LIB:=./cFE_sample_lib.o -ADDITIONAL_LIBS=-lcos_kernel_api -lcFE_emu +ADDITIONAL_LIBS=-lcos_kernel_api include ../../Makefile.subsubdir MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/sch_lab/Makefile b/src/components/implementation/no_interface/sch_lab/Makefile index f057dadda9..e149e30b4d 100644 --- a/src/components/implementation/no_interface/sch_lab/Makefile +++ b/src/components/implementation/no_interface/sch_lab/Makefile @@ -4,7 +4,7 @@ COMPONENT=sch_lab.o INTERFACES= DEPENDENCIES=cFE capmgr IF_LIB:=./cFE_sch_lab_app.o -ADDITIONAL_LIBS=-lcos_kernel_api -lcFE_emu +ADDITIONAL_LIBS=-lcos_kernel_api include ../../Makefile.subsubdir MANDITORY_LIB=simple_stklib.o diff --git a/src/components/interface/cFE/Makefile b/src/components/interface/cFE/Makefile index f55b30401e..ebb7b41beb 100644 --- a/src/components/interface/cFE/Makefile +++ b/src/components/interface/cFE/Makefile @@ -3,3 +3,4 @@ LIBS=$(LIB_OBJS:%.o=%.a) ASM_STUBS=s_stubpg.o include ../Makefile.subdir +CINC+=-I$(CDIR)/implementation/no_interface/cFE_booter/gen diff --git a/src/components/lib/cFE_emu.c b/src/components/interface/cFE/stubs/c_stub.c similarity index 100% rename from src/components/lib/cFE_emu.c rename to src/components/interface/cFE/stubs/c_stub.c diff --git a/src/components/lib/Makefile b/src/components/lib/Makefile index 30ff8cb0f8..851fdafc19 100644 --- a/src/components/lib/Makefile +++ b/src/components/lib/Makefile @@ -1,6 +1,6 @@ include Makefile.src Makefile.comp -LIB_OBJS=heap.o cobj_format.o cos_kernel_api.o cos_defkernel_api.o cFE_emu.o +LIB_OBJS=heap.o cobj_format.o cos_kernel_api.o cos_defkernel_api.o LIBS=$(LIB_OBJS:%.o=%.a) MANDITORY=c_stub.o cos_asm_upcall.o cos_asm_ainv.o cos_component.o MAND=$(MANDITORY_LIB) diff --git a/src/extern/Makefile b/src/extern/Makefile new file mode 100644 index 0000000000..06e35ba22d --- /dev/null +++ b/src/extern/Makefile @@ -0,0 +1,21 @@ +.PHONY: build, init + +default: build + +init: + $(info ) + $(info ***********************************************) + $(info ********** Setting up External Libs ***********) + $(info ***********************************************) + $(info ) + bash -c 'cd cFE/ && source setvars.sh && make -C build/cpu1 config' + $(shell cd cFE/ && python make.py -p >&2) + + +build: + $(info ) + $(info ***********************************************) + $(info *********** Building External Libs ************) + $(info ***********************************************) + $(info ) + $(shell cd cFE && python make.py >&2) diff --git a/src/extern/cFE b/src/extern/cFE index 56339c3de9..bc46e1eb10 160000 --- a/src/extern/cFE +++ b/src/extern/cFE @@ -1 +1 @@ -Subproject commit 56339c3de9bf2e86714e03f7dc87320d9a63f63c +Subproject commit bc46e1eb10577f82dd4bf3299e19b5adf7cda353 diff --git a/src/extern/make.py b/src/extern/make.py deleted file mode 100755 index 21862f4b72..0000000000 --- a/src/extern/make.py +++ /dev/null @@ -1,169 +0,0 @@ -#!/usr/bin/env python2.7 -# cFE2cos build script. Builds Composite and the cFE and links the two together. -import argparse -import os -import shutil -import subprocess as sp -import sys - -# Load command line arguments. -parser = argparse.ArgumentParser(description='Copy cFE files over to Composite and build Composite with cFE support.') -parser.add_argument('-c', '--clean', dest='clean', action='store_true', help='Clean the Composite build directory before building it.') -parser.add_argument('-i', '--ignore-clock-skew', dest='skew', action='store_true', help='Ignore clock skew warnings when building.') -parser.add_argument('-u', '--unit-tests', dest='unit_tests', action='store_true', help='Build unit tests.') -parser.add_argument('-p', '--copy-only', dest='copy_only', action='store_true', help='Don\'t build the cFE, just copy headers') - -args = parser.parse_args() - -print """ -####################### -## SETTING VARIABLES ## -####################### -""" - -# Find the root of the composite repository -cos_root, _ = sp.Popen("git rev-parse --show-toplevel", shell=True, stdout=sp.PIPE).communicate() -cos_root = cos_root.strip() - -# Set static variables. -COMPOSITE_DIR = cos_root + "/" -COMPOSITE_TRANSFER_DIR = COMPOSITE_DIR + "transfer/" -COMPOSITE_MAKE_ROOT = COMPOSITE_DIR + "src/" -COMPOSITE_IMPL_NO_INTERFACE_DIR = COMPOSITE_DIR + "src/components/implementation/no_interface/" -COMPOSITE_CFE_COMPONENT_ROOT = COMPOSITE_IMPL_NO_INTERFACE_DIR + "cFE_booter/" -COMPOSITE_CFE_HEADER_DESTINATION = COMPOSITE_CFE_COMPONENT_ROOT + "gen/" -print "COMPOSITE_DIR: {}".format(COMPOSITE_DIR) -print "COMPOSITE_TRANSFER_DIR: {}".format(COMPOSITE_TRANSFER_DIR) -print "COMPOSITE_MAKE_ROOT: {}".format(COMPOSITE_MAKE_ROOT) -print "COMPOSITE_CFE_COMPONENT_ROOT: {}".format(COMPOSITE_CFE_COMPONENT_ROOT) -print "COMPOSITE_CFE_HEADER_DESTINATION: {}".format(COMPOSITE_CFE_HEADER_DESTINATION) - -CFE_DIR = COMPOSITE_MAKE_ROOT + "extern/cFE/" -CFE_MAKE_ROOT = CFE_DIR + "build/cpu1/" -CFE_OBJECT_LOCATION = CFE_MAKE_ROOT + "exe/" -CFE_OBJECT_NAME = "composite_cFE.o" -print "CFE_DIR: {}".format(CFE_DIR) -print "CFE_MAKE_ROOT: {}".format(CFE_MAKE_ROOT) -print "CFE_OBJECT_LOCATION: {}".format(CFE_OBJECT_LOCATION) -print "CFE_OBJECT_NAME: {}".format(CFE_OBJECT_NAME) - -# UT is an abbreviation for Unit Tests. -COMPOSITE_CFE_UT_DESTINATION = COMPOSITE_CFE_COMPONENT_ROOT + "test/" -OSAL_UT_DIR = CFE_DIR + "osal/src/unit-tests/" -print "OSAL_UT_DIR: {}".format(OSAL_UT_DIR) -print "COMPOSITE_CFE_UT_DESTINATION: {}".format(COMPOSITE_CFE_UT_DESTINATION) - -# We don't need these stubs because we already provide our own. -# Copying them over causes duplicate symbol errors -OSAL_UT_OBJECTS_TO_SKIP = [ - "ut_osfile_stubs.o", - "ut_osfilesys_stubs.o", - "ut_osnetwork_stubs.o", - "ut_ostimer_stubs.o" -] -OSAL_UT_HEADERS_TO_COPY = [ - "oscore-test", - "osfile-test", - "osfilesys-test", - "osloader-test", - "osnetwork-test", - "osprintf-test", - "ostimer-test", - "shared" -] - -CFE_HEADERS_TO_COPY = [ - "build/cpu1/inc/cfe_platform_cfg.h", - "build/cpu1/inc/osconfig.h", - "build/mission_inc/cfe_mission_cfg.h", - "cfe/fsw/cfe-core/src/inc/*", - "osal/src/os/inc/*", - "psp/fsw/pc-composite/inc/*", - "psp/fsw/inc/*" -] - -CFE_APPS = [ - ("sch_lab", "sch_lab_app.o"), - ("sample_lib", "sample_lib.o"), - ("sample_app", "sample_app.o") -] - -# Just some shell magic to load the environment variable exports needed to build cFE. -cfe_env = sp.Popen(["bash", "-c", - "trap 'env' exit; cd {} && source \"$1\" > /dev/null 2>&1".format(CFE_DIR), - "_", "setvars.sh"], shell=False, stdout=sp.PIPE).communicate()[0] -os.environ.update(dict([line.split('=', 1) for line in filter(None, cfe_env.split("\n"))])) - -print """ -############## -## BUILDING ## -############## -""" - -OUT = "" -if args.skew: - "Warnings about clock skew will not be printed." - OUT = " 2>&1 | grep -vP 'Clock skew|in the future'" - -# Execute build -if args.clean: - print "=== Cleaning Composite ===" - sp.check_call("rm -rf *", shell=True, cwd=COMPOSITE_TRANSFER_DIR) - sp.check_call("make clean" + OUT, shell=True, cwd=COMPOSITE_MAKE_ROOT) - print "=== Cleaning cFE ===" - sp.check_call("make clean" + OUT, shell=True, cwd=CFE_MAKE_ROOT) - -print "=== Copying headers ===" -if not os.path.exists(COMPOSITE_CFE_HEADER_DESTINATION): - print "cFE header destination folder not found. Creating it now." - os.makedirs(COMPOSITE_CFE_HEADER_DESTINATION) -for header in CFE_HEADERS_TO_COPY: - sp.check_call("cp -ur " + CFE_DIR + header + " " + COMPOSITE_CFE_HEADER_DESTINATION, shell=True) - -if args.unit_tests: - print "=== Building unit tests ===" - sp.call("make" + OUT, shell=True, cwd=OSAL_UT_DIR) - print "Cleaning old test objects..." - if os.path.exists(COMPOSITE_CFE_UT_DESTINATION): - shutil.rmtree(COMPOSITE_CFE_UT_DESTINATION) - os.mkdir(COMPOSITE_CFE_UT_DESTINATION) - print "Copying UT objects..." - for obj in os.listdir(OSAL_UT_DIR): - if obj not in OSAL_UT_OBJECTS_TO_SKIP and os.path.isfile(OSAL_UT_DIR + obj): - shutil.copy(OSAL_UT_DIR + obj, COMPOSITE_CFE_UT_DESTINATION) - print "Copied {} to {}".format(obj, COMPOSITE_CFE_UT_DESTINATION) - print "Copying UT headers..." - for folder in OSAL_UT_HEADERS_TO_COPY: - shutil.copytree(OSAL_UT_DIR + folder, COMPOSITE_CFE_UT_DESTINATION + folder) - print "Copied {} to {}".format(folder, COMPOSITE_CFE_UT_DESTINATION) - -if args.copy_only: - sys.exit(0) - -print "=== Building cFE ===" - -sp.check_call("make" + OUT, shell=True, cwd=CFE_MAKE_ROOT) - -print "=== Copying cFE Object ===" -OBJECT_SOURCE = CFE_OBJECT_LOCATION + CFE_OBJECT_NAME -OBJECT_DESTINATION = COMPOSITE_CFE_COMPONENT_ROOT + CFE_OBJECT_NAME -if os.path.exists(OBJECT_DESTINATION): - os.remove(OBJECT_DESTINATION) -if not os.path.exists(OBJECT_SOURCE): - raise RuntimeError("Could not find cFE object to copy!") -shutil.copy(OBJECT_SOURCE, OBJECT_DESTINATION) -print "Copied {} to {}".format(OBJECT_SOURCE, OBJECT_DESTINATION) - -print "=== Copying apps ===" -for (app, obj) in CFE_APPS: - src = CFE_MAKE_ROOT + app + "/" + obj - dest = COMPOSITE_IMPL_NO_INTERFACE_DIR + app + "/cFE_" + obj - print "Copying app '{}' to '{}'.".format(src, dest) - shutil.copy(src, dest) - -print "=== Integrating Tar Filesystem ===" -sp.check_call("tar cf cFE_fs.tar --exclude=\"cf/apps/composite_cFE.o\" cf/" + OUT, - shell=True, cwd=CFE_OBJECT_LOCATION) -sp.check_call("ld -r -b binary cFE_fs.tar -o cFE_fs.o" + OUT, - shell=True, cwd=CFE_OBJECT_LOCATION) -shutil.copy(CFE_OBJECT_LOCATION + "/cFE_fs.o", COMPOSITE_CFE_COMPONENT_ROOT) From aa50fd7b8d615a766c1c9af07caaa7c9d285ca23 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sat, 24 Mar 2018 14:15:24 -0400 Subject: [PATCH 102/122] Fix the location of cFE_emu.h --- .../no_interface/cFE_booter/cFE_emu_support.c | 8 ++++---- src/components/{include => interface/cFE}/cFE_emu.h | 0 src/components/interface/cFE/stubs/c_stub.c | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) rename src/components/{include => interface/cFE}/cFE_emu.h (100%) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c index 1985deaa14..e0cc4507a5 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -6,21 +6,21 @@ #include -#include - #include +#include + union shared_region *shared_regions[16]; int emu_backend_request_memory(spdid_t client) -{ +{ vaddr_t our_addr = 0; int id = memmgr_shared_page_alloc(&our_addr); assert(our_addr); shared_regions[client] = (void *)our_addr; - + return id; } diff --git a/src/components/include/cFE_emu.h b/src/components/interface/cFE/cFE_emu.h similarity index 100% rename from src/components/include/cFE_emu.h rename to src/components/interface/cFE/cFE_emu.h diff --git a/src/components/interface/cFE/stubs/c_stub.c b/src/components/interface/cFE/stubs/c_stub.c index 6a9aab4936..5becf7da2b 100644 --- a/src/components/interface/cFE/stubs/c_stub.c +++ b/src/components/interface/cFE/stubs/c_stub.c @@ -1,11 +1,13 @@ #include +#include #include #include #include "../interface/capmgr/memmgr.h" #include #include +#include #include From 6bb6eb5be8af8da708dcef0732b3b9a8af2dfb25 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sat, 24 Mar 2018 18:12:44 -0400 Subject: [PATCH 103/122] Alphabetize cFE stubs --- .../no_interface/cFE_booter/cFE_emu_support.c | 72 +++++---- src/components/interface/cFE/cFE_emu.h | 27 ++-- src/components/interface/cFE/stubs/c_stub.c | 143 ++++++++++-------- src/components/interface/cFE/stubs/s_stub.S | 18 ++- 4 files changed, 148 insertions(+), 112 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c index e0cc4507a5..b87bc6e9c4 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -14,7 +14,7 @@ union shared_region *shared_regions[16]; int emu_backend_request_memory(spdid_t client) -{ +{ vaddr_t our_addr = 0; int id = memmgr_shared_page_alloc(&our_addr); @@ -24,6 +24,13 @@ emu_backend_request_memory(spdid_t client) return id; } +int32 +emu_CFE_ES_RunLoop(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_ES_RunLoop(&s->cfe_es_runLoop.RunStatus); +} + int32 emu_CFE_EVS_Register(spdid_t client) { @@ -40,14 +47,6 @@ emu_CFE_SB_CreatePipe(spdid_t client) s->cfe_sb_createPipe.PipeName); } -void -emu_CFE_SB_InitMsg(spdid_t client) -{ - union shared_region *s = shared_regions[client]; - CFE_SB_InitMsg(s->cfe_sb_initMsg.MsgBuffer, s->cfe_sb_initMsg.MsgId, s->cfe_sb_initMsg.Length, - s->cfe_sb_initMsg.Clear); -} - int32 emu_CFE_EVS_SendEvent(spdid_t client) { @@ -56,11 +55,34 @@ emu_CFE_EVS_SendEvent(spdid_t client) s->cfe_evs_sendEvent.Msg); } -int32 -emu_CFE_ES_RunLoop(spdid_t client) + +uint16 +emu_CFE_SB_GetCmdCode(spdid_t client) { union shared_region *s = shared_regions[client]; - return CFE_ES_RunLoop(&s->cfe_es_runLoop.RunStatus); + return CFE_SB_GetCmdCode((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); +} + +CFE_SB_MsgId_t +emu_CFE_SB_GetMsgId(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_SB_GetMsgId((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); +} + +uint16 +emu_CFE_SB_GetTotalMsgLength(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_SB_GetTotalMsgLength(&s->cfe_sb_getMsgLen.Msg); +} + +void +emu_CFE_SB_InitMsg(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + CFE_SB_InitMsg(s->cfe_sb_initMsg.MsgBuffer, s->cfe_sb_initMsg.MsgId, s->cfe_sb_initMsg.Length, + s->cfe_sb_initMsg.Clear); } int32 @@ -82,13 +104,6 @@ emu_CFE_SB_RcvMsg(spdid_t client) return result; } -uint16 -emu_CFE_SB_GetTotalMsgLength(spdid_t client) -{ - union shared_region *s = shared_regions[client]; - return CFE_SB_GetTotalMsgLength(&s->cfe_sb_getMsgLen.Msg); -} - int32 emu_CFE_SB_SendMsg(spdid_t client) { @@ -96,24 +111,23 @@ emu_CFE_SB_SendMsg(spdid_t client) return CFE_SB_SendMsg((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); } -uint16 -emu_CFE_SB_GetCmdCode(spdid_t client) +void +emu_CFE_SB_TimeStampMsg(spdid_t client) { union shared_region *s = shared_regions[client]; - return CFE_SB_GetCmdCode((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); + CFE_SB_TimeStampMsg((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); } -CFE_SB_MsgId_t -emu_CFE_SB_GetMsgId(spdid_t client) -{ + +void +emu_CFE_TIME_GetTime(spdid_t client) { union shared_region *s = shared_regions[client]; - return CFE_SB_GetMsgId((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); + s->time = CFE_TIME_GetTime(); } - void -emu_CFE_SB_TimeStampMsg(spdid_t client) +emu_CFE_TIME_Print(spdid_t client) { union shared_region *s = shared_regions[client]; - CFE_SB_TimeStampMsg((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); + CFE_TIME_Print(s->cfe_time_print.PrintBuffer, s->cfe_time_print.TimeToPrint); } diff --git a/src/components/interface/cFE/cFE_emu.h b/src/components/interface/cFE/cFE_emu.h index 3a12a2f4d0..8899005d09 100644 --- a/src/components/interface/cFE/cFE_emu.h +++ b/src/components/interface/cFE/cFE_emu.h @@ -40,28 +40,29 @@ union shared_region { struct { char Msg[EMU_BUF_SIZE]; } cfe_sb_msg; + CFE_TIME_SysTime_t time; + struct { + char PrintBuffer[CFE_TIME_PRINTED_STRING_SIZE]; + CFE_TIME_SysTime_t TimeToPrint; + } cfe_time_print; }; int emu_backend_request_memory(spdid_t client); +int32 emu_CFE_ES_RunLoop(spdid_t client); + int32 emu_CFE_EVS_Register(spdid_t sp); +int32 emu_CFE_EVS_SendEvent(spdid_t client); int32 emu_CFE_SB_CreatePipe(spdid_t client); - +uint16 emu_CFE_SB_GetCmdCode(spdid_t client); +CFE_SB_MsgId_t emu_CFE_SB_GetMsgId(spdid_t client); +uint16 emu_CFE_SB_GetTotalMsgLength(spdid_t client); void emu_CFE_SB_InitMsg(spdid_t client); - -int32 emu_CFE_EVS_SendEvent(spdid_t client); - -int32 emu_CFE_ES_RunLoop(spdid_t client); - int32 emu_CFE_SB_RcvMsg(spdid_t client); - -uint16 emu_CFE_SB_GetTotalMsgLength(spdid_t client); - int32 emu_CFE_SB_SendMsg(spdid_t client); +void emu_CFE_SB_TimeStampMsg(spdid_t client); -uint16 emu_CFE_SB_GetCmdCode(spdid_t client); +void emu_CFE_TIME_GetTime(spdid_t client); -CFE_SB_MsgId_t emu_CFE_SB_GetMsgId(spdid_t client); - -void emu_CFE_SB_TimeStampMsg(spdid_t client); +void emu_CFE_TIME_Print(spdid_t client); diff --git a/src/components/interface/cFE/stubs/c_stub.c b/src/components/interface/cFE/stubs/c_stub.c index 5becf7da2b..780c9f9ca7 100644 --- a/src/components/interface/cFE/stubs/c_stub.c +++ b/src/components/interface/cFE/stubs/c_stub.c @@ -27,26 +27,15 @@ do_emulation_setup(spdid_t id) shared_region = (void *)client_addr; } - -// FIXME: Query the cFE to decide whether printf is enabled -int is_printf_enabled = 1; - -void -OS_printf(const char *string, ...) +int32 +CFE_ES_RunLoop(uint32 *RunStatus) { - if (is_printf_enabled) { - char s[OS_BUFFER_SIZE]; - va_list arg_ptr; - int ret, len = OS_BUFFER_SIZE; - - va_start(arg_ptr, string); - ret = vsnprintf(s, len, string, arg_ptr); - va_end(arg_ptr); - cos_llprint(s, ret); - } + shared_region->cfe_es_runLoop.RunStatus = *RunStatus; + int32 result = emu_CFE_ES_RunLoop(spdid); + *RunStatus = shared_region->cfe_es_runLoop.RunStatus; + return result; } - int32 CFE_EVS_Register(void * Filters, /* Pointer to an array of filters */ uint16 NumFilteredEvents, /* How many elements in the array? */ uint16 FilterScheme) /* Filtering Algorithm to be implemented */ @@ -60,6 +49,21 @@ int32 CFE_EVS_Register(void * Filters, /* Pointer to an array of filte return emu_CFE_EVS_Register(spdid); } + +int32 +CFE_EVS_SendEvent(uint16 EventID, uint16 EventType, const char *Spec, ...) +{ + va_list Ptr; + va_start(Ptr, Spec); + vsnprintf(shared_region->cfe_evs_sendEvent.Msg, sizeof(shared_region->cfe_evs_sendEvent.Msg), Spec, Ptr); + va_end(Ptr); + + shared_region->cfe_evs_sendEvent.EventID = EventID; + shared_region->cfe_evs_sendEvent.EventType = EventType; + + return emu_CFE_EVS_SendEvent(spdid); +} + int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *PipeName) { @@ -70,6 +74,33 @@ CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *PipeName return ret; } +uint16 +CFE_SB_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr) +{ + uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); + char *msg_ptr = (char *)MsgPtr; + memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); + return emu_CFE_SB_GetCmdCode(spdid); +} + +CFE_SB_MsgId_t +CFE_SB_GetMsgId(CFE_SB_MsgPtr_t MsgPtr) +{ + uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); + char *msg_ptr = (char *)MsgPtr; + memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); + return emu_CFE_SB_GetMsgId(spdid); +} + +uint16 +CFE_SB_GetTotalMsgLength(CFE_SB_MsgPtr_t MsgPtr) +{ + shared_region->cfe_sb_getMsgLen.Msg = *MsgPtr; + return emu_CFE_SB_GetTotalMsgLength(spdid); +} + void CFE_SB_InitMsg(void *MsgPtr, CFE_SB_MsgId_t MsgId, uint16 Length, boolean Clear) { @@ -83,29 +114,6 @@ CFE_SB_InitMsg(void *MsgPtr, CFE_SB_MsgId_t MsgId, uint16 Length, boolean Clear) memcpy(source, shared_region->cfe_sb_initMsg.MsgBuffer, Length); } -int32 -CFE_EVS_SendEvent(uint16 EventID, uint16 EventType, const char *Spec, ...) -{ - va_list Ptr; - va_start(Ptr, Spec); - vsnprintf(shared_region->cfe_evs_sendEvent.Msg, sizeof(shared_region->cfe_evs_sendEvent.Msg), Spec, Ptr); - va_end(Ptr); - - shared_region->cfe_evs_sendEvent.EventID = EventID; - shared_region->cfe_evs_sendEvent.EventType = EventType; - - return emu_CFE_EVS_SendEvent(spdid); -} - -int32 -CFE_ES_RunLoop(uint32 *RunStatus) -{ - shared_region->cfe_es_runLoop.RunStatus = *RunStatus; - int32 result = emu_CFE_ES_RunLoop(spdid); - *RunStatus = shared_region->cfe_es_runLoop.RunStatus; - return result; -} - /* * We want the msg to live in this app, not the cFE component * But the message is stored in a buffer on the cFE side @@ -130,13 +138,6 @@ CFE_SB_RcvMsg(CFE_SB_MsgPtr_t *BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut) return result; } -uint16 -CFE_SB_GetTotalMsgLength(CFE_SB_MsgPtr_t MsgPtr) -{ - shared_region->cfe_sb_getMsgLen.Msg = *MsgPtr; - return emu_CFE_SB_GetTotalMsgLength(spdid); -} - int32 CFE_SB_SendMsg(CFE_SB_Msg_t *MsgPtr) { @@ -147,33 +148,47 @@ CFE_SB_SendMsg(CFE_SB_Msg_t *MsgPtr) return emu_CFE_SB_SendMsg(spdid); } -uint16 -CFE_SB_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr) + +void +CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr) { uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); assert(msg_len <= EMU_BUF_SIZE); char *msg_ptr = (char *)MsgPtr; memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); - return emu_CFE_SB_GetCmdCode(spdid); + emu_CFE_SB_TimeStampMsg(spdid); + memcpy(msg_ptr, shared_region->cfe_sb_msg.Msg, (size_t)msg_len); } -CFE_SB_MsgId_t -CFE_SB_GetMsgId(CFE_SB_MsgPtr_t MsgPtr) +CFE_TIME_SysTime_t +CFE_TIME_GetTime(void) { - uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); - assert(msg_len <= EMU_BUF_SIZE); - char *msg_ptr = (char *)MsgPtr; - memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); - return emu_CFE_SB_GetMsgId(spdid); + emu_CFE_TIME_GetTime(spdid); + return shared_region->time; } void -CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr) +CFE_TIME_Print(char *PrintBuffer, CFE_TIME_SysTime_t TimeToPrint) { - uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); - assert(msg_len <= EMU_BUF_SIZE); - char *msg_ptr = (char *)MsgPtr; - memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); - emu_CFE_SB_TimeStampMsg(spdid); - memcpy(msg_ptr, shared_region->cfe_sb_msg.Msg, (size_t)msg_len); + shared_region->cfe_time_print.TimeToPrint = TimeToPrint; + emu_CFE_TIME_Print(spdid); + memcpy(PrintBuffer, shared_region->cfe_time_print.PrintBuffer, CFE_TIME_PRINTED_STRING_SIZE); +} + +// FIXME: Query the cFE to decide whether printf is enabled +int is_printf_enabled = 1; + +void +OS_printf(const char *string, ...) +{ + if (is_printf_enabled) { + char s[OS_BUFFER_SIZE]; + va_list arg_ptr; + int ret, len = OS_BUFFER_SIZE; + + va_start(arg_ptr, string); + ret = vsnprintf(s, len, string, arg_ptr); + va_end(arg_ptr); + cos_llprint(s, ret); + } } diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index 15f9e4f5b0..048a178b5c 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -5,7 +5,6 @@ * Public License v2. */ -//#include #define __ASM__ #include #include @@ -20,15 +19,22 @@ cos_asm_server_stub(CFE_ES_RegisterApp) cos_asm_server_stub(CFE_SB_Subscribe) +// Emulated methods cos_asm_server_stub(emu_backend_request_memory) + +cos_asm_server_stub(emu_CFE_ES_RunLoop) + cos_asm_server_stub(emu_CFE_EVS_Register) +cos_asm_server_stub(emu_CFE_EVS_SendEvent) + cos_asm_server_stub(emu_CFE_SB_CreatePipe) +cos_asm_server_stub(emu_CFE_SB_GetCmdCode) +cos_asm_server_stub(emu_CFE_SB_GetMsgId) +cos_asm_server_stub(emu_CFE_SB_GetTotalMsgLength) cos_asm_server_stub(emu_CFE_SB_InitMsg) -cos_asm_server_stub(emu_CFE_EVS_SendEvent) -cos_asm_server_stub(emu_CFE_ES_RunLoop) cos_asm_server_stub(emu_CFE_SB_RcvMsg) -cos_asm_server_stub(emu_CFE_SB_GetTotalMsgLength) cos_asm_server_stub(emu_CFE_SB_SendMsg) -cos_asm_server_stub(emu_CFE_SB_GetCmdCode) -cos_asm_server_stub(emu_CFE_SB_GetMsgId) cos_asm_server_stub(emu_CFE_SB_TimeStampMsg) + +cos_asm_server_stub(emu_CFE_TIME_GetTime) +cos_asm_server_stub(emu_CFE_TIME_Print) From 480e92c3c077fa8963878b784c28daecd1e74c31 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sun, 25 Mar 2018 00:41:03 -0400 Subject: [PATCH 104/122] Implement more cFE interface stubs --- .../no_interface/cFE_booter/cFE_emu_support.c | 63 +++++++++++++ src/components/interface/cFE/cFE_emu.h | 40 +++++++- src/components/interface/cFE/stubs/c_stub.c | 92 +++++++++++++++++++ src/components/interface/cFE/stubs/s_stub.S | 21 +++++ 4 files changed, 215 insertions(+), 1 deletion(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c index b87bc6e9c4..d467c5a77d 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -24,6 +24,34 @@ emu_backend_request_memory(spdid_t client) return id; } +int32 +emu_CFE_ES_GetGenCount(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_ES_GetGenCount(s->cfe_es_getGenCount.CounterId, &s->cfe_es_getGenCount.Count); +} + +int32 +emu_CFE_ES_GetGenCounterIDByName(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_ES_GetGenCounterIDByName(&s->cfe_es_getGenCounterIDByName.CounterId, s->cfe_es_getGenCounterIDByName.CounterName); +} + +int32 +emu_CFE_ES_GetResetType(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_ES_GetResetType(&s->cfe_es_getResetType.ResetSubtype); +} + +int32 +emu_CFE_ES_GetTaskInfo(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_ES_GetTaskInfo(&s->cfe_es_getTaskInfo.TaskInfo, s->cfe_es_getTaskInfo.TaskId); +} + int32 emu_CFE_ES_RunLoop(spdid_t client) { @@ -70,6 +98,14 @@ emu_CFE_SB_GetMsgId(spdid_t client) return CFE_SB_GetMsgId((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); } +void +emu_CFE_SB_GetMsgTime(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + CFE_TIME_SysTime_t time = CFE_SB_GetMsgTime((CFE_SB_MsgPtr_t)&s->cfe_sb_msg.Msg); + s->time = time; +} + uint16 emu_CFE_SB_GetTotalMsgLength(spdid_t client) { @@ -104,6 +140,13 @@ emu_CFE_SB_RcvMsg(spdid_t client) return result; } +int32 +emu_CFE_SB_SetCmdCode(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t)s->cfe_sb_setCmdCode.Msg, s->cfe_sb_setCmdCode.CmdCode); +} + int32 emu_CFE_SB_SendMsg(spdid_t client) { @@ -118,6 +161,26 @@ emu_CFE_SB_TimeStampMsg(spdid_t client) CFE_SB_TimeStampMsg((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); } +boolean +emu_CFE_SB_ValidateChecksum(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_SB_ValidateChecksum((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); +} + +void +emu_CFE_TIME_Add(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + s->cfe_time_add.Result = CFE_TIME_Add(s->cfe_time_add.Time1, s->cfe_time_add.Time2); +} + +void +emu_CFE_TIME_Compare(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + s->cfe_time_compare.Result = CFE_TIME_Compare(s->cfe_time_compare.Time1, s->cfe_time_compare.Time2); +} void emu_CFE_TIME_GetTime(spdid_t client) { diff --git a/src/components/interface/cFE/cFE_emu.h b/src/components/interface/cFE/cFE_emu.h index 8899005d09..95cec4480c 100644 --- a/src/components/interface/cFE/cFE_emu.h +++ b/src/components/interface/cFE/cFE_emu.h @@ -4,6 +4,7 @@ #define EMU_BUF_SIZE 512 +/* TODO: Alphabetize me! */ union shared_region { struct { CFE_EVS_BinFilter_t filters[CFE_EVS_MAX_EVENT_FILTERS]; @@ -45,10 +46,43 @@ union shared_region { char PrintBuffer[CFE_TIME_PRINTED_STRING_SIZE]; CFE_TIME_SysTime_t TimeToPrint; } cfe_time_print; + struct { + char Msg[EMU_BUF_SIZE]; + uint16 CmdCode; + } cfe_sb_setCmdCode; + struct { + CFE_TIME_SysTime_t Time1; + CFE_TIME_SysTime_t Time2; + CFE_TIME_SysTime_t Result; + } cfe_time_add; + struct { + CFE_TIME_SysTime_t Time1; + CFE_TIME_SysTime_t Time2; + CFE_TIME_Compare_t Result; + } cfe_time_compare; + struct { + CFE_ES_TaskInfo_t TaskInfo; + uint32 TaskId; + } cfe_es_getTaskInfo; + struct { + uint32 ResetSubtype; + } cfe_es_getResetType; + struct { + uint32 CounterId; + uint32 Count; + } cfe_es_getGenCount; + struct { + uint32 CounterId; + char CounterName[EMU_BUF_SIZE]; + } cfe_es_getGenCounterIDByName; }; int emu_backend_request_memory(spdid_t client); +int32 emu_CFE_ES_GetGenCount(spdid_t client); +int32 emu_CFE_ES_GetGenCounterIDByName(spdid_t client); +int32 emu_CFE_ES_GetResetType(spdid_t client); +int32 emu_CFE_ES_GetTaskInfo(spdid_t client); int32 emu_CFE_ES_RunLoop(spdid_t client); int32 emu_CFE_EVS_Register(spdid_t sp); @@ -57,12 +91,16 @@ int32 emu_CFE_EVS_SendEvent(spdid_t client); int32 emu_CFE_SB_CreatePipe(spdid_t client); uint16 emu_CFE_SB_GetCmdCode(spdid_t client); CFE_SB_MsgId_t emu_CFE_SB_GetMsgId(spdid_t client); +void emu_CFE_SB_GetMsgTime(spdid_t client); uint16 emu_CFE_SB_GetTotalMsgLength(spdid_t client); void emu_CFE_SB_InitMsg(spdid_t client); int32 emu_CFE_SB_RcvMsg(spdid_t client); +int32 emu_CFE_SB_SetCmdCode(spdid_t client); int32 emu_CFE_SB_SendMsg(spdid_t client); void emu_CFE_SB_TimeStampMsg(spdid_t client); +boolean emu_CFE_SB_ValidateChecksum(spdid_t client); +void emu_CFE_TIME_Add(spdid_t client); +void emu_CFE_TIME_Compare(spdid_t client); void emu_CFE_TIME_GetTime(spdid_t client); - void emu_CFE_TIME_Print(spdid_t client); diff --git a/src/components/interface/cFE/stubs/c_stub.c b/src/components/interface/cFE/stubs/c_stub.c index 780c9f9ca7..2ba62e32c5 100644 --- a/src/components/interface/cFE/stubs/c_stub.c +++ b/src/components/interface/cFE/stubs/c_stub.c @@ -27,6 +27,43 @@ do_emulation_setup(spdid_t id) shared_region = (void *)client_addr; } + +// FIXME: Be more careful about user supplied pointers +int32 +CFE_ES_GetGenCount(uint32 CounterId, uint32 *Count) +{ + shared_region->cfe_es_getGenCount.CounterId = CounterId; + int32 result = emu_CFE_ES_GetGenCount(spdid); + *Count = shared_region->cfe_es_getGenCount.Count; + return result; +} + +int32 +CFE_ES_GetGenCounterIDByName(uint32 *CounterIdPtr, const char *CounterName) +{ + strcpy(shared_region->cfe_es_getGenCounterIDByName.CounterName, CounterName); + int32 result = emu_CFE_ES_GetGenCounterIDByName(spdid); + *CounterIdPtr = shared_region->cfe_es_getGenCounterIDByName.CounterId; + return result; +} + +int32 +CFE_ES_GetResetType(uint32 *ResetSubtypePtr) +{ + int32 result = emu_CFE_ES_GetResetType(spdid); + *ResetSubtypePtr = shared_region->cfe_es_getResetType.ResetSubtype; + return result; +} + +int32 +CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, uint32 TaskId) +{ + shared_region->cfe_es_getTaskInfo.TaskId = TaskId; + int32 result = emu_CFE_ES_GetTaskInfo(spdid); + *TaskInfo = shared_region->cfe_es_getTaskInfo.TaskInfo; + return result; +} + int32 CFE_ES_RunLoop(uint32 *RunStatus) { @@ -94,6 +131,18 @@ CFE_SB_GetMsgId(CFE_SB_MsgPtr_t MsgPtr) return emu_CFE_SB_GetMsgId(spdid); } + +CFE_TIME_SysTime_t +CFE_SB_GetMsgTime(CFE_SB_MsgPtr_t MsgPtr) +{ + uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); + char *msg_ptr = (char *)MsgPtr; + memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); + emu_CFE_SB_GetMsgTime(spdid); + return shared_region->time; +} + uint16 CFE_SB_GetTotalMsgLength(CFE_SB_MsgPtr_t MsgPtr) { @@ -138,6 +187,21 @@ CFE_SB_RcvMsg(CFE_SB_MsgPtr_t *BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut) return result; } +int32 CFE_SB_SetCmdCode(CFE_SB_MsgPtr_t MsgPtr, uint16 CmdCode) +{ + uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); + char *msg_ptr = (char *)MsgPtr; + + memcpy(shared_region->cfe_sb_setCmdCode.Msg, msg_ptr, (size_t)msg_len); + shared_region->cfe_sb_setCmdCode.CmdCode = CmdCode; + + int32 result = emu_CFE_SB_SetCmdCode(spdid); + /* TODO: Verify we can assume the msg_len won't change */ + memcpy(msg_ptr, shared_region->cfe_sb_setCmdCode.Msg, msg_len); + return result; +} + int32 CFE_SB_SendMsg(CFE_SB_Msg_t *MsgPtr) { @@ -160,6 +224,34 @@ CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr) memcpy(msg_ptr, shared_region->cfe_sb_msg.Msg, (size_t)msg_len); } +boolean +CFE_SB_ValidateChecksum (CFE_SB_MsgPtr_t MsgPtr) +{ + uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); + char *msg_ptr = (char *)MsgPtr; + memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); + return emu_CFE_SB_ValidateChecksum(spdid); +} + +CFE_TIME_SysTime_t +CFE_TIME_Add(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Time2) +{ + shared_region->cfe_time_add.Time1 = Time1; + shared_region->cfe_time_add.Time2 = Time2; + emu_CFE_TIME_Add(spdid); + return shared_region->cfe_time_add.Result; +} + +CFE_TIME_Compare_t +CFE_TIME_Compare(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Time2) +{ + shared_region->cfe_time_compare.Time1 = Time1; + shared_region->cfe_time_compare.Time2 = Time2; + emu_CFE_TIME_Compare(spdid); + return shared_region->cfe_time_compare.Result; +} + CFE_TIME_SysTime_t CFE_TIME_GetTime(void) { diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index 048a178b5c..f8f52f288b 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -13,15 +13,31 @@ cos_asm_server_stub(OS_IdleLoop) +cos_asm_server_stub(CFE_ES_DeleteApp) cos_asm_server_stub(CFE_ES_ExitApp) cos_asm_server_stub(CFE_ES_PerfLogAdd) cos_asm_server_stub(CFE_ES_RegisterApp) +cos_asm_server_stub(CFE_ES_ResetCFE) +cos_asm_server_stub(CFE_ES_RestartApp) + +cos_asm_server_stub(CFE_PSP_WatchdogDisable) +cos_asm_server_stub(CFE_PSP_WatchdogEnable) +cos_asm_server_stub(CFE_PSP_WatchdogSet) +cos_asm_server_stub(CFE_PSP_WatchdogService) cos_asm_server_stub(CFE_SB_Subscribe) +cos_asm_server_stub(CFE_TBL_NotifyByMessage) + +cos_asm_server_stub(CFE_TIME_FS2CFESeconds) + // Emulated methods cos_asm_server_stub(emu_backend_request_memory) +cos_asm_server_stub(emu_CFE_ES_GetGenCount) +cos_asm_server_stub(emu_CFE_ES_GetGenCounterIDByName) +cos_asm_server_stub(emu_CFE_ES_GetResetType) +cos_asm_server_stub(emu_CFE_ES_GetTaskInfo) cos_asm_server_stub(emu_CFE_ES_RunLoop) cos_asm_server_stub(emu_CFE_EVS_Register) @@ -30,11 +46,16 @@ cos_asm_server_stub(emu_CFE_EVS_SendEvent) cos_asm_server_stub(emu_CFE_SB_CreatePipe) cos_asm_server_stub(emu_CFE_SB_GetCmdCode) cos_asm_server_stub(emu_CFE_SB_GetMsgId) +cos_asm_server_stub(emu_CFE_SB_GetMsgTime) cos_asm_server_stub(emu_CFE_SB_GetTotalMsgLength) cos_asm_server_stub(emu_CFE_SB_InitMsg) cos_asm_server_stub(emu_CFE_SB_RcvMsg) +cos_asm_server_stub(emu_CFE_SB_SetCmdCode) cos_asm_server_stub(emu_CFE_SB_SendMsg) cos_asm_server_stub(emu_CFE_SB_TimeStampMsg) +cos_asm_server_stub(emu_CFE_SB_ValidateChecksum) +cos_asm_server_stub(emu_CFE_TIME_Add) +cos_asm_server_stub(emu_CFE_TIME_Compare) cos_asm_server_stub(emu_CFE_TIME_GetTime) cos_asm_server_stub(emu_CFE_TIME_Print) From badba1a2208ff07b7f2ddfe5a2273777c95c528d Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 26 Mar 2018 23:39:20 -0400 Subject: [PATCH 105/122] Implement many more stub functions --- .../no_interface/cFE_booter/Makefile | 2 +- .../no_interface/cFE_booter/cFE_emu_support.c | 147 +++++++++++ .../no_interface/cFE_booter/ostask.c | 1 - .../cFE_booter/sl_thd_static_backend.c | 66 +++++ src/components/interface/cFE/cFE_emu.h | 108 +++++++++ src/components/interface/cFE/stubs/c_stub.c | 229 ++++++++++++++++++ src/components/interface/cFE/stubs/s_stub.S | 39 ++- 7 files changed, 588 insertions(+), 4 deletions(-) create mode 100644 src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index 8e7f5e8e2b..98ed424117 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -4,7 +4,7 @@ COMPONENT=cFE_booter.o INTERFACES=cFE DEPENDENCIES=capmgr IF_LIB:=./composite_cFE.o ./cFE_fs.o $(wildcard test/*.o) -ADDITIONAL_LIBS=-lcobj_format $(LIBSLCAPMGR) -lheap -lsl_lock -lsl_thd_static_backend +ADDITIONAL_LIBS=-lcobj_format $(LIBSLCAPMGR) -lheap -lsl_lock include ../../Makefile.subsubdir CFLAGS += -I./gen -I ./test/shared $(CPPFLAGS) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c index d467c5a77d..2e02e62a37 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -67,6 +67,21 @@ emu_CFE_EVS_Register(spdid_t client) s->cfe_evs_register.FilterScheme); } +int32 +emu_CFE_FS_Decompress(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_FS_Decompress(s->cfe_fs_decompress.SourceFile, s->cfe_fs_decompress.DestinationFile); +} + + +int32 +emu_CFE_FS_WriteHeader(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_FS_WriteHeader(s->cfe_fs_writeHeader.FileDes, &s->cfe_fs_writeHeader.Hdr); +} + int32 emu_CFE_SB_CreatePipe(spdid_t client) { @@ -194,3 +209,135 @@ emu_CFE_TIME_Print(spdid_t client) union shared_region *s = shared_regions[client]; CFE_TIME_Print(s->cfe_time_print.PrintBuffer, s->cfe_time_print.TimeToPrint); } + +int32 +emu_OS_cp(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_cp(s->os_cp.src, s->os_cp.dest); +} + +int32 +emu_OS_creat(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_creat(s->os_creat.path, s->os_creat.access); +} + +int32 +emu_OS_FDGetInfo(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_FDGetInfo(s->os_FDGetInfo.filedes, &s->os_FDGetInfo.fd_prop); +} + +int32 +emu_OS_fsBytesFree(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_fsBytesFree(s->os_fsBytesFree.name, &s->os_fsBytesFree.bytes_free); +} + +int32 +emu_OS_mkdir(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_mkdir(s->os_mkdir.path, s->os_mkdir.access); +} + +os_dirp_t +emu_OS_opendir(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_opendir(s->os_opendir.path); +} + +int32 +emu_OS_mv(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_mv(s->os_cp.src, s->os_cp.dest); +} + +int32 +emu_OS_read(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_read(s->os_read.filedes, s->os_read.buffer, s->os_read.nbytes); +} + +void +emu_OS_readdir(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + s->os_readdir.dirent = *OS_readdir(s->os_readdir.directory); +} + +int32 +emu_OS_remove(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_remove(s->os_remove.path); +} + +int32 +emu_OS_rename(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_rename(s->os_rename.old_filename, s->os_rename.new_filename); +} + +int32 +emu_OS_rmdir(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_rmdir(s->os_rmdir.path); +} + +int32 +emu_OS_stat(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_stat(s->os_stat.path, &s->os_stat.filestats); +} + +int32 +emu_OS_write(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_write(s->os_write.filedes, s->os_write.buffer, s->os_write.nbytes); +} + +int32 +emu_OS_BinSemCreate(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_BinSemCreate(&s->os_semCreate.sem_id, s->os_semCreate.sem_name, s->os_semCreate.sem_initial_value, s->os_semCreate.options); +} + +int32 +emu_OS_CountSemCreate(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_CountSemCreate(&s->os_semCreate.sem_id, s->os_semCreate.sem_name, s->os_semCreate.sem_initial_value, s->os_semCreate.options); +} + +int32 emu_OS_MutSemCreate(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_MutSemCreate(&s->os_mutSemCreate.sem_id, s->os_mutSemCreate.sem_name, s->os_mutSemCreate.options); +} + +int32 +emu_OS_TaskGetIdByName(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_TaskGetIdByName(&s->os_taskGetIdByName.task_id, s->os_taskGetIdByName.task_name); +} + +int32 +emu_OS_SymbolLookup(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_SymbolLookup(&s->os_symbolLookup.symbol_address, s->os_symbolLookup.symbol_name); +} diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index a1ca721cde..03a336c7ce 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -14,7 +14,6 @@ void timer_fn_1hz(void *d) { - int first = 0; cycles_t now, start; rdtscll(start); diff --git a/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c b/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c new file mode 100644 index 0000000000..e588780a46 --- /dev/null +++ b/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c @@ -0,0 +1,66 @@ +/** + * Redistribution of this file is permitted under the BSD two clause license. + * + * Copyright 2017, The George Washington University + * Author: Gabriel Parmer, gparmer@gwu.edu + */ +#include +#include +#include +#include +#include + + +static struct sl_thd_policy __sl_threads[SL_MAX_NUM_THDS]; + +static struct cos_aep_info __sl_aep_infos[SL_MAX_NUM_THDS]; +static u32_t __sl_aep_free_off; + +/* Default implementations of backend functions */ +struct sl_thd_policy * +sl_thd_alloc_backend(thdid_t tid) +{ + assert(tid < SL_MAX_NUM_THDS); + return &__sl_threads[tid]; +} + +struct cos_aep_info * +sl_thd_alloc_aep_backend(void) +{ + struct cos_aep_info *aep = NULL; + + assert(__sl_aep_free_off < SL_MAX_NUM_THDS); + aep = &__sl_aep_infos[__sl_aep_free_off]; + __sl_aep_free_off++; + + return aep; +} + +void +sl_thd_free_backend(struct sl_thd_policy *t) +{ } + +void +sl_thd_index_add_backend(struct sl_thd_policy *t) +{ } + +void +sl_thd_index_rem_backend(struct sl_thd_policy *t) +{ } + +struct sl_thd_policy * +sl_thd_lookup_backend(thdid_t tid) +{ + assert(tid < SL_MAX_NUM_THDS); + return &__sl_threads[tid]; +} + +void +sl_thd_init_backend(void) +{ + assert(SL_MAX_NUM_THDS <= MAX_NUM_THREADS); + + memset(__sl_threads, 0, sizeof(struct sl_thd_policy)*SL_MAX_NUM_THDS); + memset(__sl_aep_infos, 0, sizeof(struct cos_aep_info)*SL_MAX_NUM_THDS); + __sl_aep_free_off = 0; +} diff --git a/src/components/interface/cFE/cFE_emu.h b/src/components/interface/cFE/cFE_emu.h index 95cec4480c..b6ea089d7c 100644 --- a/src/components/interface/cFE/cFE_emu.h +++ b/src/components/interface/cFE/cFE_emu.h @@ -1,6 +1,7 @@ #include #include +#include #define EMU_BUF_SIZE 512 @@ -75,6 +76,88 @@ union shared_region { uint32 CounterId; char CounterName[EMU_BUF_SIZE]; } cfe_es_getGenCounterIDByName; + struct { + int32 FileDes; + CFE_FS_Header_t Hdr; + } cfe_fs_writeHeader; + struct { + char SourceFile[EMU_BUF_SIZE]; + char DestinationFile[EMU_BUF_SIZE]; + } cfe_fs_decompress; + struct { + char path[EMU_BUF_SIZE]; + int32 access; + } os_creat; + struct { + int32 filedes; + char buffer[EMU_BUF_SIZE]; + uint32 nbytes; + } os_write; + struct { + cpuaddr symbol_address; + char symbol_name[EMU_BUF_SIZE]; + } os_symbolLookup; + struct { + uint32 sem_id; + char sem_name[EMU_BUF_SIZE]; + uint32 sem_initial_value; + uint32 options; + } os_semCreate; + struct { + char src[EMU_BUF_SIZE]; + char dest[EMU_BUF_SIZE]; + } os_cp; + struct { + int32 filedes; + OS_FDTableEntry fd_prop; + } os_FDGetInfo; + struct { + char name[EMU_BUF_SIZE]; + uint64 bytes_free; + } os_fsBytesFree; + struct { + char path[EMU_BUF_SIZE]; + uint32 access; + } os_mkdir; + struct { + uint32 sem_id; + char sem_name[EMU_BUF_SIZE]; + uint32 options; + } os_mutSemCreate; + struct { + char src[EMU_BUF_SIZE]; + char dest[EMU_BUF_SIZE]; + } os_mv; + struct { + char path[EMU_BUF_SIZE]; + } os_opendir; + struct { + int32 filedes; + char buffer[EMU_BUF_SIZE]; + uint32 nbytes; + } os_read; + struct { + char path[EMU_BUF_SIZE]; + } os_remove; + struct { + char old_filename[EMU_BUF_SIZE]; + char new_filename[EMU_BUF_SIZE]; + } os_rename; + struct { + char path[EMU_BUF_SIZE]; + } os_rmdir; + struct { + char path[EMU_BUF_SIZE]; + os_fstat_t filestats; + } os_stat; + struct { + os_dirp_t directory; + os_dirent_t dirent; + } os_readdir; + struct { + uint32 task_id; + char task_name[EMU_BUF_SIZE]; + } os_taskGetIdByName; }; int emu_backend_request_memory(spdid_t client); @@ -88,6 +171,9 @@ int32 emu_CFE_ES_RunLoop(spdid_t client); int32 emu_CFE_EVS_Register(spdid_t sp); int32 emu_CFE_EVS_SendEvent(spdid_t client); +int32 emu_CFE_FS_Decompress(spdid_t client); +int32 emu_CFE_FS_WriteHeader(spdid_t client); + int32 emu_CFE_SB_CreatePipe(spdid_t client); uint16 emu_CFE_SB_GetCmdCode(spdid_t client); CFE_SB_MsgId_t emu_CFE_SB_GetMsgId(spdid_t client); @@ -104,3 +190,25 @@ void emu_CFE_TIME_Add(spdid_t client); void emu_CFE_TIME_Compare(spdid_t client); void emu_CFE_TIME_GetTime(spdid_t client); void emu_CFE_TIME_Print(spdid_t client); + +int32 emu_OS_cp(spdid_t client); +int32 emu_OS_creat(spdid_t client); +int32 emu_OS_FDGetInfo(spdid_t client); +int32 emu_OS_fsBytesFree(spdid_t client); +int32 emu_OS_mkdir(spdid_t client); +int32 emu_OS_mv(spdid_t client); +os_dirp_t emu_OS_opendir(spdid_t client); +int32 emu_OS_read(spdid_t client); +void emu_OS_readdir(spdid_t client); +int32 emu_OS_remove(spdid_t client); +int32 emu_OS_rename(spdid_t client); +int32 emu_OS_rmdir(spdid_t client); +int32 emu_OS_stat(spdid_t client); +int32 emu_OS_write(spdid_t client); + +int32 emu_OS_BinSemCreate(spdid_t client); +int32 emu_OS_CountSemCreate(spdid_t client); +int32 emu_OS_MutSemCreate(spdid_t client); +int32 emu_OS_TaskGetIdByName(spdid_t client); + +int32 emu_OS_SymbolLookup(spdid_t client); diff --git a/src/components/interface/cFE/stubs/c_stub.c b/src/components/interface/cFE/stubs/c_stub.c index 2ba62e32c5..1d85a9ccc2 100644 --- a/src/components/interface/cFE/stubs/c_stub.c +++ b/src/components/interface/cFE/stubs/c_stub.c @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -101,6 +102,26 @@ CFE_EVS_SendEvent(uint16 EventID, uint16 EventType, const char *Spec, ...) return emu_CFE_EVS_SendEvent(spdid); } +int32 +CFE_FS_Decompress(const char *SourceFile, const char *DestinationFile) +{ + assert(strlen(SourceFile) < EMU_BUF_SIZE); + assert(strlen(DestinationFile) < EMU_BUF_SIZE); + + strcpy(shared_region->cfe_fs_decompress.SourceFile, SourceFile); + strcpy(shared_region->cfe_fs_decompress.DestinationFile, DestinationFile); + return emu_CFE_FS_Decompress(spdid); +} + +int32 +CFE_FS_WriteHeader(int32 FileDes, CFE_FS_Header_t *Hdr) +{ + shared_region->cfe_fs_writeHeader.FileDes = FileDes; + int32 result = emu_CFE_FS_WriteHeader(spdid); + *Hdr = shared_region->cfe_fs_writeHeader.Hdr; + return result; +} + int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *PipeName) { @@ -267,6 +288,214 @@ CFE_TIME_Print(char *PrintBuffer, CFE_TIME_SysTime_t TimeToPrint) memcpy(PrintBuffer, shared_region->cfe_time_print.PrintBuffer, CFE_TIME_PRINTED_STRING_SIZE); } +int32 +OS_cp(const char *src, const char *dest) +{ + assert(strlen(src) < EMU_BUF_SIZE); + assert(strlen(dest) < EMU_BUF_SIZE); + strcpy(shared_region->os_cp.src, src); + strcpy(shared_region->os_cp.dest, dest); + return emu_OS_cp(spdid); +} + +int32 +OS_creat(const char *path, int32 access) +{ + assert(strlen(path) < EMU_BUF_SIZE); + + strcpy(shared_region->os_creat.path, path); + shared_region->os_creat.access = access; + return emu_OS_creat(spdid); +} + +int32 +OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) +{ + shared_region->os_FDGetInfo.filedes = filedes; + int32 result = emu_OS_FDGetInfo(spdid); + *fd_prop = shared_region->os_FDGetInfo.fd_prop; + return result; +} + +int32 +OS_fsBytesFree(const char *name, uint64 *bytes_free) +{ + assert(strlen(name) < EMU_BUF_SIZE); + + strcpy(shared_region->os_fsBytesFree.name, name); + int32 result = emu_OS_fsBytesFree(spdid); + *bytes_free = shared_region->os_fsBytesFree.bytes_free; + + return result; +} + +int32 +OS_mkdir(const char *path, uint32 access) +{ + assert(strlen(path) < EMU_BUF_SIZE); + + strcpy(shared_region->os_mkdir.path, path); + shared_region->os_mkdir.access = access; + return emu_OS_mkdir(spdid); +} + +int32 +OS_mv(const char *src, const char *dest) +{ + assert(strlen(src) < EMU_BUF_SIZE); + assert(strlen(dest) < EMU_BUF_SIZE); + + strcpy(shared_region->os_mv.src, src); + strcpy(shared_region->os_mv.dest, dest); + return emu_OS_mv(spdid); +} + +os_dirp_t +OS_opendir(const char *path) +{ + assert(strlen(path) < EMU_BUF_SIZE); + + strcpy(shared_region->os_opendir.path, path); + return emu_OS_opendir(spdid); +} + +int32 +OS_read(int32 filedes, void *buffer, uint32 nbytes) +{ + assert(nbytes <= EMU_BUF_SIZE); + + shared_region->os_read.filedes = filedes; + shared_region->os_read.nbytes = nbytes; + int32 result = emu_OS_read(spdid); + memcpy(buffer, shared_region->os_read.buffer, nbytes); + return result; +} + +int32 +OS_remove(const char *path) +{ + assert(strlen(path) < EMU_BUF_SIZE); + + strcpy(shared_region->os_remove.path, path); + return emu_OS_remove(spdid); +} + + +os_dirent_t buffered_dirent; + +os_dirent_t* +OS_readdir(os_dirp_t directory) +{ + shared_region->os_readdir.directory = directory; + emu_OS_readdir(spdid); + buffered_dirent = shared_region->os_readdir.dirent; + return &buffered_dirent; +} + +int32 +OS_rename(const char *old_filename, const char *new_filename) +{ + assert(strlen(old_filename) < EMU_BUF_SIZE); + assert(strlen(new_filename) < EMU_BUF_SIZE); + + strcpy(shared_region->os_rename.old_filename, old_filename); + strcpy(shared_region->os_rename.new_filename, new_filename); + return emu_OS_rename(spdid); +} + +int32 +OS_rmdir(const char *path) +{ + assert(strlen(path) < EMU_BUF_SIZE); + + strcpy(shared_region->os_rmdir.path, path); + return emu_OS_rmdir(spdid); +} + +int32 +OS_stat(const char *path, os_fstat_t *filestats) +{ + assert(strlen(path) < EMU_BUF_SIZE); + + strcpy(shared_region->os_stat.path, path); + int32 result = emu_OS_stat(spdid); + *filestats = shared_region->os_stat.filestats; + return result; +} + +int32 +OS_write(int32 filedes, void *buffer, uint32 nbytes) +{ + assert(nbytes < EMU_BUF_SIZE); + shared_region->os_write.filedes = filedes; + memcpy(shared_region->os_write.buffer, buffer, nbytes); + shared_region->os_write.nbytes = nbytes; + return emu_OS_write(spdid); +} + + +int32 +OS_BinSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) +{ + assert(strlen(sem_name) < EMU_BUF_SIZE); + + strcpy(shared_region->os_semCreate.sem_name, sem_name); + shared_region->os_semCreate.sem_initial_value = sem_initial_value; + shared_region->os_semCreate.options = options; + int32 result = emu_OS_BinSemCreate(spdid); + *sem_id = shared_region->os_semCreate.sem_id; + return result; +} + +int32 +OS_CountSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) +{ + assert(strlen(sem_name) < EMU_BUF_SIZE); + + strcpy(shared_region->os_semCreate.sem_name, sem_name); + shared_region->os_semCreate.sem_initial_value = sem_initial_value; + shared_region->os_semCreate.options = options; + int32 result = emu_OS_CountSemCreate(spdid); + *sem_id = shared_region->os_semCreate.sem_id; + return result; +} + +int32 +OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) +{ + assert(strlen(sem_name) < EMU_BUF_SIZE); + + strcpy(shared_region->os_mutSemCreate.sem_name, sem_name); + shared_region->os_mutSemCreate.options = options; + int32 result = emu_OS_MutSemCreate(spdid); + *sem_id = shared_region->os_mutSemCreate.sem_id; + + return result; +} + +int32 +OS_TaskGetIdByName(uint32 *task_id, const char *task_name) +{ + assert(strlen(task_name) < EMU_BUF_SIZE); + + strcpy(shared_region->os_taskGetIdByName.task_name, task_name); + int32 result = emu_OS_TaskGetIdByName(spdid); + *task_id = shared_region->os_taskGetIdByName.task_id; + return result; +} + +int32 +OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) +{ + assert(strlen(symbol_name) < EMU_BUF_SIZE); + + strcpy(shared_region->os_symbolLookup.symbol_name, symbol_name); + int32 result = emu_OS_SymbolLookup(spdid); + *symbol_address = shared_region->os_symbolLookup.symbol_address; + return result; +} + +/* Methods that are completly emulated */ // FIXME: Query the cFE to decide whether printf is enabled int is_printf_enabled = 1; diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index f8f52f288b..5f6d9787e9 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -11,8 +11,6 @@ .text -cos_asm_server_stub(OS_IdleLoop) - cos_asm_server_stub(CFE_ES_DeleteApp) cos_asm_server_stub(CFE_ES_ExitApp) cos_asm_server_stub(CFE_ES_PerfLogAdd) @@ -31,6 +29,18 @@ cos_asm_server_stub(CFE_TBL_NotifyByMessage) cos_asm_server_stub(CFE_TIME_FS2CFESeconds) +cos_asm_server_stub(OS_CountSemGive) +cos_asm_server_stub(OS_CountSemTake) +cos_asm_server_stub(OS_IdleLoop) +cos_asm_server_stub(OS_MutSemGive) +cos_asm_server_stub(OS_MutSemTake) + +// FS methods +// Relies on the assumption that dirp_t are never dereferenced outside the cFE +cos_asm_server_stub(OS_closedir) +cos_asm_server_stub(OS_lseek) +cos_asm_server_stub(OS_rewinddir) + // Emulated methods cos_asm_server_stub(emu_backend_request_memory) @@ -43,6 +53,9 @@ cos_asm_server_stub(emu_CFE_ES_RunLoop) cos_asm_server_stub(emu_CFE_EVS_Register) cos_asm_server_stub(emu_CFE_EVS_SendEvent) +cos_asm_server_stub(emu_CFE_FS_Decompress) +cos_asm_server_stub(emu_CFE_FS_WriteHeader) + cos_asm_server_stub(emu_CFE_SB_CreatePipe) cos_asm_server_stub(emu_CFE_SB_GetCmdCode) cos_asm_server_stub(emu_CFE_SB_GetMsgId) @@ -59,3 +72,25 @@ cos_asm_server_stub(emu_CFE_TIME_Add) cos_asm_server_stub(emu_CFE_TIME_Compare) cos_asm_server_stub(emu_CFE_TIME_GetTime) cos_asm_server_stub(emu_CFE_TIME_Print) + +cos_asm_server_stub(emu_OS_cp) +cos_asm_server_stub(emu_OS_creat) +cos_asm_server_stub(emu_OS_FDGetInfo) +cos_asm_server_stub(emu_OS_fsBytesFree) +cos_asm_server_stub(emu_OS_mkdir) +cos_asm_server_stub(emu_OS_opendir) +cos_asm_server_stub(emu_OS_mv) +cos_asm_server_stub(emu_OS_read) +cos_asm_server_stub(emu_OS_readdir) +cos_asm_server_stub(emu_OS_remove) +cos_asm_server_stub(emu_OS_rename) +cos_asm_server_stub(emu_OS_rmdir) +cos_asm_server_stub(emu_OS_stat) +cos_asm_server_stub(emu_OS_write) + +cos_asm_server_stub(emu_OS_BinSemCreate) +cos_asm_server_stub(emu_OS_CountSemCreate) +cos_asm_server_stub(emu_OS_MutSemCreate) +cos_asm_server_stub(emu_OS_TaskGetIdByName) + +cos_asm_server_stub(emu_OS_SymbolLookup) From 99dba05a82f1acea8130762fbc86fcceec9acbde Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Fri, 30 Mar 2018 15:12:41 -0400 Subject: [PATCH 106/122] Address PR comments on the first half of ostask.c --- .../no_interface/cFE_booter/cFE_util.h | 4 +- .../no_interface/cFE_booter/osapi.c | 41 +++++++++---------- .../no_interface/cFE_booter/ostask.c | 8 ++-- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.h b/src/components/implementation/no_interface/cFE_booter/cFE_util.h index 17589f5abb..886be7b1cc 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.h +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.h @@ -1,5 +1,5 @@ -#ifndef _cFE_util_ -#define _cFE_util_ +#ifndef _CFE_UTIL_ +#define _CFE_UTIL_ #include #include diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index bd4d379a23..cf2cfdd10d 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -19,18 +19,17 @@ int have_initialized = 0; int32 OS_API_Init(void) { - if (!have_initialized) { - cos_defcompinfo_init(); - struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); - struct cos_compinfo * ci = cos_compinfo_get(defci); - cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); + if (have_initialized) return OS_SUCCESS; - OS_FS_Init(); + cos_defcompinfo_init(); + struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); + struct cos_compinfo * ci = cos_compinfo_get(defci); + cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); - OS_ModuleTableInit(); + OS_FS_Init(); + OS_ModuleTableInit(); - have_initialized = 1; - } + have_initialized = 1; return OS_SUCCESS; } @@ -68,9 +67,10 @@ OS_DeleteAllObjects(void) */ int32 -OS_Milli2Ticks(uint32 milli_seconds) +OS_Milli2Ticks(uint32 milliseconds) { - return (int32)(CFE_PSP_GetTimerTicksPerSecond() * milli_seconds) / 1000; + uint32 ticks_per_millisecond = CFE_PSP_GetTimerTicksPerSecond() / 1000; + return (int32) (ticks_per_millisecond * milliseconds); } int32 @@ -116,7 +116,6 @@ OS_GetLocalTime(OS_time_t *time_struct) *time_struct = local_time; return OS_SUCCESS; - } /* end OS_GetLocalTime */ int32 @@ -412,16 +411,16 @@ int is_printf_enabled = TRUE; void OS_printf(const char *string, ...) { - if (is_printf_enabled) { - char s[OS_BUFFER_SIZE]; - va_list arg_ptr; - int ret, len = OS_BUFFER_SIZE; + if (!is_printf_enabled) return; - va_start(arg_ptr, string); - ret = vsnprintf(s, len, string, arg_ptr); - va_end(arg_ptr); - llprint(s, ret); - } + char s[OS_BUFFER_SIZE]; + va_list arg_ptr; + int ret, len = OS_BUFFER_SIZE; + + va_start(arg_ptr, string); + ret = vsnprintf(s, len, string, arg_ptr); + va_end(arg_ptr); + llprint(s, ret); } void diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 03a336c7ce..c242f90f3b 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -14,14 +14,14 @@ void timer_fn_1hz(void *d) { - cycles_t now, start; + cycles_t now, first_deadline; - rdtscll(start); - start += sl_usec2cyc(HZ_PAUSE); + rdtscll(now); + first_deadline = now + sl_usec2cyc(HZ_PAUSE); while (1) { rdtscll(now); - if (now > start) { + if (now > first_deadline) { CFE_TIME_Local1HzISR(); /* input param is signum. but CFE_PSP_TimerHandler doesn't seem to use it. */ } From edcdb78b8a68fba93e515a0690a94e7fc2c309b6 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Fri, 30 Mar 2018 15:54:03 -0400 Subject: [PATCH 107/122] Get rid of sl overrides in the cFE_booter --- .../no_interface/cFE_booter/Makefile | 2 +- .../no_interface/cFE_booter/ostask.c | 60 +++++++++++------ .../no_interface/cFE_booter/sl_mod_policy.h | 34 ---------- .../cFE_booter/sl_thd_static_backend.c | 66 ------------------- 4 files changed, 42 insertions(+), 120 deletions(-) delete mode 100644 src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h delete mode 100644 src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c diff --git a/src/components/implementation/no_interface/cFE_booter/Makefile b/src/components/implementation/no_interface/cFE_booter/Makefile index 98ed424117..8e7f5e8e2b 100644 --- a/src/components/implementation/no_interface/cFE_booter/Makefile +++ b/src/components/implementation/no_interface/cFE_booter/Makefile @@ -4,7 +4,7 @@ COMPONENT=cFE_booter.o INTERFACES=cFE DEPENDENCIES=capmgr IF_LIB:=./composite_cFE.o ./cFE_fs.o $(wildcard test/*.o) -ADDITIONAL_LIBS=-lcobj_format $(LIBSLCAPMGR) -lheap -lsl_lock +ADDITIONAL_LIBS=-lcobj_format $(LIBSLCAPMGR) -lheap -lsl_lock -lsl_thd_static_backend include ../../Makefile.subsubdir CFLAGS += -I./gen -I ./test/shared $(CPPFLAGS) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index c242f90f3b..131258255a 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -39,6 +39,13 @@ timer_fn_1hz(void *d) /* We need to keep track of this to check if register or delete handler calls are invalid */ thdid_t main_delegate_thread_id; +struct cfe_task_info { + osal_task_entry delete_handler; + OS_task_prop_t osal_task_prop; +}; + +struct cfe_task_info cfe_tasks[SL_MAX_NUM_THDS] = {{0}}; + void OS_SchedulerStart(cos_thd_fn_t main_delegate) { @@ -49,10 +56,10 @@ OS_SchedulerStart(cos_thd_fn_t main_delegate) sl_thd_param_set(main_delegate_thread, sp.v); main_delegate_thread_id = sl_thd_thdid(main_delegate_thread); - struct sl_thd_policy *policy = sl_mod_thd_policy_get(main_delegate_thread); - strcpy(policy->osal_task_prop.name, "MAIN_THREAD"); - policy->osal_task_prop.priority = MAIN_DELEGATE_THREAD_PRIORITY; - policy->osal_task_prop.OStask_id = (uint32)sl_thd_thdid(main_delegate_thread); + struct cfe_task_info *task_info = &cfe_tasks[main_delegate_thread_id]; + strcpy(task_info->osal_task_prop.name, "MAIN_THREAD"); + task_info->osal_task_prop.priority = MAIN_DELEGATE_THREAD_PRIORITY; + task_info->osal_task_prop.OStask_id = (uint32)sl_thd_thdid(main_delegate_thread); struct sl_thd * timer_thd = sl_thd_alloc(timer_fn_1hz, NULL); union sched_param_union spperiod = {.c = {.type = SCHEDP_WINDOW, .value = HZ_PAUSE}}; @@ -110,13 +117,13 @@ OS_TaskCreate(uint32 *task_id, const char *task_name, osal_task_entry function_p union sched_param_union sp = {.c = {.type = SCHEDP_PRIO, .value = priority}}; sl_thd_param_set(thd, sp.v); - struct sl_thd_policy *policy = sl_mod_thd_policy_get(thd); - strcpy(policy->osal_task_prop.name, task_name); - policy->osal_task_prop.creator = OS_TaskGetId(); - policy->osal_task_prop.stack_size = stack_size; - policy->osal_task_prop.priority = priority; - policy->osal_task_prop.OStask_id = (uint32)sl_thd_thdid(thd); - policy->delete_handler = NULL; + struct cfe_task_info *task_info = &cfe_tasks[sl_thd_thdid(thd)]; + strcpy(task_info->osal_task_prop.name, task_name); + task_info->osal_task_prop.creator = OS_TaskGetId(); + task_info->osal_task_prop.stack_size = stack_size; + task_info->osal_task_prop.priority = priority; + task_info->osal_task_prop.OStask_id = (uint32)sl_thd_thdid(thd); + task_info->delete_handler = NULL; *task_id = (uint32)sl_thd_thdid(thd); @@ -129,9 +136,9 @@ OS_TaskDelete(uint32 task_id) struct sl_thd *thd = sl_thd_lkup(task_id); if (!thd) { return OS_ERR_INVALID_ID; } - struct sl_thd_policy *thd_policy = sl_mod_thd_policy_get(thd); + struct cfe_task_info *task_info = &cfe_tasks[task_id]; - osal_task_entry delete_handler = thd_policy->delete_handler; + osal_task_entry delete_handler = task_info->delete_handler; if (delete_handler) { delete_handler(); } sl_thd_free(thd); @@ -159,7 +166,10 @@ int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer) { if (OS_TaskGetId() == main_delegate_thread_id) { return OS_ERR_INVALID_ID; } - sl_mod_thd_policy_get(sl_thd_curr())->delete_handler = function_pointer; + + struct cfe_task_info *task_info = &cfe_tasks[sl_thd_thdid(sl_thd_curr())]; + task_info->delete_handler = function_pointer; + return OS_SUCCESS; } @@ -197,8 +207,19 @@ OS_TaskRegister(void) int32 OS_TaskGetIdByName(uint32 *task_id, const char *task_name) { - // FIXME: Implement this - return OS_ERR_NOT_IMPLEMENTED; + if (!task_id || !task_name) return OS_INVALID_POINTER; + + thdid_t i; + for (i = 1; i < SL_MAX_NUM_THDS; i++) { + struct sl_thd *thd = sl_thd_lkup(i); + if (!thd || thd->state == SL_THD_FREE) continue; + if (strcmp(cfe_tasks[i].osal_task_prop.name, task_name) == 0) { + *task_id = i; + return OS_SUCCESS; + } + } + + return OS_ERR_NAME_NOT_FOUND; } int32 @@ -207,12 +228,13 @@ OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) if (!task_prop) { return OS_INVALID_POINTER; } struct sl_thd *thd = sl_thd_lkup(task_id); + // TODO: Fix this ugly workaround if (!thd || thd->state == SL_THD_FREE) { return OS_ERR_INVALID_ID; } - struct sl_thd_policy *thd_policy = sl_mod_thd_policy_get(thd); - assert(thd_policy); - *task_prop = thd_policy->osal_task_prop; + struct cfe_task_info *task_info = &cfe_tasks[task_id]; + *task_prop = task_info->osal_task_prop; + return OS_SUCCESS; } diff --git a/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h b/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h deleted file mode 100644 index c888b5e8f0..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/sl_mod_policy.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef SL_CUSTOM_MOD_POLICY_H -#define SL_CUSTOM_MOD_POLICY_H - -#include -#include - -#include "gen/osapi.h" -#include "gen/common_types.h" - -struct sl_thd_policy { - struct sl_thd thd; - tcap_prio_t priority; - microsec_t period_usec; - cycles_t period; - struct ps_list list; - - // cFE specific fields - osal_task_entry delete_handler; - OS_task_prop_t osal_task_prop; -}; - -static inline struct sl_thd * -sl_mod_thd_get(struct sl_thd_policy *tp) -{ - return &tp->thd; -} - -static inline struct sl_thd_policy * -sl_mod_thd_policy_get(struct sl_thd *t) -{ - return ps_container(t, struct sl_thd_policy, thd); -} - -#endif /* SL_CUSTOM_MOD_POLICY_H */ diff --git a/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c b/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c deleted file mode 100644 index e588780a46..0000000000 --- a/src/components/implementation/no_interface/cFE_booter/sl_thd_static_backend.c +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Redistribution of this file is permitted under the BSD two clause license. - * - * Copyright 2017, The George Washington University - * Author: Gabriel Parmer, gparmer@gwu.edu - */ -#include -#include -#include -#include -#include - - -static struct sl_thd_policy __sl_threads[SL_MAX_NUM_THDS]; - -static struct cos_aep_info __sl_aep_infos[SL_MAX_NUM_THDS]; -static u32_t __sl_aep_free_off; - -/* Default implementations of backend functions */ -struct sl_thd_policy * -sl_thd_alloc_backend(thdid_t tid) -{ - assert(tid < SL_MAX_NUM_THDS); - return &__sl_threads[tid]; -} - -struct cos_aep_info * -sl_thd_alloc_aep_backend(void) -{ - struct cos_aep_info *aep = NULL; - - assert(__sl_aep_free_off < SL_MAX_NUM_THDS); - aep = &__sl_aep_infos[__sl_aep_free_off]; - __sl_aep_free_off++; - - return aep; -} - -void -sl_thd_free_backend(struct sl_thd_policy *t) -{ } - -void -sl_thd_index_add_backend(struct sl_thd_policy *t) -{ } - -void -sl_thd_index_rem_backend(struct sl_thd_policy *t) -{ } - -struct sl_thd_policy * -sl_thd_lookup_backend(thdid_t tid) -{ - assert(tid < SL_MAX_NUM_THDS); - return &__sl_threads[tid]; -} - -void -sl_thd_init_backend(void) -{ - assert(SL_MAX_NUM_THDS <= MAX_NUM_THREADS); - - memset(__sl_threads, 0, sizeof(struct sl_thd_policy)*SL_MAX_NUM_THDS); - memset(__sl_aep_infos, 0, sizeof(struct cos_aep_info)*SL_MAX_NUM_THDS); - __sl_aep_free_off = 0; -} From bb134b1729fb4ba6f702805db8c7a26b123e378e Mon Sep 17 00:00:00 2001 From: base0x10 Date: Sat, 31 Mar 2018 14:03:13 -0400 Subject: [PATCH 108/122] WIP Made apps that kinda work --- .../no_interface/cfs_lib/Makefile | 10 +++ .../implementation/no_interface/ds/Makefile | 10 +++ .../implementation/no_interface/fm/Makefile | 10 +++ .../implementation/no_interface/hs/Makefile | 10 +++ .../implementation/no_interface/mm/Makefile | 10 +++ .../implementation/no_interface/sc/Makefile | 10 +++ src/components/interface/cFE/stubs/s_stub.S | 62 +++++++++++++++++++ 7 files changed, 122 insertions(+) create mode 100644 src/components/implementation/no_interface/cfs_lib/Makefile create mode 100644 src/components/implementation/no_interface/ds/Makefile create mode 100644 src/components/implementation/no_interface/fm/Makefile create mode 100644 src/components/implementation/no_interface/hs/Makefile create mode 100644 src/components/implementation/no_interface/mm/Makefile create mode 100644 src/components/implementation/no_interface/sc/Makefile diff --git a/src/components/implementation/no_interface/cfs_lib/Makefile b/src/components/implementation/no_interface/cfs_lib/Makefile new file mode 100644 index 0000000000..c96dd1478c --- /dev/null +++ b/src/components/implementation/no_interface/cfs_lib/Makefile @@ -0,0 +1,10 @@ +# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c +ASM_OBJS= +COMPONENT=cfs_util.o +INTERFACES= +DEPENDENCIES=cFE +IF_LIB:=./cFE_cfs_utils.o +ADDITIONAL_LIBS=-lcos_kernel_api + +include ../../Makefile.subsubdir +MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/ds/Makefile b/src/components/implementation/no_interface/ds/Makefile new file mode 100644 index 0000000000..1db070a233 --- /dev/null +++ b/src/components/implementation/no_interface/ds/Makefile @@ -0,0 +1,10 @@ +# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c +ASM_OBJS= +COMPONENT=ds_app.o +INTERFACES= +DEPENDENCIES=cFE +IF_LIB:=./cFE_ds_app.o ./cFE_ds_cmds.o ./cFE_ds_file.o ./cFE_ds_table.o +ADDITIONAL_LIBS=-lcos_kernel_api + +include ../../Makefile.subsubdir +MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/fm/Makefile b/src/components/implementation/no_interface/fm/Makefile new file mode 100644 index 0000000000..9a0dd0b059 --- /dev/null +++ b/src/components/implementation/no_interface/fm/Makefile @@ -0,0 +1,10 @@ +# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c +ASM_OBJS= +COMPONENT=fm_app.o +INTERFACES= +DEPENDENCIES=cFE +IF_LIB:=./cFE_fm_app.o ./cFE_fm_child.o ./cFE_fm_cmds.o ./cFE_fm_cmd_utils.o cFE_fm_tbl.o +ADDITIONAL_LIBS=-lcos_kernel_api + +include ../../Makefile.subsubdir +MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/hs/Makefile b/src/components/implementation/no_interface/hs/Makefile new file mode 100644 index 0000000000..3525a3e6b5 --- /dev/null +++ b/src/components/implementation/no_interface/hs/Makefile @@ -0,0 +1,10 @@ +# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c +ASM_OBJS= +COMPONENT=hs_app.o +INTERFACES= +DEPENDENCIES=cFE +IF_LIB:=./cFE_hs_app.o ./cFE_hs_cmds.o ./cFE_hs_custom.o ./cFE_hs_monitors.o +ADDITIONAL_LIBS=-lcos_kernel_api + +include ../../Makefile.subsubdir +MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/mm/Makefile b/src/components/implementation/no_interface/mm/Makefile new file mode 100644 index 0000000000..0eeef67b8b --- /dev/null +++ b/src/components/implementation/no_interface/mm/Makefile @@ -0,0 +1,10 @@ +# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c +ASM_OBJS= +COMPONENT=mm_app.o +INTERFACES= +DEPENDENCIES=cFE +IF_LIB:=./cFE_mm_app.o ./cFE_mm_dump.o ./cFE_mm_load.o cFE_mm_mem16.o ./cFE_mm_mem32 ./cFE_mm_mem8.o ./cFE_mm_utils.o +ADDITIONAL_LIBS=-lcos_kernel_api + +include ../../Makefile.subsubdir +MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/sc/Makefile b/src/components/implementation/no_interface/sc/Makefile new file mode 100644 index 0000000000..3b6f43f6b8 --- /dev/null +++ b/src/components/implementation/no_interface/sc/Makefile @@ -0,0 +1,10 @@ +# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c +ASM_OBJS= +COMPONENT=sc_app.o +INTERFACES= +DEPENDENCIES=cFE +IF_LIB:=./cFE_sc_app.o ./cFE_sc_atsrq.o ./cFE_sc_cmds.o ./cFE_sc_loads.o ./cFE_sc_rtsrq.o ./cFE_sc_state.o ./cFE_sc_utils.o +ADDITIONAL_LIBS=-lcos_kernel_api + +include ../../Makefile.subsubdir +MANDITORY_LIB=simple_stklib.o diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index a4899501bc..a1cce42602 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -75,3 +75,65 @@ cos_asm_server_stub(CFE_TBL_DumpToBuffer) cos_asm_server_stub(CFE_TBL_GetStatus) cos_asm_server_stub(CFE_TBL_Update) cos_asm_server_stub(CFE_TBL_Validate) + +// needed for cFE ds app +cos_asm_server_stub(CFE_FS_WriteHeader) +//cos_asm_server_stub(CFE_SB_Default_Qos) +cos_asm_server_stub(CFE_TIME_GetTime) +cos_asm_server_stub(CFE_TIME_Print) +//cos_asm_server_stub(PacketFiltered) +//cos_asm_server_stub(CFS_VerifyString) +cos_asm_server_stub(OS_creat) +cos_asm_server_stub(OS_lseek) +cos_asm_server_stub(OS_write) + +// needed for fm app +cos_asm_server_stub(CFE_ES_GetTaskInfo) +cos_asm_server_stub(CFE_FS_Decompress) +cos_asm_server_stub(CFE_TIME_FS2CFESeconds) +cos_asm_server_stub(CFS_IsValidFilename) +cos_asm_server_stub(OS_closedir) +cos_asm_server_stub(OS_CountSemCreate) +cos_asm_server_stub(OS_CountSemGive) +cos_asm_server_stub(OS_CountSemTake) +cos_asm_server_stub(OS_cp) +cos_asm_server_stub(OS_FDGetInfo) +cos_asm_server_stub(OS_fsBytesFree) +cos_asm_server_stub(OS_mkdir) +cos_asm_server_stub(OS_MutSemCreate) +cos_asm_server_stub(OS_MutSemGive) +cos_asm_server_stub(OS_MutSemTake) +cos_asm_server_stub(OS_mv) +cos_asm_server_stub(OS_opendir) +cos_asm_server_stub(OS_read) +cos_asm_server_stub(OS_readdir) +cos_asm_server_stub(OS_remove) +cos_asm_server_stub(OS_rename) +cos_asm_server_stub(OS_rewinddir) +cos_asm_server_stub(OS_rmdir) +cos_asm_server_stub(OS_stat) + +// needed for cfs_util +cos_asm_server_stub(CFE_SB_GetMsgTime) +cos_asm_server_stub(OS_SymbolLookup) + +// needed for sc app +cos_asm_server_stub(CFE_ES_GetResetType) +cos_asm_server_stub(CFE_SB_SetCmdCode) +cos_asm_server_stub(CFE_SB_ValidateChecksum) +cos_asm_server_stub(CFE_TBL_NotifyByMessage) +cos_asm_server_stub(CFE_TIME_Add) +cos_asm_server_stub(CFE_TIME_Compare) + +// needed for hs app +cos_asm_server_stub(CFE_ES_DeleteApp) +cos_asm_server_stub(CFE_ES_GetGenCount) +cos_asm_server_stub(CFE_ES_GetGenCounterIDByName) +cos_asm_server_stub(CFE_ES_ResetCFE) +cos_asm_server_stub(CFE_ES_RestartApp) +cos_asm_server_stub(CFE_PSP_WatchdogEnable) +cos_asm_server_stub(CFE_PSP_WatchdogService) +cos_asm_server_stub(CFE_PSP_WatchdogSet) +cos_asm_server_stub(CFE_TIME_RegisterSynchCallback) +cos_asm_server_stub(CFE_TIME_UnregisterSynchCallback) +cos_asm_server_stub(OS_TaskGetIdByName) From 1fecd4a403aa959334516024182dc9d2fe0d1d85 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sat, 31 Mar 2018 17:03:29 -0400 Subject: [PATCH 109/122] Address more PR comments in ostask.c --- .../implementation/no_interface/cFE_booter/osloader.c | 7 ++++++- .../implementation/no_interface/cFE_booter/ostask.c | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index 89812d8511..3f5b2cf7bc 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -39,11 +39,16 @@ launch_other_component(int child_id, int is_library) cos_defcompinfo_childid_init(&child_dci, child_id); struct sl_thd *t = sl_thd_initaep_alloc(&child_dci, NULL, 0, 0, 0); + + /* We need to override the delegate thread id, so the cFE think it's this thread + * Otherwise cFE application id detection is broken + */ + id_overrides[sl_thd_thdid(t)] = sl_thdid(); + if (is_library) { sl_thd_param_set(t, sched_param_pack(SCHEDP_PRIO, 1)); sl_thd_yield(sl_thd_thdid(t)); } else { - id_overrides[sl_thd_thdid(t)] = sl_thdid(); while (1) sl_thd_yield(sl_thd_thdid(t)); } } diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 131258255a..58098370b7 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -34,6 +34,9 @@ timer_fn_1hz(void *d) ** Internal Task helper functions */ +/* We delegate the main thread of execution to a different thread + * (the main thread needs to run the scheduling loop) + */ #define MAIN_DELEGATE_THREAD_PRIORITY 2 /* We need to keep track of this to check if register or delete handler calls are invalid */ @@ -150,6 +153,7 @@ uint32 OS_TaskGetId(void) { thdid_t real_id = sl_thdid(); + /* Sometimes we need to disguise a thread as another thread... */ thdid_t possible_override = id_overrides[real_id]; if (possible_override) return possible_override; return real_id; From 1067a292442b34962988f4d071b8d4cefdadebeb Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sat, 31 Mar 2018 19:57:45 -0400 Subject: [PATCH 110/122] Fix scheduling oddeties within the cFE --- .../no_interface/cFE_booter/osapi.c | 17 ++-- .../no_interface/cFE_booter/osloader.c | 12 ++- .../no_interface/cFE_booter/ostask.c | 89 +++++++++---------- src/extern/cFE | 2 +- 4 files changed, 59 insertions(+), 61 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index cf2cfdd10d..1ca7757437 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -195,8 +195,9 @@ OS_FPUExcGetMask(uint32 *mask) } /* -** Interrupt API -*/ + * Interrupt API + * The disabling APIs always work, since interrupts are always disabled + */ int32 OS_IntAttachHandler(uint32 InterruptNumber, osal_task_entry InterruptHandler, int32 parameter) { @@ -207,29 +208,25 @@ OS_IntAttachHandler(uint32 InterruptNumber, osal_task_entry InterruptHandler, in int32 OS_IntUnlock(int32 IntLevel) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SUCCESS; } int32 OS_IntLock(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SUCCESS; } int32 OS_IntEnable(int32 Level) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SUCCESS; } int32 OS_IntDisable(int32 Level) { - PANIC("Unimplemented method!"); // TODO: Implement me! - return 0; + return OS_SUCCESS; } int32 diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index 3f5b2cf7bc..ced5013e5e 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -32,6 +32,15 @@ OS_ModuleUnload(uint32 module_id) return OS_SUCCESS; } +int32 +get_this_threads_priority() +{ + OS_task_prop_t prop; + int32 result = OS_TaskGetInfo(sl_thdid(), &prop); + assert(result == OS_SUCCESS); + return prop.priority; +} + void launch_other_component(int child_id, int is_library) { @@ -49,7 +58,8 @@ launch_other_component(int child_id, int is_library) sl_thd_param_set(t, sched_param_pack(SCHEDP_PRIO, 1)); sl_thd_yield(sl_thd_thdid(t)); } else { - while (1) sl_thd_yield(sl_thd_thdid(t)); + sl_thd_param_set(t, sched_param_pack(SCHEDP_PRIO, get_this_threads_priority())); + OS_TaskExit(); } } diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index 58098370b7..f79e62046e 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -283,7 +283,6 @@ struct mutex { struct sl_lock mutex_data_lock = SL_LOCK_STATIC_INIT(); struct mutex mutexes[OS_MAX_MUTEXES]; - int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) { @@ -332,41 +331,32 @@ OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) int32 OS_MutSemGive(uint32 sem_id) { - int32 result = OS_SUCCESS; - sl_lock_take(&mutex_data_lock); - if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { - result = OS_ERR_INVALID_ID; - goto exit; + sl_lock_release(&mutex_data_lock); + return OS_ERR_INVALID_ID; } + sl_lock_release(&mutex_data_lock); sl_lock_release(&mutexes[sem_id].lock); -exit: - sl_lock_release(&mutex_data_lock); - - return result; + return OS_SUCCESS; } int32 OS_MutSemTake(uint32 sem_id) { - int32 result = OS_SUCCESS; sl_lock_take(&mutex_data_lock); - if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { - result = OS_ERR_INVALID_ID; - goto exit; + sl_lock_release(&mutex_data_lock); + return OS_ERR_INVALID_ID; } + sl_lock_release(&mutex_data_lock); sl_lock_take(&mutexes[sem_id].lock); -exit: - sl_lock_release(&mutex_data_lock); - - return result; + return OS_SUCCESS; } int32 @@ -456,14 +446,15 @@ struct semaphore { int used; uint32 count; - int epoch; + thdid_t holder; + uint32 creator; char name[OS_MAX_API_NAME]; }; struct sl_lock semaphore_data_lock = SL_LOCK_STATIC_INIT(); -struct semaphore binary_semaphores[OS_MAX_BIN_SEMAPHORES]; +struct semaphore binary_semaphores[OS_MAX_BIN_SEMAPHORES]; struct semaphore counting_semaphores[OS_MAX_COUNT_SEMAPHORES]; // Generic semaphore methods @@ -506,6 +497,7 @@ OS_SemaphoreCreate(struct semaphore *semaphores, uint32 max_semaphores, uint32 * semaphores[id].used = TRUE; semaphores[id].creator = sl_thdid(); semaphores[id].count = sem_initial_value; + semaphores[id].holder = 0; strcpy(semaphores[id].name, sem_name); exit: @@ -516,20 +508,8 @@ OS_SemaphoreCreate(struct semaphore *semaphores, uint32 max_semaphores, uint32 * int32 OS_SemaphoreFlush(struct semaphore *semaphores, uint32 max_semaphores, uint32 sem_id) { - int32 result = OS_SUCCESS; - - sl_lock_take(&semaphore_data_lock); - - if (sem_id >= max_semaphores || !semaphores[sem_id].used) { - result = OS_ERR_INVALID_ID; - goto exit; - } - - semaphores[sem_id].epoch += 1; - -exit: - sl_lock_release(&semaphore_data_lock); - return result; + PANIC("Unimplemented method!"); + return 0; } @@ -545,8 +525,10 @@ OS_SemaphoreGive(struct semaphore *semaphores, uint32 max_semaphores, uint32 sem goto exit; } - // FIXME: Add some checks that the semaphore was actually taken by this thread semaphores[sem_id].count += 1; + if (semaphores[sem_id].holder == sl_thdid()) { + semaphores[sem_id].holder = 0; + } exit: sl_lock_release(&semaphore_data_lock); @@ -565,16 +547,18 @@ OS_SemaphoreTake(struct semaphore *semaphores, uint32 max_semaphores, uint32 sem goto exit; } - int starting_epoch = semaphores[sem_id].epoch; - - while (semaphores[sem_id].used && semaphores[sem_id].count == 0) { - if (semaphores[sem_id].epoch != starting_epoch) { goto exit; } + while (semaphores[sem_id].used && semaphores[sem_id].count < 1) { + thdid_t holder = semaphores[sem_id].holder; sl_lock_release(&semaphore_data_lock); - - // TODO: Do something smarter than blocking for 3 millisecond - cycles_t timeout = sl_now() + sl_usec2cyc(3 * 1000); - sl_thd_block_timeout(0, timeout); - + /* We want to run someone else here, preferably one of the semaphore holders */ + sl_thd_yield(holder); + /* If the semaphore holder is blocked, we might just get scheduled again + * Optimally we would switch to an unblocked holder, but we aren't storing them all + * And even if we did, what if all of them were blocked? + * Under fprr, in that situation, we'd just spin in this loop forever + * Thus, we use this OS_TaskDelay hack, to get us removed from the runqueue temporarily + */ + OS_TaskDelay(1); sl_lock_take(&semaphore_data_lock); } @@ -583,6 +567,10 @@ OS_SemaphoreTake(struct semaphore *semaphores, uint32 max_semaphores, uint32 sem goto exit; } + if (semaphores[sem_id].holder == 0) { + semaphores[sem_id].holder = sl_thdid(); + } + semaphores[sem_id].count -= 1; exit: @@ -604,11 +592,10 @@ OS_SemaphoreTimedWait(struct semaphore *semaphores, uint32 max_semaphores, uint3 goto exit; } - while (semaphores[sem_id].used && semaphores[sem_id].count == 0 && (sl_now_usec() - start_time) < max_wait) { + while (semaphores[sem_id].used && semaphores[sem_id].count < 1 && (sl_now_usec() - start_time) < max_wait) { + thdid_t holder = semaphores[sem_id].holder; sl_lock_release(&semaphore_data_lock); - // TODO: Do something smarter than blocking for 3 milliseconds - cycles_t timeout = sl_now() + sl_usec2cyc(3 * 1000); - sl_thd_block_timeout(0, timeout); + sl_thd_yield(holder); sl_lock_take(&semaphore_data_lock); } @@ -617,11 +604,15 @@ OS_SemaphoreTimedWait(struct semaphore *semaphores, uint32 max_semaphores, uint3 goto exit; } - if (semaphores[sem_id].count == 0) { + if (semaphores[sem_id].count < 1) { result = OS_SEM_TIMEOUT; goto exit; } + if (semaphores[sem_id].holder == 0) { + semaphores[sem_id].holder = sl_thdid(); + } + semaphores[sem_id].count -= 1; exit: diff --git a/src/extern/cFE b/src/extern/cFE index bc46e1eb10..35d2ed699c 160000 --- a/src/extern/cFE +++ b/src/extern/cFE @@ -1 +1 @@ -Subproject commit bc46e1eb10577f82dd4bf3299e19b5adf7cda353 +Subproject commit 35d2ed699ca975fc804d69feca2042367d11f1e0 From 67fb31ebfaf68a4077986460fa8d002ad10e62e7 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Thu, 12 Apr 2018 14:21:09 -0400 Subject: [PATCH 111/122] Implement more missing stubs, bump INTERFACE_UNDEF_SYMBS --- .../no_interface/cFE_booter/cFE_emu_support.c | 44 ++++++++++ src/components/interface/cFE/cFE_emu.h | 34 ++++++++ src/components/interface/cFE/stubs/c_stub.c | 83 ++++++++++++++++++- src/components/interface/cFE/stubs/s_stub.S | 11 +++ src/kernel/include/shared/cos_types.h | 2 +- 5 files changed, 171 insertions(+), 3 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c index 2e02e62a37..9c30d3ac18 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -24,6 +24,28 @@ emu_backend_request_memory(spdid_t client) return id; } +int32 +emu_CFE_ES_CalculateCRC(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_ES_CalculateCRC(s->cfe_es_calculateCRC.Data, s->cfe_es_calculateCRC.DataLength, + s->cfe_es_calculateCRC.InputCRC, s->cfe_es_calculateCRC.TypeCRC); +} + +int32 +emu_CFE_ES_GetAppIDByName(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_ES_GetAppIDByName(&s->cfe_es_getAppIDByName.AppId, s->cfe_es_getAppIDByName.AppName); +} + +int32 +emu_CFE_ES_GetAppInfo(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_ES_GetAppInfo(&s->cfe_es_getAppInfo.AppInfo, s->cfe_es_getAppInfo.AppId); +} + int32 emu_CFE_ES_GetGenCount(spdid_t client) { @@ -59,6 +81,13 @@ emu_CFE_ES_RunLoop(spdid_t client) return CFE_ES_RunLoop(&s->cfe_es_runLoop.RunStatus); } +int32 +emu_CFE_ES_WriteToSysLog(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_ES_WriteToSysLog("%s", s->cfe_es_writeToSysLog.String); +} + int32 emu_CFE_EVS_Register(spdid_t client) { @@ -169,6 +198,14 @@ emu_CFE_SB_SendMsg(spdid_t client) return CFE_SB_SendMsg((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); } +int32 +emu_CFE_SB_SubscribeEx(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_SB_SubscribeEx(s->cfe_sb_subscribeEx.MsgId, s->cfe_sb_subscribeEx.PipeId, + s->cfe_sb_subscribeEx.Quality, s->cfe_sb_subscribeEx.MsgLim); +} + void emu_CFE_SB_TimeStampMsg(spdid_t client) { @@ -245,6 +282,13 @@ emu_OS_mkdir(spdid_t client) return OS_mkdir(s->os_mkdir.path, s->os_mkdir.access); } +int32 +emu_OS_open(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return OS_open(s->os_open.path, s->os_open.access, s->os_open.mode); +} + os_dirp_t emu_OS_opendir(spdid_t client) { diff --git a/src/components/interface/cFE/cFE_emu.h b/src/components/interface/cFE/cFE_emu.h index b6ea089d7c..743f4272ff 100644 --- a/src/components/interface/cFE/cFE_emu.h +++ b/src/components/interface/cFE/cFE_emu.h @@ -158,15 +158,47 @@ union shared_region { uint32 task_id; char task_name[EMU_BUF_SIZE]; } os_taskGetIdByName; + struct { + char String[EMU_BUF_SIZE]; + } cfe_es_writeToSysLog; + struct { + char path[EMU_BUF_SIZE]; + int32 access; + uint32 mode; + } os_open; + struct { + char Data[EMU_BUF_SIZE]; + uint32 DataLength; + uint32 InputCRC; + uint32 TypeCRC; + } cfe_es_calculateCRC; + struct { + uint32 AppId; + char AppName[EMU_BUF_SIZE]; + } cfe_es_getAppIDByName; + struct { + CFE_ES_AppInfo_t AppInfo; + uint32 AppId; + } cfe_es_getAppInfo; + struct { + CFE_SB_MsgId_t MsgId; + CFE_SB_PipeId_t PipeId; + CFE_SB_Qos_t Quality; + uint16 MsgLim; + } cfe_sb_subscribeEx; }; int emu_backend_request_memory(spdid_t client); +int32 emu_CFE_ES_CalculateCRC(spdid_t client); +int32 emu_CFE_ES_GetAppIDByName(spdid_t client); +int32 emu_CFE_ES_GetAppInfo(spdid_t client); int32 emu_CFE_ES_GetGenCount(spdid_t client); int32 emu_CFE_ES_GetGenCounterIDByName(spdid_t client); int32 emu_CFE_ES_GetResetType(spdid_t client); int32 emu_CFE_ES_GetTaskInfo(spdid_t client); int32 emu_CFE_ES_RunLoop(spdid_t client); +int32 emu_CFE_ES_WriteToSysLog(spdid_t client); int32 emu_CFE_EVS_Register(spdid_t sp); int32 emu_CFE_EVS_SendEvent(spdid_t client); @@ -183,6 +215,7 @@ void emu_CFE_SB_InitMsg(spdid_t client); int32 emu_CFE_SB_RcvMsg(spdid_t client); int32 emu_CFE_SB_SetCmdCode(spdid_t client); int32 emu_CFE_SB_SendMsg(spdid_t client); +int32 emu_CFE_SB_SubscribeEx(spdid_t client); void emu_CFE_SB_TimeStampMsg(spdid_t client); boolean emu_CFE_SB_ValidateChecksum(spdid_t client); @@ -197,6 +230,7 @@ int32 emu_OS_FDGetInfo(spdid_t client); int32 emu_OS_fsBytesFree(spdid_t client); int32 emu_OS_mkdir(spdid_t client); int32 emu_OS_mv(spdid_t client); +int32 emu_OS_open(spdid_t client); os_dirp_t emu_OS_opendir(spdid_t client); int32 emu_OS_read(spdid_t client); void emu_OS_readdir(spdid_t client); diff --git a/src/components/interface/cFE/stubs/c_stub.c b/src/components/interface/cFE/stubs/c_stub.c index 1d85a9ccc2..30299a6b5f 100644 --- a/src/components/interface/cFE/stubs/c_stub.c +++ b/src/components/interface/cFE/stubs/c_stub.c @@ -14,6 +14,8 @@ union shared_region *shared_region; spdid_t spdid; +// NOTE: This is tagged as currently unused in the docs +CFE_SB_Qos_t CFE_SB_Default_Qos = { 0 }; void do_emulation_setup(spdid_t id) @@ -26,10 +28,42 @@ do_emulation_setup(spdid_t id) memmgr_shared_page_map(region_id, &client_addr); assert(client_addr); shared_region = (void *)client_addr; -} +} + // FIXME: Be more careful about user supplied pointers +// FIXME: Take a lock in each function, so shared memory can't be corrupted +uint32 +CFE_ES_CalculateCRC(const void *DataPtr, uint32 DataLength, uint32 InputCRC, uint32 TypeCRC) +{ + assert(DataLength < EMU_BUF_SIZE); + memcpy(shared_region->cfe_es_calculateCRC.Data, DataPtr, DataLength); + shared_region->cfe_es_calculateCRC.InputCRC = InputCRC; + shared_region->cfe_es_calculateCRC.TypeCRC = TypeCRC; + return emu_CFE_ES_CalculateCRC(spdid); +} + +int32 +CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName) +{ + assert(strlen(AppName) < EMU_BUF_SIZE); + + strcpy(shared_region->cfe_es_getAppIDByName.AppName, AppName); + int32 result = emu_CFE_ES_GetAppIDByName(spdid); + *AppIdPtr = shared_region->cfe_es_getAppIDByName.AppId; + return result; +} + +int32 +CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, uint32 AppId) +{ + shared_region->cfe_es_getAppInfo.AppId = AppId; + int32 result = emu_CFE_ES_GetAppInfo(spdid); + *AppInfo = shared_region->cfe_es_getAppInfo.AppInfo; + return result; +} + int32 CFE_ES_GetGenCount(uint32 CounterId, uint32 *Count) { @@ -74,6 +108,18 @@ CFE_ES_RunLoop(uint32 *RunStatus) return result; } +int32 +CFE_ES_WriteToSysLog(const char *SpecStringPtr, ...) +{ + va_list arg_ptr; + int ret, len = OS_BUFFER_SIZE; + + va_start(arg_ptr, SpecStringPtr); + vsnprintf(shared_region->cfe_es_writeToSysLog.String, len, SpecStringPtr, arg_ptr); + va_end(arg_ptr); + return emu_CFE_ES_WriteToSysLog(spdid); +} + int32 CFE_EVS_Register(void * Filters, /* Pointer to an array of filters */ uint16 NumFilteredEvents, /* How many elements in the array? */ uint16 FilterScheme) /* Filtering Algorithm to be implemented */ @@ -122,6 +168,19 @@ CFE_FS_WriteHeader(int32 FileDes, CFE_FS_Header_t *Hdr) return result; } +int32 +CFE_PSP_MemCpy(void *dest, void *src, uint32 n) +{ + memcpy(dest, src, n); + return CFE_PSP_SUCCESS; +} + +int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n) +{ + memset(dest, value, n); + return CFE_PSP_SUCCESS; +} + int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *PipeName) { @@ -233,6 +292,15 @@ CFE_SB_SendMsg(CFE_SB_Msg_t *MsgPtr) return emu_CFE_SB_SendMsg(spdid); } +int32 +CFE_SB_SubscribeEx(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, CFE_SB_Qos_t Quality, uint16 MsgLim) +{ + shared_region->cfe_sb_subscribeEx.MsgId = MsgId; + shared_region->cfe_sb_subscribeEx.PipeId = PipeId; + shared_region->cfe_sb_subscribeEx.Quality = Quality; + shared_region->cfe_sb_subscribeEx.MsgLim = MsgLim; + return emu_CFE_SB_SubscribeEx(spdid); +} void CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr) @@ -350,6 +418,18 @@ OS_mv(const char *src, const char *dest) return emu_OS_mv(spdid); } +int32 +OS_open(const char *path, int32 access, uint32 mode) +{ + assert(strlen(path) < EMU_BUF_SIZE); + + strcpy(shared_region->os_open.path, path); + shared_region->os_open.access = access; + shared_region->os_open.mode = mode; + + return emu_OS_open(spdid); +} + os_dirp_t OS_opendir(const char *path) { @@ -433,7 +513,6 @@ OS_write(int32 filedes, void *buffer, uint32 nbytes) return emu_OS_write(spdid); } - int32 OS_BinSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index 5f6d9787e9..c5a778c78b 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -15,8 +15,10 @@ cos_asm_server_stub(CFE_ES_DeleteApp) cos_asm_server_stub(CFE_ES_ExitApp) cos_asm_server_stub(CFE_ES_PerfLogAdd) cos_asm_server_stub(CFE_ES_RegisterApp) +cos_asm_server_stub(CFE_ES_RegisterChildTask) cos_asm_server_stub(CFE_ES_ResetCFE) cos_asm_server_stub(CFE_ES_RestartApp) +cos_asm_server_stub(CFE_ES_WaitForStartupSync) cos_asm_server_stub(CFE_PSP_WatchdogDisable) cos_asm_server_stub(CFE_PSP_WatchdogEnable) @@ -24,6 +26,8 @@ cos_asm_server_stub(CFE_PSP_WatchdogSet) cos_asm_server_stub(CFE_PSP_WatchdogService) cos_asm_server_stub(CFE_SB_Subscribe) +cos_asm_server_stub(CFE_SB_Unsubscribe) +cos_asm_server_stub(CFE_SB_UnsubscribeLocal) cos_asm_server_stub(CFE_TBL_NotifyByMessage) @@ -34,6 +38,7 @@ cos_asm_server_stub(OS_CountSemTake) cos_asm_server_stub(OS_IdleLoop) cos_asm_server_stub(OS_MutSemGive) cos_asm_server_stub(OS_MutSemTake) +cos_asm_server_stub(OS_TaskDelay) // FS methods // Relies on the assumption that dirp_t are never dereferenced outside the cFE @@ -44,11 +49,15 @@ cos_asm_server_stub(OS_rewinddir) // Emulated methods cos_asm_server_stub(emu_backend_request_memory) +cos_asm_server_stub(emu_CFE_ES_CalculateCRC) +cos_asm_server_stub(emu_CFE_ES_GetAppIDByName) +cos_asm_server_stub(emu_CFE_ES_GetAppInfo) cos_asm_server_stub(emu_CFE_ES_GetGenCount) cos_asm_server_stub(emu_CFE_ES_GetGenCounterIDByName) cos_asm_server_stub(emu_CFE_ES_GetResetType) cos_asm_server_stub(emu_CFE_ES_GetTaskInfo) cos_asm_server_stub(emu_CFE_ES_RunLoop) +cos_asm_server_stub(emu_CFE_ES_WriteToSysLog) cos_asm_server_stub(emu_CFE_EVS_Register) cos_asm_server_stub(emu_CFE_EVS_SendEvent) @@ -65,6 +74,7 @@ cos_asm_server_stub(emu_CFE_SB_InitMsg) cos_asm_server_stub(emu_CFE_SB_RcvMsg) cos_asm_server_stub(emu_CFE_SB_SetCmdCode) cos_asm_server_stub(emu_CFE_SB_SendMsg) +cos_asm_server_stub(emu_CFE_SB_SubscribeEx) cos_asm_server_stub(emu_CFE_SB_TimeStampMsg) cos_asm_server_stub(emu_CFE_SB_ValidateChecksum) @@ -78,6 +88,7 @@ cos_asm_server_stub(emu_OS_creat) cos_asm_server_stub(emu_OS_FDGetInfo) cos_asm_server_stub(emu_OS_fsBytesFree) cos_asm_server_stub(emu_OS_mkdir) +cos_asm_server_stub(emu_OS_open) cos_asm_server_stub(emu_OS_opendir) cos_asm_server_stub(emu_OS_mv) cos_asm_server_stub(emu_OS_read) diff --git a/src/kernel/include/shared/cos_types.h b/src/kernel/include/shared/cos_types.h index f8a5313d53..3bfe342cb3 100644 --- a/src/kernel/include/shared/cos_types.h +++ b/src/kernel/include/shared/cos_types.h @@ -446,7 +446,7 @@ typedef enum { #define IL_INV (~0) typedef unsigned int isolation_level_t; -#define INTERFACE_UNDEF_SYMBS 64 /* maxiumum undefined symbols in a cobj */ +#define INTERFACE_UNDEF_SYMBS 128 /* maxiumum undefined symbols in a cobj */ #define LLBOOT_ROOTSCHED_PRIO 1 /* root scheduler priority for llbooter dispatch */ #define LLBOOT_NEWCOMP_UNTYPED_SZ (1<<24) /* 16 MB = untyped size per component if there is no capability manager */ #define LLBOOT_RESERVED_UNTYPED_SZ (1<<24) /* 16 MB = reserved untyped size with booter if there is a capability manager */ From fc1095b226e9dfc7b39ca577f395d63a55f94e27 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sat, 14 Apr 2018 17:43:49 -0400 Subject: [PATCH 112/122] Implement CDS stubs for the cFE interface --- .../no_interface/cFE_booter/cFE_emu_support.c | 23 ++++++++ src/components/interface/cFE/cFE_emu.h | 16 ++++++ src/components/interface/cFE/stubs/c_stub.c | 55 ++++++++++++++++++- src/components/interface/cFE/stubs/s_stub.S | 3 + 4 files changed, 95 insertions(+), 2 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c index 9c30d3ac18..ca3008b9fa 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -32,6 +32,14 @@ emu_CFE_ES_CalculateCRC(spdid_t client) s->cfe_es_calculateCRC.InputCRC, s->cfe_es_calculateCRC.TypeCRC); } +int32 +emu_CFE_ES_CopyToCDS(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_ES_CopyToCDS(s->cfe_es_copyToCDS.CDSHandle, s->cfe_es_copyToCDS.DataToCopy); +} + + int32 emu_CFE_ES_GetAppIDByName(spdid_t client) { @@ -74,6 +82,21 @@ emu_CFE_ES_GetTaskInfo(spdid_t client) return CFE_ES_GetTaskInfo(&s->cfe_es_getTaskInfo.TaskInfo, s->cfe_es_getTaskInfo.TaskId); } +int32 +emu_CFE_ES_RegisterCDS(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_ES_RegisterCDS(&s->cfe_es_registerCDS.CDS_Handle, s->cfe_es_registerCDS.BlockSize, s->cfe_es_registerCDS.Name); +} + +int32 +emu_CFE_ES_RestoreFromCDS(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_ES_RestoreFromCDS(s->cfe_es_restoreFromCDS.RestoreToMemory, s->cfe_es_restoreFromCDS.CDSHandle); +} + + int32 emu_CFE_ES_RunLoop(spdid_t client) { diff --git a/src/components/interface/cFE/cFE_emu.h b/src/components/interface/cFE/cFE_emu.h index 743f4272ff..0ac547f583 100644 --- a/src/components/interface/cFE/cFE_emu.h +++ b/src/components/interface/cFE/cFE_emu.h @@ -186,17 +186,33 @@ union shared_region { CFE_SB_Qos_t Quality; uint16 MsgLim; } cfe_sb_subscribeEx; + struct { + CFE_ES_CDSHandle_t CDS_Handle; + int32 BlockSize; + char Name[EMU_BUF_SIZE]; + } cfe_es_registerCDS; + struct { + CFE_ES_CDSHandle_t CDSHandle; + char DataToCopy[EMU_BUF_SIZE]; + } cfe_es_copyToCDS; + struct { + CFE_ES_CDSHandle_t CDSHandle; + char RestoreToMemory[EMU_BUF_SIZE]; + } cfe_es_restoreFromCDS; }; int emu_backend_request_memory(spdid_t client); int32 emu_CFE_ES_CalculateCRC(spdid_t client); +int32 emu_CFE_ES_CopyToCDS(spdid_t client); int32 emu_CFE_ES_GetAppIDByName(spdid_t client); int32 emu_CFE_ES_GetAppInfo(spdid_t client); int32 emu_CFE_ES_GetGenCount(spdid_t client); int32 emu_CFE_ES_GetGenCounterIDByName(spdid_t client); int32 emu_CFE_ES_GetResetType(spdid_t client); int32 emu_CFE_ES_GetTaskInfo(spdid_t client); +int32 emu_CFE_ES_RegisterCDS(spdid_t client); +int32 emu_CFE_ES_RestoreFromCDS(spdid_t client); int32 emu_CFE_ES_RunLoop(spdid_t client); int32 emu_CFE_ES_WriteToSysLog(spdid_t client); diff --git a/src/components/interface/cFE/stubs/c_stub.c b/src/components/interface/cFE/stubs/c_stub.c index 30299a6b5f..9e9ad94428 100644 --- a/src/components/interface/cFE/stubs/c_stub.c +++ b/src/components/interface/cFE/stubs/c_stub.c @@ -14,8 +14,10 @@ union shared_region *shared_region; spdid_t spdid; + // NOTE: This is tagged as currently unused in the docs CFE_SB_Qos_t CFE_SB_Default_Qos = { 0 }; +size_t CDS_sizes[CFE_ES_CDS_MAX_NUM_ENTRIES] = { 0 }; void do_emulation_setup(spdid_t id) @@ -28,8 +30,6 @@ do_emulation_setup(spdid_t id) memmgr_shared_page_map(region_id, &client_addr); assert(client_addr); shared_region = (void *)client_addr; - - } // FIXME: Be more careful about user supplied pointers @@ -44,6 +44,21 @@ CFE_ES_CalculateCRC(const void *DataPtr, uint32 DataLength, uint32 InputCRC, uin return emu_CFE_ES_CalculateCRC(spdid); } +int32 +CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t CDSHandle, void * DataToCopy) +{ + /* CDSHandle is unsigned, so it can't be invalid by being negative */ + assert(CDSHandle < CFE_ES_CDS_MAX_NUM_ENTRIES); + + shared_region->cfe_es_copyToCDS.CDSHandle = CDSHandle; + + size_t data_size = CDS_sizes[CDSHandle]; + assert(data_size <= EMU_BUF_SIZE); + memcpy(shared_region->cfe_es_copyToCDS.DataToCopy, DataToCopy, data_size); + + return emu_CFE_ES_CopyToCDS(spdid); +} + int32 CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName) { @@ -99,6 +114,42 @@ CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, uint32 TaskId) return result; } +int32 +CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, int32 BlockSize, const char *Name) +{ + assert(strlen(Name) < EMU_BUF_SIZE); + + shared_region->cfe_es_registerCDS.BlockSize = BlockSize; + strcpy(shared_region->cfe_es_registerCDS.Name, Name); + + int32 result = emu_CFE_ES_RegisterCDS(spdid); + if (result == CFE_SUCCESS) { + CFE_ES_CDSHandle_t handle = shared_region->cfe_es_registerCDS.CDS_Handle; + CDS_sizes[handle] = BlockSize; + *HandlePtr = handle; + } + return result; +} + +int32 +CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t CDSHandle) +{ + shared_region->cfe_es_restoreFromCDS.CDSHandle = CDSHandle; + + int32 result = emu_CFE_ES_RestoreFromCDS(spdid); + + if (result == CFE_SUCCESS) { + /* CDSHandle is unsigned, so it can't be invalid by being negative */ + assert(CDSHandle < CFE_ES_CDS_MAX_NUM_ENTRIES); + size_t data_size = CDS_sizes[CDSHandle]; + assert(data_size <= EMU_BUF_SIZE); + + memcpy(RestoreToMemory, shared_region->cfe_es_restoreFromCDS.RestoreToMemory, data_size); + } + + return result; +} + int32 CFE_ES_RunLoop(uint32 *RunStatus) { diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index c5a778c78b..2d9f151414 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -50,12 +50,15 @@ cos_asm_server_stub(OS_rewinddir) cos_asm_server_stub(emu_backend_request_memory) cos_asm_server_stub(emu_CFE_ES_CalculateCRC) +cos_asm_server_stub(emu_CFE_ES_CopyToCDS) cos_asm_server_stub(emu_CFE_ES_GetAppIDByName) cos_asm_server_stub(emu_CFE_ES_GetAppInfo) cos_asm_server_stub(emu_CFE_ES_GetGenCount) cos_asm_server_stub(emu_CFE_ES_GetGenCounterIDByName) cos_asm_server_stub(emu_CFE_ES_GetResetType) cos_asm_server_stub(emu_CFE_ES_GetTaskInfo) +cos_asm_server_stub(emu_CFE_ES_RegisterCDS) +cos_asm_server_stub(emu_CFE_ES_RestoreFromCDS) cos_asm_server_stub(emu_CFE_ES_RunLoop) cos_asm_server_stub(emu_CFE_ES_WriteToSysLog) From 6869ec47760182546fc9e643d3549270da47f822 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sun, 15 Apr 2018 20:37:16 -0400 Subject: [PATCH 113/122] Implement support for TIME_SyncCallback in the cFE api --- .../no_interface/cFE_booter/cFE_emu_support.c | 53 ++++++++++++- src/components/interface/cFE/cFE_emu.h | 4 +- src/components/interface/cFE/stubs/c_stub.c | 76 ++++++++++++++++++- src/components/interface/cFE/stubs/s_stub.S | 4 +- 4 files changed, 131 insertions(+), 6 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c index ca3008b9fa..876ef8830e 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -2,8 +2,11 @@ #include #include +#include #include +#include +#include #include #include @@ -12,8 +15,24 @@ union shared_region *shared_regions[16]; +int have_registered_sync_callback = 0; +asndcap_t sync_callback_delegates[CFE_TIME_MAX_NUM_SYNCH_FUNCS]; + +int32 +sync_callback_handler() +{ + int i; + for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) { + asndcap_t callback = sync_callback_delegates[i]; + if (callback) { + cos_asnd(callback, 1); + } + } + return CFE_SUCCESS; +} + int -emu_backend_request_memory(spdid_t client) +emu_request_memory(spdid_t client) { vaddr_t our_addr = 0; int id = memmgr_shared_page_alloc(&our_addr); @@ -21,9 +40,26 @@ emu_backend_request_memory(spdid_t client) assert(our_addr); shared_regions[client] = (void *)our_addr; + // FIXME: This is broken if applications can stop (because then the handler could get auto-deregistered) + if (!have_registered_sync_callback){ + CFE_TIME_RegisterSynchCallback(sync_callback_handler); + have_registered_sync_callback = 1; + } + return id; } + +void +emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_aepkey_t key) +{ + struct cos_defcompinfo child_dci; + cos_defcompinfo_childid_init(&child_dci, client); + + sl_thd_aep_alloc_ext(&child_dci, NULL, idx, 1, 0, key, NULL); +} + + int32 emu_CFE_ES_CalculateCRC(spdid_t client) { @@ -150,7 +186,6 @@ emu_CFE_EVS_SendEvent(spdid_t client) s->cfe_evs_sendEvent.Msg); } - uint16 emu_CFE_SB_GetCmdCode(spdid_t client) { @@ -270,6 +305,20 @@ emu_CFE_TIME_Print(spdid_t client) CFE_TIME_Print(s->cfe_time_print.PrintBuffer, s->cfe_time_print.TimeToPrint); } +int32 +emu_CFE_TIME_RegisterSynchCallback(cos_aepkey_t key) +{ + int i; + for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) + { + if (!sync_callback_delegates[i]) { + sync_callback_delegates[i] = capmgr_asnd_key_create(key); + return CFE_SUCCESS; + } + } + return CFE_TIME_TOO_MANY_SYNCH_CALLBACKS; +} + int32 emu_OS_cp(spdid_t client) { diff --git a/src/components/interface/cFE/cFE_emu.h b/src/components/interface/cFE/cFE_emu.h index 0ac547f583..8877106b2a 100644 --- a/src/components/interface/cFE/cFE_emu.h +++ b/src/components/interface/cFE/cFE_emu.h @@ -201,7 +201,8 @@ union shared_region { } cfe_es_restoreFromCDS; }; -int emu_backend_request_memory(spdid_t client); +int emu_request_memory(spdid_t client); +void emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_aepkey_t key); int32 emu_CFE_ES_CalculateCRC(spdid_t client); int32 emu_CFE_ES_CopyToCDS(spdid_t client); @@ -239,6 +240,7 @@ void emu_CFE_TIME_Add(spdid_t client); void emu_CFE_TIME_Compare(spdid_t client); void emu_CFE_TIME_GetTime(spdid_t client); void emu_CFE_TIME_Print(spdid_t client); +int32 emu_CFE_TIME_RegisterSynchCallback(cos_aepkey_t key); int32 emu_OS_cp(spdid_t client); int32 emu_OS_creat(spdid_t client); diff --git a/src/components/interface/cFE/stubs/c_stub.c b/src/components/interface/cFE/stubs/c_stub.c index 9e9ad94428..0f87bcf41b 100644 --- a/src/components/interface/cFE/stubs/c_stub.c +++ b/src/components/interface/cFE/stubs/c_stub.c @@ -2,7 +2,10 @@ #include #include +#include +#include #include +#include #include "../interface/capmgr/memmgr.h" #include @@ -12,26 +15,65 @@ #include +#define BASE_AEP_KEY 0xBEAFCAFE + union shared_region *shared_region; spdid_t spdid; +cos_aepkey_t time_sync_key; // NOTE: This is tagged as currently unused in the docs CFE_SB_Qos_t CFE_SB_Default_Qos = { 0 }; -size_t CDS_sizes[CFE_ES_CDS_MAX_NUM_ENTRIES] = { 0 }; +size_t CDS_sizes[CFE_ES_CDS_MAX_NUM_ENTRIES]; + +int sync_callbacks_are_setup = 0; +CFE_TIME_SynchCallbackPtr_t sync_callbacks[CFE_TIME_MAX_NUM_SYNCH_FUNCS]; void do_emulation_setup(spdid_t id) { spdid = id; - int region_id = emu_backend_request_memory(id); + int region_id = emu_request_memory(id); vaddr_t client_addr = 0; memmgr_shared_page_map(region_id, &client_addr); assert(client_addr); shared_region = (void *)client_addr; + + time_sync_key = BASE_AEP_KEY + id; +} + +void +handle_sync_callbacks(arcvcap_t rcv, void *data) +{ + while (1) { + int pending = cos_rcv(rcv, 0, NULL); + if (pending) { + int i; + for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) { + if (sync_callbacks[i]){ + sync_callbacks[i](); + } + } + } + } +} + +void +ensure_sync_callbacks_are_setup() +{ + if (!sync_callbacks_are_setup) + { + thdclosure_index_t idx = cos_thd_init_alloc(handle_sync_callbacks, NULL); + emu_create_aep_thread(spdid, idx, time_sync_key); + + int32 result = emu_CFE_TIME_RegisterSynchCallback(time_sync_key); + assert(result == CFE_SUCCESS); + sync_callbacks_are_setup = 1; + } } + // FIXME: Be more careful about user supplied pointers // FIXME: Take a lock in each function, so shared memory can't be corrupted uint32 @@ -407,6 +449,36 @@ CFE_TIME_Print(char *PrintBuffer, CFE_TIME_SysTime_t TimeToPrint) memcpy(PrintBuffer, shared_region->cfe_time_print.PrintBuffer, CFE_TIME_PRINTED_STRING_SIZE); } +int32 +CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr) +{ + ensure_sync_callbacks_are_setup(); + + int i; + for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) + { + if (!sync_callbacks[i]) { + sync_callbacks[i] = CallbackFuncPtr; + return CFE_SUCCESS; + } + } + return CFE_TIME_TOO_MANY_SYNCH_CALLBACKS; +} + +int32 +CFE_TIME_UnregisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr) +{ + int i; + for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) + { + if (sync_callbacks[i] == CallbackFuncPtr) { + sync_callbacks[i] = NULL; + return CFE_SUCCESS; + } + } + return CFE_TIME_CALLBACK_NOT_REGISTERED; +} + int32 OS_cp(const char *src, const char *dest) { diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index 2d9f151414..8305a46d41 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -47,7 +47,8 @@ cos_asm_server_stub(OS_lseek) cos_asm_server_stub(OS_rewinddir) // Emulated methods -cos_asm_server_stub(emu_backend_request_memory) +cos_asm_server_stub(emu_request_memory) +cos_asm_server_stub(emu_create_aep_thread) cos_asm_server_stub(emu_CFE_ES_CalculateCRC) cos_asm_server_stub(emu_CFE_ES_CopyToCDS) @@ -85,6 +86,7 @@ cos_asm_server_stub(emu_CFE_TIME_Add) cos_asm_server_stub(emu_CFE_TIME_Compare) cos_asm_server_stub(emu_CFE_TIME_GetTime) cos_asm_server_stub(emu_CFE_TIME_Print) +cos_asm_server_stub(emu_CFE_TIME_RegisterSynchCallback) cos_asm_server_stub(emu_OS_cp) cos_asm_server_stub(emu_OS_creat) From 1913e0140ff85a98d1e4a188184966bc0d67f53f Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sun, 15 Apr 2018 22:27:40 -0400 Subject: [PATCH 114/122] Manually fixup the formatting in the cFE --- .../no_interface/cFE_booter/cFE_emu_support.c | 59 ++-- .../no_interface/cFE_booter/cFE_entrypoint.c | 12 +- .../no_interface/cFE_booter/osapi.c | 116 ++++---- .../no_interface/cFE_booter/osfiles.c | 46 ++- .../no_interface/cFE_booter/osfilesys.c | 246 ++++++++++------- .../no_interface/cFE_booter/osfilesys.h | 11 +- .../no_interface/cFE_booter/osloader.c | 8 +- .../no_interface/cFE_booter/osnetwork.c | 42 +-- .../no_interface/cFE_booter/osqueue.c | 60 ++-- .../no_interface/cFE_booter/ostask.c | 162 ++++++----- .../no_interface/cFE_booter/ostimer.c | 16 +- .../no_interface/cFE_booter/psp.c | 261 +++++++++--------- .../no_interface/cFE_booter/tar.c | 27 +- .../no_interface/cFE_booter/tar.h | 4 +- src/components/interface/cFE/cFE_emu.h | 1 + src/components/interface/cFE/stubs/c_stub.c | 175 ++++++++---- src/components/interface/cFE/stubs/s_stub.S | 1 + 17 files changed, 704 insertions(+), 543 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c index 876ef8830e..4e5b23d222 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -15,18 +15,18 @@ union shared_region *shared_regions[16]; -int have_registered_sync_callback = 0; +int have_registered_sync_callback = 0; asndcap_t sync_callback_delegates[CFE_TIME_MAX_NUM_SYNCH_FUNCS]; int32 sync_callback_handler() { - int i; + int i; + asndcap_t callback; + for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) { - asndcap_t callback = sync_callback_delegates[i]; - if (callback) { - cos_asnd(callback, 1); - } + callback = sync_callback_delegates[i]; + if (callback) { cos_asnd(callback, 1); } } return CFE_SUCCESS; } @@ -40,8 +40,8 @@ emu_request_memory(spdid_t client) assert(our_addr); shared_regions[client] = (void *)our_addr; - // FIXME: This is broken if applications can stop (because then the handler could get auto-deregistered) - if (!have_registered_sync_callback){ + /* FIXME: This is broken if applications can stop (because then the handler could get auto-deregistered) */ + if (!have_registered_sync_callback) { CFE_TIME_RegisterSynchCallback(sync_callback_handler); have_registered_sync_callback = 1; } @@ -101,7 +101,8 @@ int32 emu_CFE_ES_GetGenCounterIDByName(spdid_t client) { union shared_region *s = shared_regions[client]; - return CFE_ES_GetGenCounterIDByName(&s->cfe_es_getGenCounterIDByName.CounterId, s->cfe_es_getGenCounterIDByName.CounterName); + return CFE_ES_GetGenCounterIDByName(&s->cfe_es_getGenCounterIDByName.CounterId, + s->cfe_es_getGenCounterIDByName.CounterName); } int32 @@ -122,7 +123,8 @@ int32 emu_CFE_ES_RegisterCDS(spdid_t client) { union shared_region *s = shared_regions[client]; - return CFE_ES_RegisterCDS(&s->cfe_es_registerCDS.CDS_Handle, s->cfe_es_registerCDS.BlockSize, s->cfe_es_registerCDS.Name); + return CFE_ES_RegisterCDS(&s->cfe_es_registerCDS.CDS_Handle, s->cfe_es_registerCDS.BlockSize, + s->cfe_es_registerCDS.Name); } int32 @@ -203,9 +205,9 @@ emu_CFE_SB_GetMsgId(spdid_t client) void emu_CFE_SB_GetMsgTime(spdid_t client) { - union shared_region *s = shared_regions[client]; - CFE_TIME_SysTime_t time = CFE_SB_GetMsgTime((CFE_SB_MsgPtr_t)&s->cfe_sb_msg.Msg); - s->time = time; + union shared_region *s = shared_regions[client]; + CFE_TIME_SysTime_t time = CFE_SB_GetMsgTime((CFE_SB_MsgPtr_t)&s->cfe_sb_msg.Msg); + s->time = time; } uint16 @@ -227,15 +229,15 @@ int32 emu_CFE_SB_RcvMsg(spdid_t client) { union shared_region *s = shared_regions[client]; - - CFE_SB_MsgPtr_t BufPtr; - int32 result = CFE_SB_RcvMsg(&BufPtr, s->cfe_sb_rcvMsg.PipeId, s->cfe_sb_rcvMsg.TimeOut); + CFE_SB_MsgPtr_t BufPtr; + int32 result = CFE_SB_RcvMsg(&BufPtr, s->cfe_sb_rcvMsg.PipeId, s->cfe_sb_rcvMsg.TimeOut); + int len; /* We want to save the message contents to the shared region * But we need to be sure there is something to copy, so we check the call was successful */ if (result == CFE_SUCCESS) { - int len = CFE_SB_GetTotalMsgLength(BufPtr); + len = CFE_SB_GetTotalMsgLength(BufPtr); assert(len <= EMU_BUF_SIZE); memcpy(s->cfe_sb_rcvMsg.Msg, (char *)BufPtr, len); } @@ -261,7 +263,7 @@ emu_CFE_SB_SubscribeEx(spdid_t client) { union shared_region *s = shared_regions[client]; return CFE_SB_SubscribeEx(s->cfe_sb_subscribeEx.MsgId, s->cfe_sb_subscribeEx.PipeId, - s->cfe_sb_subscribeEx.Quality, s->cfe_sb_subscribeEx.MsgLim); + s->cfe_sb_subscribeEx.Quality, s->cfe_sb_subscribeEx.MsgLim); } void @@ -288,14 +290,15 @@ emu_CFE_TIME_Add(spdid_t client) void emu_CFE_TIME_Compare(spdid_t client) { - union shared_region *s = shared_regions[client]; + union shared_region *s = shared_regions[client]; s->cfe_time_compare.Result = CFE_TIME_Compare(s->cfe_time_compare.Time1, s->cfe_time_compare.Time2); } void -emu_CFE_TIME_GetTime(spdid_t client) { +emu_CFE_TIME_GetTime(spdid_t client) +{ union shared_region *s = shared_regions[client]; - s->time = CFE_TIME_GetTime(); + s->time = CFE_TIME_GetTime(); } void @@ -309,8 +312,7 @@ int32 emu_CFE_TIME_RegisterSynchCallback(cos_aepkey_t key) { int i; - for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) - { + for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) { if (!sync_callback_delegates[i]) { sync_callback_delegates[i] = capmgr_asnd_key_create(key); return CFE_SUCCESS; @@ -386,7 +388,7 @@ void emu_OS_readdir(spdid_t client) { union shared_region *s = shared_regions[client]; - s->os_readdir.dirent = *OS_readdir(s->os_readdir.directory); + s->os_readdir.dirent = *OS_readdir(s->os_readdir.directory); } int32 @@ -428,17 +430,20 @@ int32 emu_OS_BinSemCreate(spdid_t client) { union shared_region *s = shared_regions[client]; - return OS_BinSemCreate(&s->os_semCreate.sem_id, s->os_semCreate.sem_name, s->os_semCreate.sem_initial_value, s->os_semCreate.options); + return OS_BinSemCreate(&s->os_semCreate.sem_id, s->os_semCreate.sem_name, s->os_semCreate.sem_initial_value, + s->os_semCreate.options); } int32 emu_OS_CountSemCreate(spdid_t client) { union shared_region *s = shared_regions[client]; - return OS_CountSemCreate(&s->os_semCreate.sem_id, s->os_semCreate.sem_name, s->os_semCreate.sem_initial_value, s->os_semCreate.options); + return OS_CountSemCreate(&s->os_semCreate.sem_id, s->os_semCreate.sem_name, s->os_semCreate.sem_initial_value, + s->os_semCreate.options); } -int32 emu_OS_MutSemCreate(spdid_t client) +int32 +emu_OS_MutSemCreate(spdid_t client) { union shared_region *s = shared_regions[client]; return OS_MutSemCreate(&s->os_mutSemCreate.sem_id, s->os_mutSemCreate.sem_name, s->os_mutSemCreate.options); diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c index 59d7967c8c..fbc003b467 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_entrypoint.c @@ -51,14 +51,10 @@ CFE_PSP_ModuleInit(void) */ struct CFE_PSP_CommandData_t { char ResetType[CFE_PSP_RESET_NAME_LENGTH]; /* Reset type can be "PO" for Power on or "PR" for Processor Reset */ - - uint32 SubType; /* Reset Sub Type ( 1 - 5 ) */ - - char CpuName[CFE_PSP_CPU_NAME_LENGTH]; /* CPU Name */ - - uint32 CpuId; /* CPU ID */ - - uint32 SpacecraftId; /* Spacecraft ID */ + uint32 SubType; /* Reset Sub Type ( 1 - 5 ) */ + char CpuName[CFE_PSP_CPU_NAME_LENGTH]; /* CPU Name */ + uint32 CpuId; /* CPU ID */ + uint32 SpacecraftId; /* Spacecraft ID */ }; void diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 1ca7757437..27b1a50ca0 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -12,18 +12,21 @@ #include "cFE_util.h" /* -** Initialization of API -*/ + * Initialization of API + */ int have_initialized = 0; int32 OS_API_Init(void) { + struct cos_defcompinfo *defci; + struct cos_compinfo * ci; + if (have_initialized) return OS_SUCCESS; cos_defcompinfo_init(); - struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); - struct cos_compinfo * ci = cos_compinfo_get(defci); + defci = cos_defcompinfo_curr_get(); + ci = cos_compinfo_get(defci); cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT); OS_FS_Init(); @@ -35,10 +38,10 @@ OS_API_Init(void) } /* -** OS_DeleteAllObjects() provides a means to clean up all resources allocated by this -** instance of OSAL. It would typically be used during an orderly shutdown but may also -** be helpful for testing purposes. -*/ + * OS_DeleteAllObjects() provides a means to clean up all resources allocated by this + * instance of OSAL. It would typically be used during an orderly shutdown but may also + * be helpful for testing purposes. + */ void OS_DeleteAllObjects(void) { @@ -49,10 +52,10 @@ OS_DeleteAllObjects(void) * { * OS_TaskDelete(i); * } - * for (i = 0; i < OS_MAX_TIMERS; ++i) - * { - * OS_TimerDelete(i); - * } */ + * for (i = 0; i < OS_MAX_TIMERS; ++i) + * { + * OS_TimerDelete(i); + * } */ for (i = 0; i < OS_MAX_QUEUES; ++i) { OS_QueueDelete(i); } for (i = 0; i < OS_MAX_MUTEXES; ++i) { OS_MutSemDelete(i); } for (i = 0; i < OS_MAX_COUNT_SEMAPHORES; ++i) { OS_CountSemDelete(i); } @@ -63,14 +66,14 @@ OS_DeleteAllObjects(void) /* -** OS Time/Tick related API -*/ + * OS Time/Tick related API + */ int32 OS_Milli2Ticks(uint32 milliseconds) { uint32 ticks_per_millisecond = CFE_PSP_GetTimerTicksPerSecond() / 1000; - return (int32) (ticks_per_millisecond * milliseconds); + return (int32)(ticks_per_millisecond * milliseconds); } int32 @@ -130,13 +133,13 @@ OS_SetLocalTime(OS_time_t *time_struct) } /*end OS_SetLocalTime */ /* -** Exception API -*/ + * Exception API + */ int32 OS_ExcAttachHandler(uint32 ExceptionNumber, void (*ExceptionHandler)(uint32, const void *, uint32), int32 parameter) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } @@ -144,53 +147,53 @@ OS_ExcAttachHandler(uint32 ExceptionNumber, void (*ExceptionHandler)(uint32, con int32 OS_ExcEnable(int32 ExceptionNumber) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_ExcDisable(int32 ExceptionNumber) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } /* -** Floating Point Unit API -*/ + * Floating Point Unit API + */ int32 OS_FPUExcAttachHandler(uint32 ExceptionNumber, void *ExceptionHandler, int32 parameter) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_FPUExcEnable(int32 ExceptionNumber) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_FPUExcDisable(int32 ExceptionNumber) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_FPUExcSetMask(uint32 mask) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_FPUExcGetMask(uint32 *mask) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } @@ -201,7 +204,7 @@ OS_FPUExcGetMask(uint32 *mask) int32 OS_IntAttachHandler(uint32 InterruptNumber, osal_task_entry InterruptHandler, int32 parameter) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } @@ -232,83 +235,83 @@ OS_IntDisable(int32 Level) int32 OS_IntSetMask(uint32 mask) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_IntGetMask(uint32 *mask) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_IntAck(int32 InterruptNumber) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } /* -** Shared memory API -*/ + * Shared memory API + */ int32 OS_ShMemInit(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_ShMemCreate(uint32 *Id, uint32 NBytes, const char *SegName) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_ShMemSemTake(uint32 Id) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_ShMemSemGive(uint32 Id) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_ShMemAttach(cpuaddr *Address, uint32 Id) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_ShMemGetIdByName(uint32 *ShMemId, const char *SegName) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } /* -** Heap API -*/ + * Heap API + */ int32 OS_HeapGetInfo(OS_heap_prop_t *heap_prop) { - // FIXME: Implement me! + /* TODO: Implement me! */ return OS_ERR_NOT_IMPLEMENTED; } /* -** API for useful debugging function -** (Implementation stolen from the posix osapi) -*/ + * API for useful debugging function + * (Implementation stolen from the posix osapi) + */ int32 OS_GetErrorName(int32 error_num, os_err_name_t *err_name) @@ -401,19 +404,26 @@ OS_GetErrorName(int32 error_num, os_err_name_t *err_name) /* -** Abstraction for printf statements -*/ + * Abstraction for printf statements + */ int is_printf_enabled = TRUE; +/* We expose this function so that app components can use it */ +int +emu_is_printf_enabled() +{ + return is_printf_enabled; +} + void OS_printf(const char *string, ...) { - if (!is_printf_enabled) return; - char s[OS_BUFFER_SIZE]; va_list arg_ptr; int ret, len = OS_BUFFER_SIZE; + if (!is_printf_enabled) return; + va_start(arg_ptr, string); ret = vsnprintf(s, len, string, arg_ptr); va_end(arg_ptr); @@ -442,10 +452,10 @@ OS_printf_enable(void) } /* -** Call to exit the running application -** Normally embedded applications run forever, but for debugging purposes -** (unit testing for example) this is needed in order to end the test -*/ + * Call to exit the running application + * Normally embedded applications run forever, but for debugging purposes + * (unit testing for example) this is needed in order to end the test + */ void OS_ApplicationExit(int32 Status) { diff --git a/src/components/implementation/no_interface/cFE_booter/osfiles.c b/src/components/implementation/no_interface/cFE_booter/osfiles.c index 697fb94622..8a928d5c66 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfiles.c +++ b/src/components/implementation/no_interface/cFE_booter/osfiles.c @@ -12,9 +12,9 @@ int32 OS_FS_Init(void) { os_dirent_t d; + uint32 ret = 0; - uint32 ret = 0; - ret = tar_load(); + ret = tar_load(); if (ret != OS_FS_SUCCESS) return ret; ret = fs_init("/ramdev0", "RAM", 512, 4096); if (ret != OS_FS_SUCCESS) return ret; @@ -39,8 +39,10 @@ OS_creat(const char *path, int32 access) int32 OS_open(const char *path, int32 access, uint32 mode) { + int32 ret; + if (access != OS_READ_WRITE && access != OS_WRITE_ONLY && access != OS_READ_ONLY) { return OS_FS_ERROR; } - int32 ret = path_exists(path); + ret = path_exists(path); if (ret != OS_FS_SUCCESS) return ret; return file_open((char *)path, access); } @@ -90,8 +92,10 @@ OS_chmod(const char *path, uint32 access) int32 OS_stat(const char *path, os_fstat_t *filestats) { + int32 ret; + if (!filestats || !path) return OS_FS_ERR_INVALID_POINTER; - int32 ret = path_exists(path); + ret = path_exists(path); if (ret != OS_FS_SUCCESS) return ret; return file_stat((char *)path, filestats); } @@ -122,8 +126,10 @@ OS_remove(const char *path) int32 OS_rename(const char *old_filename, const char *new_filename) { + int32 ret; + if (!old_filename || !new_filename) return OS_FS_ERR_INVALID_POINTER; - int32 ret = path_exists(old_filename); + ret = path_exists(old_filename); if (ret != OS_FS_SUCCESS) return ret; ret = path_isvalid(new_filename); if (ret != OS_FS_SUCCESS) return ret; @@ -138,16 +144,20 @@ OS_rename(const char *old_filename, const char *new_filename) int32 OS_cp(const char *src, const char *dest) { + int32 ret; + char *src_path; + char *dest_path; + if (!src || !dest) return OS_FS_ERR_INVALID_POINTER; - char *src_path = (char *)src; - char *dest_path = (char *)dest; + src_path = (char *)src; + dest_path = (char *)dest; if (strlen(src_path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; if (strlen(dest_path) > OS_MAX_PATH_LEN) return OS_FS_ERR_PATH_TOO_LONG; if (strlen(path_to_name(src_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; if (strlen(path_to_name(dest_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; - int32 ret = path_exists(src_path); + ret = path_exists(src_path); if (ret != OS_FS_SUCCESS) return ret; ret = path_isvalid(dest_path); if (ret != OS_FS_SUCCESS) return ret; @@ -161,6 +171,7 @@ OS_cp(const char *src, const char *dest) int32 OS_mv(const char *src, const char *dest) { + int32 ret; char *src_path = (char *)src; char *dest_path = (char *)dest; @@ -170,7 +181,7 @@ OS_mv(const char *src, const char *dest) if (strlen(path_to_name(src_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; if (strlen(path_to_name(dest_path)) > OS_MAX_FILE_NAME) return OS_FS_ERR_NAME_TOO_LONG; - int32 ret = path_exists(src); + ret = path_exists(src); if (ret != OS_FS_SUCCESS) return ret; ret = path_isvalid(dest); if (ret != OS_FS_SUCCESS) return ret; @@ -196,10 +207,12 @@ OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) int32 OS_FileOpenCheck(char *Filename) { - int32 ret = path_exists(Filename); + struct fsobj *file; + int32 ret = path_exists(Filename); + if (ret != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_POINTER; - struct fsobj *file = file_find(Filename); + file = file_find(Filename); if (!file) return OS_INVALID_POINTER; if (file->refcnt == 0) return OS_FS_ERROR; return OS_FS_SUCCESS; @@ -249,8 +262,9 @@ OS_mkdir(const char *path, uint32 access) os_dirp_t OS_opendir(const char *path) { + int32 FD; if (path_exists(path) != OS_FS_SUCCESS) return NULL; - int32 FD = dir_open((char *)path); + FD = dir_open((char *)path); if (FD == 0) return NULL; return (os_dirp_t)FD; } @@ -350,8 +364,10 @@ OS_rmfs(char *devname) int32 OS_unmount(const char *mountpoint) { + int32 ret; + if (!mountpoint) return OS_FS_ERR_INVALID_POINTER; - int32 ret = path_exists(mountpoint); + ret = path_exists(mountpoint); if (ret != OS_FS_SUCCESS) return ret; return fs_unmount((char *)mountpoint); } @@ -386,8 +402,10 @@ OS_chkfs(const char *name, boolean repair) int32 OS_FS_GetPhysDriveName(char *PhysDriveName, char *MountPoint) { + int32 ret; + if (!PhysDriveName || !MountPoint) return OS_FS_ERR_INVALID_POINTER; - int32 ret = path_exists(MountPoint); + ret = path_exists(MountPoint); if (ret != OS_FS_SUCCESS) return ret; return fs_get_drive_name(PhysDriveName, MountPoint); } diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.c b/src/components/implementation/no_interface/cFE_booter/osfilesys.c index 91d6d14cf0..74f2643272 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.c +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.c @@ -26,21 +26,23 @@ struct fd fd_tbl[OS_MAX_NUM_OPEN_FILES + 1]; ** fsobj Level Methods ******************************************************************************/ -// checks if a file descriptor is valid and in use +/* checks if a file descriptor is valid and in use */ int32 chk_fd(int32 FD) { + struct fd *filedes; + if (FD > OS_MAX_NUM_OPEN_FILES) return OS_FS_ERR_INVALID_FD; if (FD <= 0) return OS_FS_ERR_INVALID_FD; - struct fd *filedes = &fd_tbl[FD]; + filedes = &fd_tbl[FD]; if (!filedes->file) return OS_FS_ERR_INVALID_FD; if (filedes->ino == 0 || filedes->file->ino == 0) return OS_FS_ERR_INVALID_FD; assert(filedes->ino == filedes->file->ino); return OS_FS_SUCCESS; } -// finds the next free file +/* finds the next free file */ uint32 file_get_new(struct fsobj **o) { @@ -49,8 +51,8 @@ file_get_new(struct fsobj **o) if (count == MAX_NUM_FILES) return OS_FS_ERROR; *o = &files[count]; - **o = (struct fsobj){// ino needs to be unique and nonzero, so ino is defined as index+1 - .ino = count + 1}; + /* ino needs to be unique and nonzero, so ino is defined as index+1 */ + **o = (struct fsobj){.ino = count + 1}; return OS_FS_SUCCESS; } @@ -59,7 +61,7 @@ file_insert(struct fsobj *o, char *path) { assert(o && path && openfs); - // paths should always begin with '/' but we do not need it here + /* paths should always begin with '/' but we do not need it here */ if (path[0] != '/') return OS_FS_ERR_PATH_INVALID; path++; @@ -71,7 +73,7 @@ file_insert(struct fsobj *o, char *path) assert(openfs->root->ino); struct fsobj *cur = openfs->root; - // token is the current directory in path + /* token is the current directory in path */ char path_temp[OS_MAX_PATH_LEN * 2]; strcpy(path_temp, path); const char delim[2] = "/"; @@ -79,14 +81,14 @@ file_insert(struct fsobj *o, char *path) if (strcmp(token, cur->name) != 0) return OS_FS_ERR_PATH_INVALID; - // loop terminates when it finds a place to put o or determines path is invalid + /* loop terminates when it finds a place to put o or determines path is invalid */ while (1) { if (token == NULL) { return OS_FS_ERR_PATH_INVALID; } assert(cur->name); - // if there is no child, then insert as child + /* if there is no child, then insert as child */ if (!cur->child) { - // if the next part of the path is not o->name or there is a part after it, bad path + /* if the next part of the path is not o->name or there is a part after it, bad path */ token = strtok(NULL, delim); if (strcmp(token, o->name) != 0 || strtok(NULL, delim) != NULL) { return OS_FS_ERR_PATH_INVALID; @@ -101,16 +103,17 @@ file_insert(struct fsobj *o, char *path) cur = cur->child; token = strtok(NULL, delim); - // precondition: cur is the first in a non-empty list of children - // postcondition: cur is an ancestor of o or o has been inserted in list - // while cur is not ancestor of o + /* precondition: cur is the first in a non-empty list of children + * postcondition: cur is an ancestor of o or o has been inserted in list + * while cur is not ancestor of o + */ while (strcmp(token, cur->name) != 0) { if (cur->next == NULL) { - // if the next part of the path is o->name or there is a part after it, bad path + /* if the next part of the path is o->name or there is a part after it, bad path */ if (strcmp(token, o->name) != 0 || strtok(NULL, delim) != NULL) { return OS_FS_ERR_PATH_INVALID; } - // insert o as the last child in a linked list of children + /* insert o as the last child in a linked list of children */ cur->next = o; o->prev = cur; o->parent = cur->parent; @@ -124,12 +127,12 @@ file_insert(struct fsobj *o, char *path) return 0; } -// Internally, FDs are considered unused when ino == 0 +/* Internally, FDs are considered unused when ino == 0 */ static int32 fd_get(int32 ino) { - uint32 count = 1; struct fd *filedes; + uint32 count = 1; while (count <= OS_MAX_NUM_OPEN_FILES + 1 && fd_tbl[count].ino != 0) { count++; } if (count == OS_MAX_NUM_OPEN_FILES + 1) return OS_FS_ERROR; @@ -143,20 +146,23 @@ fd_get(int32 ino) int32 file_open(char *path, enum fs_permissions permission) { + int32 FD; + struct fsobj *file; + struct fd * filedes; + assert(openfs); if (!openfs->root) return OS_FS_ERROR; if (!path) return OS_FS_ERR_INVALID_POINTER; - // find the file - struct fsobj *file = file_find(path); + file = file_find(path); if (!file) return OS_FS_ERR_PATH_INVALID; if (file->type != FSOBJ_FILE) return OS_FS_ERROR; - // get a new fd - int32 FD = fd_get(file->ino); + /* get a new fd */ + FD = fd_get(file->ino); if (FD == OS_FS_ERROR) { return OS_FS_ERR_NO_FREE_FDS; } - struct fd *filedes = &fd_tbl[FD]; + filedes = &fd_tbl[FD]; filedes->access = permission; filedes->file = file; @@ -186,8 +192,8 @@ file_close(int32 FD) int32 file_close_by_name(char *path) { - struct fsobj *file = file_find(path); int i; + struct fsobj *file = file_find(path); for (i = 0; i < OS_MAX_NUM_OPEN_FILES + 1; i++) { if (fd_tbl[i].file == file) { @@ -199,8 +205,9 @@ file_close_by_name(char *path) return OS_FS_ERROR; } -// converts from the cFE defined permission constants to internal permission type -// unknown permissions return NONE, cFE should treat none as an error +/* converts from the cFE defined permission constants to internal permission type + * unknown permissions return NONE, cFE should treat none as an error + */ enum fs_permissions permission_cFE_to_cos(uint32 permission) { @@ -235,7 +242,6 @@ permission_cos_to_cFE(enum fs_permissions permission) return 0; } -// checks if a path is the right format for a path, and if it exists int32 path_exists(const char *path) { @@ -245,7 +251,6 @@ path_exists(const char *path) return OS_FS_SUCCESS; } -// checks if a path is the correct format, for example to be inserted int32 path_isvalid(const char *path) { @@ -265,8 +270,10 @@ path_isvalid(const char *path) int32 path_translate(char *virt, char *local) { + int32 ret; + if (!virt || !local) return OS_FS_ERR_INVALID_POINTER; - int32 ret = path_isvalid(virt); + ret = path_isvalid(virt); if (ret != OS_FS_SUCCESS) return ret; if (!openfs->root) return OS_FS_ERR_PATH_INVALID; ret = path_exists(virt); @@ -282,9 +289,6 @@ path_translate(char *virt, char *local) uint32 part_get_new(struct f_part **part) { - struct cos_defcompinfo *defci = cos_defcompinfo_curr_get(); - struct cos_compinfo * ci = &defci->ci; - *part = (void *)memmgr_heap_page_alloc(); assert(part != NULL); @@ -310,7 +314,7 @@ file_read(int32 FD, void *buffer, uint32 nbytes) struct file_position *position = &filedes->position.file_pos; struct f_part * part = position->open_part; - // nbytes > number of bytes left in file, only number left are read + /* nbytes > number of bytes left in file, only number left are read */ if (nbytes > o->size - position->file_offset) { nbytes = o->size - position->file_offset; } if (nbytes == OS_FS_SUCCESS) return 0; @@ -318,7 +322,7 @@ file_read(int32 FD, void *buffer, uint32 nbytes) if (o->memtype == DYNAMIC) { while (1) { - // read_size is the length of a continuous segment to be read from + /* read_size is the length of a continuous segment to be read from */ uint32 read_size = F_PART_DATA_SIZE - position->file_offset; part = position->open_part; assert(part); @@ -348,7 +352,7 @@ file_read(int32 FD, void *buffer, uint32 nbytes) position->part_offset = 0; return nbytes; - // bytes_to_read < the continuous space left on f_part + /* bytes_to_read < the continuous space left on f_part */ } else { memcpy(buffer, position->open_part->data + position->part_offset, bytes_to_read); position->part_offset += bytes_to_read; @@ -372,8 +376,12 @@ file_read(int32 FD, void *buffer, uint32 nbytes) int32 file_write(int32 FD, void *buffer, uint32 nbytes) { + int32 ret; + uint32 bytes_to_write; + uint32 bytes_remaining; + if (!buffer) return OS_FS_ERR_INVALID_POINTER; - int32 ret = chk_fd(FD); + ret = chk_fd(FD); if (ret != OS_FS_SUCCESS) return ret; struct fd * filedes = &fd_tbl[FD]; @@ -385,10 +393,10 @@ file_write(int32 FD, void *buffer, uint32 nbytes) if (o->type == FSOBJ_DIR) return OS_FS_ERROR; if (nbytes == 0) return 0; - uint32 bytes_to_write = nbytes; - uint32 bytes_remaining = F_PART_DATA_SIZE - position->part_offset; + bytes_to_write = nbytes; + bytes_remaining = F_PART_DATA_SIZE - position->part_offset; - // while there are enough bytes to be written to fill a f_part + /* while there are enough bytes to be written to fill a f_part */ while (bytes_to_write > bytes_remaining) { memcpy(position->open_part->data + position->part_offset, buffer, bytes_remaining); position->file_offset += bytes_remaining; @@ -407,7 +415,7 @@ file_write(int32 FD, void *buffer, uint32 nbytes) position->open_part = position->open_part->next; bytes_remaining = F_PART_DATA_SIZE - position->part_offset; } - // bytes_to_write < bytes_remaining + /* bytes_to_write < bytes_remaining */ memcpy(position->open_part->data, buffer, bytes_to_write); position->part_offset += bytes_to_write; position->file_offset += bytes_to_write; @@ -418,24 +426,27 @@ file_write(int32 FD, void *buffer, uint32 nbytes) struct fsobj * file_find(char *path) { + char path_temp[OS_MAX_PATH_LEN * 2]; + const char delim[2] = "/"; + char * token; + struct fsobj *cur; + assert(path); - // paths should always begin with '/' dir names do not + /* paths should always begin with '/' dir names do not */ if (path[0] != '/') return NULL; path++; - // token is the current directory in path - char path_temp[OS_MAX_PATH_LEN * 2]; + /* token is the current directory in path */ strcpy(path_temp, path); - const char delim[2] = "/"; - char * token = strtok(path_temp, delim); + token = strtok(path_temp, delim); if (!openfs || !openfs->root) return NULL; - struct fsobj *cur = openfs->root; + cur = openfs->root; assert(cur && cur->name); if (strcmp(token, cur->name) != 0) return NULL; while (1) { - // iterate through linked list of children until ancestor is found + /* iterate through linked list of children until ancestor is found */ while (strcmp(token, cur->name) != 0) { if (!cur->next) return NULL; cur = cur->next; @@ -452,9 +463,10 @@ file_find(char *path) int32 file_create(char *path, enum fs_permissions permission) { + struct fsobj *o; + assert(path); - struct fsobj *o; if (file_get_new(&o) != OS_FS_SUCCESS) return OS_FS_ERROR; o->name = path_to_name(path); o->type = FSOBJ_FILE; @@ -479,6 +491,7 @@ int32 file_remove(char *path) { struct fsobj *file = file_find(path); + if (!file) return OS_FS_ERR_PATH_INVALID; file_rm(file); return OS_FS_SUCCESS; @@ -488,17 +501,20 @@ int32 file_rename(char *old_filename, char *new_filename) { struct fsobj *file = file_find(old_filename); + if (!file) return OS_FS_ERR_PATH_INVALID; file->name = path_to_name(new_filename); return OS_FS_SUCCESS; } -// This is part of but not a full posix implementation, -// stat has a lot of fields not applicable to us +/* This is part of but not a full posix implementation, + * stat has a lot of fields not applicable to us + */ int32 file_stat(char *path, os_fstat_t *filestats) { struct fsobj *file = file_find(path); + if (!file) return OS_FS_ERROR; *filestats = (os_fstat_t){.st_dev = 0, .st_ino = file->ino, .st_size = file->size, .st_blksize = F_PART_DATA_SIZE}; @@ -512,16 +528,16 @@ file_stat(char *path, os_fstat_t *filestats) int32 file_lseek(int32 FD, int32 offset, uint32 whence) { - int32 ret = chk_fd(FD); + uint32 target_offset = 0; + int32 ret = chk_fd(FD); + if (ret != OS_FS_SUCCESS) return ret; struct fd * filedes = &fd_tbl[FD]; struct fsobj * o = filedes->file; struct file_position *position = &filedes->position.file_pos; - uint32 target_offset = 0; - - // wasnt sure if it should be legal to pass negative offset, went with yes + /* wasnt sure if it should be legal to pass negative offset, went with yes */ if (whence == SEEK_SET) { if (offset < 0) return OS_FS_ERROR; target_offset = offset; @@ -534,14 +550,15 @@ file_lseek(int32 FD, int32 offset, uint32 whence) } else { return OS_FS_ERROR; } - // you cannot write past the end of a static file + + /* you cannot write past the end of a static file */ if (target_offset > o->size && o->memtype == STATIC) { return OS_FS_ERROR; } position->open_part = o->file_part; position->file_offset = 0; while (target_offset - position->file_offset > F_PART_DATA_SIZE) { - // seeking past the end of a file writes zeros until that position + /* seeking past the end of a file writes zeros until that position */ if (position->open_part->next == NULL) { struct f_part *part; part_get_new(&part); @@ -563,25 +580,30 @@ file_lseek(int32 FD, int32 offset, uint32 whence) int32 file_cp(char *src, char *dest) { + int32 fd_src; + int32 fd_dest; + int32 to_copy; + int32 read_size, write_size; static char copy_buffer[F_PART_DATA_SIZE]; - int32 fd_src = file_open(src, READ); + fd_src = file_open(src, READ); if (chk_fd(fd_src) != OS_FS_SUCCESS) return fd_src; - // if the dest already exists, overwrite it - int32 fd_dest = file_open(dest, WRITE); + /* if the dest already exists, overwrite it */ + fd_dest = file_open(dest, WRITE); if (chk_fd(fd_dest) == OS_FS_SUCCESS) { - // writing size to zero effectivly deletes all the old data + /* writing size to zero effectivly deletes all the old data */ fd_tbl[fd_dest].file->size = 0; } else { fd_dest = file_create(dest, fd_tbl[fd_src].file->permission); } if (chk_fd(fd_dest) != OS_FS_SUCCESS) return fd_dest; - int32 to_copy = fd_tbl[fd_src].file->size; - int32 read_size = 0, write_size = 0; + to_copy = fd_tbl[fd_src].file->size; + read_size = 0; + write_size = 0; - // TODO: copy buffer is aggressively not thread safe, take a lock + /* TODO: copy buffer is aggressively not thread safe, take a lock */ while (to_copy > 0) { if (to_copy > (int32)F_PART_DATA_SIZE) { read_size = F_PART_DATA_SIZE; @@ -624,10 +646,12 @@ file_mv(char *src, char *dest) int32 file_FDGetInfo(int32 FD, OS_FDTableEntry *fd_prop) { - int32 ret = chk_fd(FD); + struct fd *filedes; + int32 ret = chk_fd(FD); + if (ret != OS_FS_SUCCESS) return OS_FS_ERR_INVALID_FD; - struct fd *filedes = &fd_tbl[FD]; + filedes = &fd_tbl[FD]; if (filedes->ino == 0) return OS_FS_ERR_INVALID_FD; fd_prop->OSfd = FD; @@ -645,24 +669,28 @@ file_FDGetInfo(int32 FD, OS_FDTableEntry *fd_prop) int32 dir_open(char *path) { - struct fsobj *file; + int32 FD; + struct fsobj * file; + struct fd * filedes; + struct dir_position *position; + file = file_find(path); if (!file) return 0; if (file->ino == 0) return 0; if (file->type != FSOBJ_DIR) return 0; - int32 FD = fd_get(file->ino); + FD = fd_get(file->ino); if (FD > OS_MAX_NUM_OPEN_FILES + 1 || FD <= 0) return 0; file->refcnt++; - struct fd *filedes = &fd_tbl[FD]; - filedes->access = READ; - filedes->file = file; + filedes = &fd_tbl[FD]; + filedes->access = READ; + filedes->file = file; - struct dir_position *position = &filedes->position.dir_pos; - position->open_dir = file; - position->cur = file; - position->status = NORMAL; + position = &filedes->position.dir_pos; + position->open_dir = file; + position->cur = file; + position->status = NORMAL; return FD; } @@ -670,8 +698,10 @@ dir_open(char *path) uint32 dir_close(int32 FD) { + struct fd *filedes; + if (FD > OS_MAX_NUM_OPEN_FILES + 1 || FD <= 0) return OS_FS_ERROR; - struct fd *filedes = &fd_tbl[FD]; + filedes = &fd_tbl[FD]; filedes->ino = 0; return OS_FS_SUCCESS; @@ -680,13 +710,15 @@ dir_close(int32 FD) void dir_rewind(int32 FD) { + struct fd *filedes; + if (FD >= OS_MAX_NUM_OPEN_FILES || FD <= 0) return; - struct fd *filedes = &fd_tbl[FD]; + filedes = &fd_tbl[FD]; if (filedes->ino == 0) return; if (filedes->file->type != FSOBJ_DIR) return; - // cur == open_dir indicates that stream is in initial position, prior to first read + /* cur == open_dir indicates that stream is in initial position, prior to first read */ filedes->position.dir_pos.cur = filedes->position.dir_pos.open_dir; filedes->position.dir_pos.status = NORMAL; } @@ -694,13 +726,16 @@ dir_rewind(int32 FD) os_dirent_t * dir_read(int32 FD) { + struct fd * filedes; + os_dirent_t *dir; + if (FD > OS_MAX_NUM_OPEN_FILES + 1 || FD <= 0) return NULL; - struct fd *filedes = &fd_tbl[FD]; + filedes = &fd_tbl[FD]; if (filedes->ino == 0) return NULL; if (filedes->file->type != FSOBJ_DIR) return NULL; - os_dirent_t *dir = &filedes->position.dir_pos.dirent; + dir = &filedes->position.dir_pos.dirent; switch (filedes->position.dir_pos.status) { case NORMAL: @@ -742,8 +777,10 @@ dir_read(int32 FD) int32 file_mkdir(char *path) { - assert(path); struct fsobj *o; + + assert(path); + if (file_get_new(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; o->name = path_to_name(path); o->type = FSOBJ_DIR; @@ -759,12 +796,17 @@ file_mkdir(char *path) int32 file_rmdir(char *path) { + struct fsobj *root; + struct fsobj *cur; + assert(path); - struct fsobj *root = file_find(path); + + root = file_find(path); + cur = root; if (!root) return OS_FS_ERROR; - struct fsobj *cur = root; + while (root->child) { - // if cur is the last leaf in a list + /* if cur is the last leaf in a list */ if (!cur->next && !cur->child) { if (cur->prev != NULL) { assert(cur->prev->next == cur); @@ -777,7 +819,7 @@ file_rmdir(char *path) } } else if (cur->child != NULL) { cur = cur->child; - } else { // cur->next !=NULL + } else { cur = cur->next; } } @@ -788,34 +830,35 @@ file_rmdir(char *path) int32 file_rm(struct fsobj *o) { - // TODO, pass an error back out of library if someone implicitly tries to close open file - // assert(o->refcnt == 0); + /* TODO, pass an error back out of library if someone implicitly tries to close open file */ + /* assert(o->refcnt == 0); */ assert(o && o->child == NULL); - // if o is first in list of children, update parent link to it + /* if o is first in list of children, update parent link to it */ if (o->prev == NULL && o->parent) { assert(o->parent->child == o); - // if next = null this still works + /* if next = null this still works */ o->parent->child = o->next; } - // update link from prev still work if next or prev = null + /* update link from prev still work if next or prev = null */ if (o->prev) { assert(o->prev->next == o); o->prev->next = o->next; } - // update link from next + /* update link from next */ if (o->next) { assert(o->next->prev == o); o->next->prev = o->prev; } - // there should now be no links within the fs to o - // we do not do deallocate file data but we do reuse fsobj + /* there should now be no links within the fs to o + * we do not do deallocate file data but we do reuse fsobj + */ *o = (struct fsobj){.name = NULL}; return OS_FS_SUCCESS; } -// close all of the open FDs associated with file +/* close all of the open FDs associated with file */ int32 file_close_by_ino(int32 ino) { @@ -833,13 +876,16 @@ file_close_by_ino(int32 ino) uint32 fs_mount(char *devname, char *mountpoint) { - assert(devname); uint32 i; + + assert(devname); + for (i = 0; i < MAX_NUM_FS && filesystems[i].devname != NULL; i++) { if (!strcmp(filesystems[i].devname, devname)) { - // This is a bad hack that I have not found a solution to - // basically mount should fail if already mounted - // but to load tar I need to pre-mount the first filesystem + /* This is a bad hack that I have not found a solution to + * basically mount should fail if already mounted + * but to load tar I need to pre-mount the first filesystem + */ if (strcmp(mountpoint, "/ram") && filesystems[i].root) return OS_FS_ERROR; struct fsobj *o; if (file_get_new(&o)) return OS_FS_ERROR; @@ -857,6 +903,7 @@ uint32 fs_unmount(char *mountpoint) { uint32 i; + assert(mountpoint); for (i = 0; i < MAX_NUM_FS && filesystems[i].mountpoint != NULL; i++) { if (mountpoint != NULL && !strcmp(filesystems[i].mountpoint, mountpoint)) { @@ -871,6 +918,7 @@ uint32 fs_init(char *devname, char *volname, uint32 blocksize, uint32 numblocks) { uint32 count = 0, ret = 0; + if (!devname) return OS_FS_ERR_INVALID_POINTER; if (blocksize == 0 || numblocks == 0) return OS_FS_ERROR; if (strlen(devname) >= OS_FS_DEV_NAME_LEN || strlen(volname) >= OS_FS_VOL_NAME_LEN) return OS_FS_ERROR; @@ -892,9 +940,10 @@ fs_init(char *devname, char *volname, uint32 blocksize, uint32 numblocks) int32 fs_remove(char *devname) { + uint32 i; + if (!devname) return OS_FS_ERR_INVALID_POINTER; - uint32 i; for (i = 0; i < MAX_NUM_FS && filesystems[i].devname != NULL; i++) { if (devname && filesystems[i].devname && !strcmp(filesystems[i].devname, devname)) { filesystems[i].devname = NULL; @@ -926,8 +975,9 @@ fs_get_drive_name(char *PhysDriveName, char *MountPoint) int32 fs_get_info(os_fsinfo_t *filesys_info) { - filesys_info->MaxFds = MAX_NUM_FILES; uint32 i, count = 0; + + filesys_info->MaxFds = MAX_NUM_FILES; for (i = 0; i < MAX_NUM_FILES; i++) { if (files[i].ino == 0) count++; } diff --git a/src/components/implementation/no_interface/cFE_booter/osfilesys.h b/src/components/implementation/no_interface/cFE_booter/osfilesys.h index 08281c7f56..10bd71286e 100644 --- a/src/components/implementation/no_interface/cFE_booter/osfilesys.h +++ b/src/components/implementation/no_interface/cFE_booter/osfilesys.h @@ -13,13 +13,14 @@ #include "cFE_util.h" -// Not to be confused with similar OSAL constants. -// These are only to define size of statically allocated data +/* Not to be confused with similar OSAL constants. + * These are only to define size of statically allocated data + */ #define MAX_NUM_FS NUM_TABLE_ENTRIES #define MAX_NUM_FILES 100 #define MAX_NUM_DIRENT 10 -// a page is 4096, size of f_part is 5 values * 4 bytes +/* a page is 4096, size of f_part is 5 values * 4 bytes */ #define F_PART_DATA_SIZE (4096 - sizeof(struct f_part)) enum fsobj_type @@ -124,8 +125,10 @@ struct fs { static char * path_to_name(char *path) { + uint32 path_len, offset; + assert(path); - uint32 path_len = strlen(path), offset; + path_len = strlen(path); assert(path_len > 1); // remove one or more '/' at the end of path diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index ced5013e5e..6076b6e95b 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -36,7 +36,8 @@ int32 get_this_threads_priority() { OS_task_prop_t prop; - int32 result = OS_TaskGetInfo(sl_thdid(), &prop); + int32 result = OS_TaskGetInfo(sl_thdid(), &prop); + assert(result == OS_SUCCESS); return prop.priority; } @@ -44,10 +45,11 @@ get_this_threads_priority() void launch_other_component(int child_id, int is_library) { + struct sl_thd * t; struct cos_defcompinfo child_dci; - cos_defcompinfo_childid_init(&child_dci, child_id); - struct sl_thd *t = sl_thd_initaep_alloc(&child_dci, NULL, 0, 0, 0); + cos_defcompinfo_childid_init(&child_dci, child_id); + t = sl_thd_initaep_alloc(&child_dci, NULL, 0, 0, 0); /* We need to override the delegate thread id, so the cFE think it's this thread * Otherwise cFE application id detection is broken diff --git a/src/components/implementation/no_interface/cFE_booter/osnetwork.c b/src/components/implementation/no_interface/cFE_booter/osnetwork.c index 8d72b5164c..010eedb778 100644 --- a/src/components/implementation/no_interface/cFE_booter/osnetwork.c +++ b/src/components/implementation/no_interface/cFE_booter/osnetwork.c @@ -4,120 +4,120 @@ #include "gen/common_types.h" /* -** Networking API -*/ + * Networking API + */ int32 OS_SocketOpen(uint32 *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t Type) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_SocketClose(uint32 sock_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_SocketBind(uint32 sock_id, const OS_SockAddr_t *Addr) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_SocketConnect(uint32 sock_id, const OS_SockAddr_t *Addr, int32 timeout) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_SocketAccept(uint32 sock_id, uint32 *connsock_id, OS_SockAddr_t *Addr, int32 timeout) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_SocketRecvFrom(uint32 sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_SocketSendTo(uint32 sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_SocketGetIdByName(uint32 *sock_id, const char *sock_name) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_SocketGetInfo(uint32 sock_id, OS_socket_prop_t *sock_prop) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_SocketAddrToString(char *buffer, uint32 buflen, const OS_SockAddr_t *Addr) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_SocketAddrFromString(OS_SockAddr_t *Addr, const char *string) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_SocketAddrGetPort(uint16 *PortNum, const OS_SockAddr_t *Addr) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } /* -** OS_NetworkGetID is currently [[deprecated]] as its behavior is -** unknown and not consistent across operating systems. -*/ + * OS_NetworkGetID is currently [[deprecated]] as its behavior is + * unknown and not consistent across operating systems. + */ int32 OS_NetworkGetID(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_NetworkGetHostName(char *host_name, uint32 name_len) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } diff --git a/src/components/implementation/no_interface/cFE_booter/osqueue.c b/src/components/implementation/no_interface/cFE_booter/osqueue.c index 33a9c38adf..6acdece0cf 100644 --- a/src/components/implementation/no_interface/cFE_booter/osqueue.c +++ b/src/components/implementation/no_interface/cFE_booter/osqueue.c @@ -13,28 +13,24 @@ struct sl_lock queue_lock = SL_LOCK_STATIC_INIT(); -// The main queue data structure. +/* The main queue data structure. */ struct queue { - // Whether or not the index of this queue is already taken. int32 used; - // The number of elements allowed in the queue. + /* The number of elements allowed in the queue */ uint32 depth; - // The size, in bytes, of each element in the queue. + /* The size, in bytes, of each element in the queue */ uint32 data_size; - // The name of the queue. For display purposes only. char name[OS_MAX_API_NAME]; uint32 head; uint32 tail; }; -// The global queue bank. struct queue queues[OS_MAX_QUEUES]; -// The bank of data that queues have access to. char queue_data[OS_MAX_QUEUES][MAX_QUEUE_DATA_SIZE]; int32 @@ -43,28 +39,26 @@ OS_QueueCreate(uint32 *queue_id, const char *queue_name, uint32 queue_depth, uin int32 i; uint32 qid; - // Check validity of parameters. if (queue_id == NULL || queue_name == NULL) { return OS_INVALID_POINTER; } - // Check name length. if (strlen(queue_name) >= OS_MAX_API_NAME) { return OS_ERR_NAME_TOO_LONG; } - // Check to see if the name is already taken. + /* Check to see if the name is already taken */ for (i = 0; i < OS_MAX_QUEUES; i++) { if ((queues[i].used == TRUE) && strcmp((char *)queue_name, queues[i].name) == 0) { return OS_ERR_NAME_TAKEN; } } - // Calculate the queue ID. + /* Find a free queue ID */ for (qid = 0; qid < OS_MAX_QUEUES; qid++) { if (queues[qid].used == FALSE) { break; } } - // Fail if there are too many queues. + /* Fail if there are too many queues */ if (qid >= OS_MAX_QUEUES || queues[qid].used == TRUE) { return OS_ERR_NO_FREE_IDS; } - // OS_ERROR may also be returned in the event that an OS call fails, but none are used here. + /* OS_ERROR may also be returned in the event that an OS call fails, but none are used here */ *queue_id = qid; queues[*queue_id].used = TRUE; @@ -79,10 +73,9 @@ int32 OS_QueueDelete(uint32 queue_id) { if (queue_id > OS_MAX_QUEUES) { return OS_ERR_INVALID_ID; } - // Check if there is a queue to be deleted at the ID. if (queues[queue_id].used == FALSE) { return OS_ERR_INVALID_ID; } - // Reset all values in the queue. + /* Reset all values in the queue */ queues[queue_id].used = FALSE; queues[queue_id].depth = 0; queues[queue_id].data_size = 0; @@ -90,8 +83,6 @@ OS_QueueDelete(uint32 queue_id) queues[queue_id].head = 0; queues[queue_id].tail = 0; - // OS_ERROR may also be returned in the event that an OS call fails, but none are used here. - return OS_SUCCESS; } @@ -100,20 +91,17 @@ OS_QueuePoll(uint32 queue_id, void *data, uint32 size, uint32 *size_copied) { uint32 i; - // Check if there are messages to be received. + /* Check if there are messages to be received */ if (queues[queue_id].head == queues[queue_id].tail) { return OS_QUEUE_EMPTY; } - // TODO: Implement logic for returning OS_QUEUE_TIMEOUT (waiting on mutex implementation). - if (size < queues[queue_id].data_size) { return OS_QUEUE_INVALID_SIZE; } - // A helper reference to the currently selected queue. struct queue *cur = &queues[queue_id]; - // Walk through the bytes at the head of the queue and write them to buffer `data`. + /* Walk through the bytes at the head of the queue and write them to buffer `data` */ for (i = 0; i < size; i++) { *((char *)data + i) = queue_data[queue_id][cur->head * cur->data_size + i]; } - // Advance the queue head, wrapping if it is passed `depth`. + /* Advance the queue head, wrapping if it is passed `depth` */ cur->head = (cur->head + 1) % cur->depth; return OS_SUCCESS; @@ -123,24 +111,23 @@ int32 OS_QueueGet(uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout) { uint32 i; + int32 intervals; + int32 current_interval; int result = OS_ERROR; sl_lock_take(&queue_lock); - // Check if the requested queue exists. if (queue_id > OS_MAX_QUEUES || queues[queue_id].used == FALSE) { result = OS_ERR_INVALID_ID; goto exit; } - // Check for a NULL pointer. if (data == NULL || size_copied == NULL) { result = OS_INVALID_POINTER; goto exit; } /* FIXME: Block instead of poll */ - int32 intervals; if (timeout == OS_CHECK) { result = OS_QueuePoll(queue_id, data, size, size_copied); goto exit; @@ -150,8 +137,7 @@ OS_QueueGet(uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 intervals = timeout / 50 + 1; } - int32 inter = 0; - for (inter = 0; inter < intervals; inter++) { + for (current_interval = 0; current_interval < intervals; current_interval++) { result = OS_QueuePoll(queue_id, data, size, size_copied); if (result == OS_SUCCESS) { goto exit; } sl_lock_release(&queue_lock); @@ -173,26 +159,24 @@ OS_QueueGet(uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 int32 OS_QueuePut(uint32 queue_id, const void *data, uint32 size, uint32 flags) { - if (queue_id > OS_MAX_QUEUES) { return OS_ERR_INVALID_ID; } + uint32 i; + struct queue *cur; - uint32 i; + if (queue_id > OS_MAX_QUEUES) { return OS_ERR_INVALID_ID; } - // Check if the requested queue exists. if (queues[queue_id].used == FALSE) { return OS_ERR_INVALID_ID; } - // Check for invalid pointers. if (data == NULL) { return OS_INVALID_POINTER; } - // Check if space remains in the queue. + /* Check if space remains in the queue */ if ((queues[queue_id].tail + 1) % queues[queue_id].depth == queues[queue_id].head) { return OS_QUEUE_FULL; } - // A helper pointer to the currently selected queue. - struct queue *cur = &queues[queue_id]; + cur = &queues[queue_id]; - // Walk through the bytes in `data` and write them to the tail of the specified queue. + /* Walk through the bytes in `data` and write them to the tail of the specified queue */ for (i = 0; i < size; i++) { queue_data[queue_id][cur->tail * cur->data_size + i] = *((char *)data + i); } - // Advance the queue tail, wrapping if it is past `depth`. + /* Advance the queue tail, wrapping if it is past `depth` */ cur->tail = (cur->tail + 1) % cur->depth; return OS_SUCCESS; @@ -231,7 +215,7 @@ OS_QueueGetInfo(uint32 queue_id, OS_queue_prop_t *queue_prop) if (queues[queue_id].used == FALSE) { return OS_ERR_INVALID_ID; } - // TODO: Identify creator; `0` is a dummy value. + /* TODO: Identify creator; `0` is a dummy value */ queue_prop->creator = 0; strcpy(queue_prop->name, queues[queue_id].name); diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index f79e62046e..f21850c152 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -21,18 +21,15 @@ timer_fn_1hz(void *d) while (1) { rdtscll(now); - if (now > first_deadline) { - CFE_TIME_Local1HzISR(); /* input param is signum. but CFE_PSP_TimerHandler doesn't seem to use - it. */ - } + if (now > first_deadline) { CFE_TIME_Local1HzISR(); } sl_thd_block_periodic(0); } } /* -** Internal Task helper functions -*/ + * Internal Task helper functions + */ /* We delegate the main thread of execution to a different thread * (the main thread needs to run the scheduling loop) @@ -52,23 +49,30 @@ struct cfe_task_info cfe_tasks[SL_MAX_NUM_THDS] = {{0}}; void OS_SchedulerStart(cos_thd_fn_t main_delegate) { + struct sl_thd * main_delegate_thread; + sched_param_t sp; + struct cfe_task_info *task_info; + struct sl_thd * timer_thd; + sched_param_t timer_window; + sched_param_t timer_priority; + sl_init(SL_MIN_PERIOD_US); - struct sl_thd * main_delegate_thread = sl_thd_alloc(main_delegate, NULL); - union sched_param_union sp = {.c = {.type = SCHEDP_PRIO, .value = MAIN_DELEGATE_THREAD_PRIORITY}}; - sl_thd_param_set(main_delegate_thread, sp.v); + main_delegate_thread = sl_thd_alloc(main_delegate, NULL); + sp = sched_param_pack(SCHEDP_PRIO, MAIN_DELEGATE_THREAD_PRIORITY); + sl_thd_param_set(main_delegate_thread, sp); main_delegate_thread_id = sl_thd_thdid(main_delegate_thread); - struct cfe_task_info *task_info = &cfe_tasks[main_delegate_thread_id]; + task_info = &cfe_tasks[main_delegate_thread_id]; strcpy(task_info->osal_task_prop.name, "MAIN_THREAD"); task_info->osal_task_prop.priority = MAIN_DELEGATE_THREAD_PRIORITY; task_info->osal_task_prop.OStask_id = (uint32)sl_thd_thdid(main_delegate_thread); - struct sl_thd * timer_thd = sl_thd_alloc(timer_fn_1hz, NULL); - union sched_param_union spperiod = {.c = {.type = SCHEDP_WINDOW, .value = HZ_PAUSE}}; - union sched_param_union spprio = {.c = {.type = SCHEDP_PRIO, .value = MAIN_DELEGATE_THREAD_PRIORITY + 1}}; - sl_thd_param_set(timer_thd, spperiod.v); - sl_thd_param_set(timer_thd, spprio.v); + timer_thd = sl_thd_alloc(timer_fn_1hz, NULL); + timer_window = sched_param_pack(SCHEDP_WINDOW, HZ_PAUSE); + timer_priority = sched_param_pack(SCHEDP_PRIO, MAIN_DELEGATE_THREAD_PRIORITY + 1); + sl_thd_param_set(timer_thd, timer_window); + sl_thd_param_set(timer_thd, timer_priority); sl_sched_loop(); } @@ -97,15 +101,17 @@ is_thread_name_taken(const char *name) } /* -** Task API -*/ + * Task API + */ -/* NOTE: Flags here aren't implemented, but I can't find an implementation that does */ +/* NOTE: We don't do flags, but I can't find an implementation that does */ int32 OS_TaskCreate(uint32 *task_id, const char *task_name, osal_task_entry function_pointer, uint32 *stack_pointer, uint32 stack_size, uint32 priority, uint32 flags) { - /* TODO: Verify that we don't need to take the cs here */ + struct sl_thd * thd; + sched_param_t sp; + struct cfe_task_info *task_info; if (task_id == NULL || task_name == NULL || function_pointer == NULL) { return OS_INVALID_POINTER; } @@ -115,12 +121,12 @@ OS_TaskCreate(uint32 *task_id, const char *task_name, osal_task_entry function_p if (priority > 255 || priority < 1) { return OS_ERR_INVALID_PRIORITY; } - struct sl_thd *thd = sl_thd_alloc(osal_task_entry_wrapper, function_pointer); + thd = sl_thd_alloc(osal_task_entry_wrapper, function_pointer); assert(thd); - union sched_param_union sp = {.c = {.type = SCHEDP_PRIO, .value = priority}}; - sl_thd_param_set(thd, sp.v); + sp = sched_param_pack(SCHEDP_PRIO, priority); + sl_thd_param_set(thd, sp); - struct cfe_task_info *task_info = &cfe_tasks[sl_thd_thdid(thd)]; + task_info = &cfe_tasks[sl_thd_thdid(thd)]; strcpy(task_info->osal_task_prop.name, task_name); task_info->osal_task_prop.creator = OS_TaskGetId(); task_info->osal_task_prop.stack_size = stack_size; @@ -136,12 +142,15 @@ OS_TaskCreate(uint32 *task_id, const char *task_name, osal_task_entry function_p int32 OS_TaskDelete(uint32 task_id) { - struct sl_thd *thd = sl_thd_lkup(task_id); + struct cfe_task_info *task_info; + struct sl_thd * thd = sl_thd_lkup(task_id); + osal_task_entry delete_handler; + if (!thd) { return OS_ERR_INVALID_ID; } - struct cfe_task_info *task_info = &cfe_tasks[task_id]; + task_info = &cfe_tasks[task_id]; - osal_task_entry delete_handler = task_info->delete_handler; + delete_handler = task_info->delete_handler; if (delete_handler) { delete_handler(); } sl_thd_free(thd); @@ -152,7 +161,7 @@ OS_TaskDelete(uint32 task_id) uint32 OS_TaskGetId(void) { - thdid_t real_id = sl_thdid(); + thdid_t real_id = sl_thdid(); /* Sometimes we need to disguise a thread as another thread... */ thdid_t possible_override = id_overrides[real_id]; if (possible_override) return possible_override; @@ -169,9 +178,11 @@ OS_TaskExit(void) int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer) { + struct cfe_task_info *task_info; + if (OS_TaskGetId() == main_delegate_thread_id) { return OS_ERR_INVALID_ID; } - struct cfe_task_info *task_info = &cfe_tasks[sl_thd_thdid(sl_thd_curr())]; + task_info = &cfe_tasks[sl_thd_thdid(sl_thd_curr())]; task_info->delete_handler = function_pointer; return OS_SUCCESS; @@ -188,13 +199,16 @@ OS_TaskDelay(uint32 millisecond) int32 OS_TaskSetPriority(uint32 task_id, uint32 new_priority) { + struct sl_thd *thd; + sched_param_t sp; + if (new_priority > 255 || new_priority < 1) { return OS_ERR_INVALID_PRIORITY; } - struct sl_thd *thd = sl_thd_lkup(task_id); + thd = sl_thd_lkup(task_id); if (!thd) { return OS_ERR_INVALID_ID; } - union sched_param_union sp = {.c = {.type = SCHEDP_PRIO, .value = new_priority}}; - sl_thd_param_set(thd, sp.v); + sp = sched_param_pack(SCHEDP_PRIO, new_priority); + sl_thd_param_set(thd, sp); return OS_SUCCESS; } @@ -211,9 +225,10 @@ OS_TaskRegister(void) int32 OS_TaskGetIdByName(uint32 *task_id, const char *task_name) { + thdid_t i; + if (!task_id || !task_name) return OS_INVALID_POINTER; - thdid_t i; for (i = 1; i < SL_MAX_NUM_THDS; i++) { struct sl_thd *thd = sl_thd_lkup(i); if (!thd || thd->state == SL_THD_FREE) continue; @@ -229,29 +244,31 @@ OS_TaskGetIdByName(uint32 *task_id, const char *task_name) int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) { + struct sl_thd *thd; + if (!task_prop) { return OS_INVALID_POINTER; } - struct sl_thd *thd = sl_thd_lkup(task_id); + thd = sl_thd_lkup(task_id); - // TODO: Fix this ugly workaround + /* TODO: Fix this ugly workaround */ if (!thd || thd->state == SL_THD_FREE) { return OS_ERR_INVALID_ID; } struct cfe_task_info *task_info = &cfe_tasks[task_id]; - *task_prop = task_info->osal_task_prop; + *task_prop = task_info->osal_task_prop; return OS_SUCCESS; } /* -** Main thread waiting API -*/ + * Main thread waiting API + */ /* -** OS-specific background thread implementation - waits forever for events to occur. -** -** This should be called from the BSP main routine / initial thread after all other -** board / application initialization has taken place and all other tasks are running. -*/ + * OS-specific background thread implementation - waits forever for events to occur. + * + * This should be called from the BSP main routine / initial thread after all other + * board / application initialization has taken place and all other tasks are running. + */ void OS_IdleLoop(void) { @@ -259,20 +276,20 @@ OS_IdleLoop(void) } /* -** OS_ApplicationShutdown() provides a means for a user-created thread to request the orderly -** shutdown of the whole system, such as part of a user-commanded reset command. -** This is preferred over e.g. ApplicationExit() which exits immediately and does not -** provide for any means to clean up first. -*/ + * OS_ApplicationShutdown() provides a means for a user-created thread to request the orderly + * shutdown of the whole system, such as part of a user-commanded reset command. + * This is preferred over e.g. ApplicationExit() which exits immediately and does not + * provide for any means to clean up first. + */ void OS_ApplicationShutdown(uint8 flag) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ } /* -** Mutex API -*/ + * Mutex API + */ struct mutex { int used; @@ -286,7 +303,8 @@ struct mutex mutexes[OS_MAX_MUTEXES]; int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) { - int32 result = OS_SUCCESS; + uint32 id; + int32 result = OS_SUCCESS; sl_lock_take(&mutex_data_lock); @@ -300,7 +318,6 @@ OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) goto exit; } - uint32 id; for (id = 0; id < OS_MAX_MUTEXES; id++) { if (mutexes[id].used && strcmp(sem_name, mutexes[id].prop.name) == 0) { result = OS_ERR_NAME_TAKEN; @@ -346,7 +363,6 @@ OS_MutSemGive(uint32 sem_id) int32 OS_MutSemTake(uint32 sem_id) { - sl_lock_take(&mutex_data_lock); if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { sl_lock_release(&mutex_data_lock); @@ -363,6 +379,7 @@ int32 OS_MutSemDelete(uint32 sem_id) { int32 result = OS_SUCCESS; + sl_lock_take(&mutex_data_lock); if (sem_id >= OS_MAX_MUTEXES || !mutexes[sem_id].used) { @@ -385,6 +402,7 @@ OS_MutSemDelete(uint32 sem_id) int32 OS_MutSemGetIdByName(uint32 *sem_id, const char *sem_name) { + int i; int32 result = OS_SUCCESS; sl_lock_take(&mutex_data_lock); @@ -399,7 +417,6 @@ OS_MutSemGetIdByName(uint32 *sem_id, const char *sem_name) goto exit; } - int i; for (i = 0; i < OS_MAX_MUTEXES; i++) { if (mutexes[i].used && (strcmp(mutexes[i].prop.name, (char *)sem_name) == 0)) { *sem_id = i; @@ -419,6 +436,7 @@ int32 OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) { int32 result = OS_SUCCESS; + sl_lock_take(&mutex_data_lock); if (!mut_prop) { @@ -439,30 +457,30 @@ OS_MutSemGetInfo(uint32 sem_id, OS_mut_sem_prop_t *mut_prop) } /* -** Semaphore API -*/ + * Semaphore API + */ struct semaphore { int used; - uint32 count; + uint32 count; thdid_t holder; uint32 creator; char name[OS_MAX_API_NAME]; }; -struct sl_lock semaphore_data_lock = SL_LOCK_STATIC_INIT(); +struct sl_lock semaphore_data_lock = SL_LOCK_STATIC_INIT(); struct semaphore binary_semaphores[OS_MAX_BIN_SEMAPHORES]; struct semaphore counting_semaphores[OS_MAX_COUNT_SEMAPHORES]; -// Generic semaphore methods int32 OS_SemaphoreCreate(struct semaphore *semaphores, uint32 max_semaphores, uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { - int32 result = OS_SUCCESS; + uint32 id; + int32 result = OS_SUCCESS; sl_lock_take(&semaphore_data_lock); @@ -476,7 +494,6 @@ OS_SemaphoreCreate(struct semaphore *semaphores, uint32 max_semaphores, uint32 * goto exit; } - uint32 id; for (id = 0; id < max_semaphores; id++) { if (semaphores[id].used && strcmp(sem_name, semaphores[id].name) == 0) { result = OS_ERR_NAME_TAKEN; @@ -508,7 +525,7 @@ OS_SemaphoreCreate(struct semaphore *semaphores, uint32 max_semaphores, uint32 * int32 OS_SemaphoreFlush(struct semaphore *semaphores, uint32 max_semaphores, uint32 sem_id) { - PANIC("Unimplemented method!"); + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } @@ -526,9 +543,7 @@ OS_SemaphoreGive(struct semaphore *semaphores, uint32 max_semaphores, uint32 sem } semaphores[sem_id].count += 1; - if (semaphores[sem_id].holder == sl_thdid()) { - semaphores[sem_id].holder = 0; - } + if (semaphores[sem_id].holder == sl_thdid()) { semaphores[sem_id].holder = 0; } exit: sl_lock_release(&semaphore_data_lock); @@ -567,9 +582,7 @@ OS_SemaphoreTake(struct semaphore *semaphores, uint32 max_semaphores, uint32 sem goto exit; } - if (semaphores[sem_id].holder == 0) { - semaphores[sem_id].holder = sl_thdid(); - } + if (semaphores[sem_id].holder == 0) { semaphores[sem_id].holder = sl_thdid(); } semaphores[sem_id].count -= 1; @@ -609,9 +622,7 @@ OS_SemaphoreTimedWait(struct semaphore *semaphores, uint32 max_semaphores, uint3 goto exit; } - if (semaphores[sem_id].holder == 0) { - semaphores[sem_id].holder = sl_thdid(); - } + if (semaphores[sem_id].holder == 0) { semaphores[sem_id].holder = sl_thdid(); } semaphores[sem_id].count -= 1; @@ -643,7 +654,8 @@ OS_SemaphoreDelete(struct semaphore *semaphores, uint32 max_semaphores, uint32 s int32 OS_SemaphoreGetIdByName(struct semaphore *semaphores, uint32 max_semaphores, uint32 *sem_id, const char *sem_name) { - int32 result = OS_SUCCESS; + uint32 i; + int32 result = OS_SUCCESS; sl_lock_take(&semaphore_data_lock); @@ -657,7 +669,6 @@ OS_SemaphoreGetIdByName(struct semaphore *semaphores, uint32 max_semaphores, uin goto exit; } - uint32 i; for (i = 0; i < max_semaphores; i++) { if (semaphores[i].used && (strcmp(semaphores[i].name, (char *)sem_name) == 0)) { *sem_id = i; @@ -666,7 +677,8 @@ OS_SemaphoreGetIdByName(struct semaphore *semaphores, uint32 max_semaphores, uin } /* The name was not found in the table, - * or it was, and the sem_id isn't valid anymore */ + * or it was, and the sem_id isn't valid anymore + */ result = OS_ERR_NAME_NOT_FOUND; exit: sl_lock_release(&semaphore_data_lock); @@ -674,7 +686,7 @@ OS_SemaphoreGetIdByName(struct semaphore *semaphores, uint32 max_semaphores, uin } -// Binary semaphore methods +/* Binary semaphore methods */ int32 OS_BinSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { diff --git a/src/components/implementation/no_interface/cFE_booter/ostimer.c b/src/components/implementation/no_interface/cFE_booter/ostimer.c index 372994cfb5..143e17df23 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostimer.c +++ b/src/components/implementation/no_interface/cFE_booter/ostimer.c @@ -10,11 +10,11 @@ int32 OS_TimerAPIInit(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } -// TODO: Verify this API really insn't necessary +/* TODO: Verify this API really insn't necessary */ int32 OS_TimeBaseCreate(uint32 *timer_id, const char *timebase_name, OS_TimerSync_t external_sync) { @@ -43,7 +43,7 @@ OS_TimeBaseGetIdByName(uint32 *timer_id, const char *timebase_name) int32 OS_TimerCreate(uint32 *timer_id, const char *timer_name, uint32 *clock_accuracy, OS_TimerCallback_t callback_ptr) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } @@ -51,21 +51,21 @@ int32 OS_TimerAdd(uint32 *timer_id, const char *timer_name, uint32 timebase_id, OS_ArgCallback_t callback_ptr, void *callback_arg) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_TimerSet(uint32 timer_id, uint32 start_time, uint32 interval_time) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_TimerDelete(uint32 timer_id) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } @@ -73,13 +73,13 @@ OS_TimerDelete(uint32 timer_id) int32 OS_TimerGetIdByName(uint32 *timer_id, const char *timer_name) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 OS_TimerGetInfo(uint32 timer_id, OS_timer_prop_t *timer_prop) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c index 7fc914194c..c3c74f348f 100644 --- a/src/components/implementation/no_interface/cFE_booter/psp.c +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -34,24 +34,23 @@ /* -** Function prototypes -*/ + * Function prototypes + */ /* -** PSP entry point and reset routines -*/ + * PSP entry point and reset routines + */ void CFE_PSP_Main(uint32 ModeId, char *StartupFilePath) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ } -/* -** CFE_PSP_Main is the entry point that the real time OS calls to start our -** software. This routine will do any BSP/OS specific setup, then call the -** entrypoint of the flight software ( i.e. the cFE main entry point ). -** The flight software (i.e. cFE ) should not call this routine. -*/ +/* CFE_PSP_Main is the entry point that the real time OS calls to start our + * software. This routine will do any BSP/OS specific setup, then call the + * entrypoint of the flight software ( i.e. the cFE main entry point ). + * The flight software (i.e. cFE ) should not call this routine. + */ void CFE_PSP_GetTime(OS_time_t *LocalTime) @@ -60,38 +59,38 @@ CFE_PSP_GetTime(OS_time_t *LocalTime) } /* This call gets the local time from the hardware on the Vxworks system * on the mcp750s - * on the other os/hardware setup, it will get the time the normal way */ + * on the other os/hardware setup, it will get the time the normal way + */ void CFE_PSP_Restart(uint32 resetType) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ } -/* -** CFE_PSP_Restart is the entry point back to the BSP to restart the processor. -** The flight software calls this routine to restart the processor. -*/ +/* CFE_PSP_Restart is the entry point back to the BSP to restart the processor. + * The flight software calls this routine to restart the processor. + */ uint32 CFE_PSP_GetRestartType(uint32 *restartSubType) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } /* -** CFE_PSP_GetRestartType returns the last reset type and if a pointer to a valid -** memory space is passed in, it returns the reset sub-type in that memory. -** Right now the reset types are application specific. For the cFE they -** are defined in the cfe_es.h file. -*/ + * CFE_PSP_GetRestartType returns the last reset type and if a pointer to a valid + * memory space is passed in, it returns the reset sub-type in that memory. + * Right now the reset types are application specific. For the cFE they + * are defined in the cfe_es.h file. + */ void CFE_PSP_FlushCaches(uint32 type, cpuaddr address, uint32 size); /* -** This is a BSP specific cache flush routine -*/ + * This is a BSP specific cache flush routine + */ uint32 CFE_PSP_GetProcessorId(void) @@ -99,9 +98,9 @@ CFE_PSP_GetProcessorId(void) return CFE_PSP_CpuId; } /* -** CFE_PSP_GetProcessorId returns the CPU ID as defined by the specific board -** and BSP. -*/ + * CFE_PSP_GetProcessorId returns the CPU ID as defined by the specific board + * and BSP. + */ uint32 @@ -110,84 +109,83 @@ CFE_PSP_GetSpacecraftId(void) return CFE_PSP_SpacecraftId; } /* -** CFE_PSP_GetSpacecraftId retuns the Spacecraft ID (if any ) -*/ + * CFE_PSP_GetSpacecraftId retuns the Spacecraft ID (if any ) + */ uint32 CFE_PSP_Get_Timer_Tick(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } /* -** CFE_PSP_Get_Timer_Tick returns the underlying OS timer tick value -** It is used for the performance monitoring software -*/ + * CFE_PSP_Get_Timer_Tick returns the underlying OS timer tick value + * It is used for the performance monitoring software + */ uint32 CFE_PSP_GetTimerTicksPerSecond(void) { - // (usec / sec) / (usec / tick) + /* (usec / sec) / (usec / tick) */ return 1000000 / SL_MIN_PERIOD_US; } /* -** CFE_PSP_GetTimerTicksPerSecond provides the resolution of the least significant -** 32 bits of the 64 bit time stamp returned by CFE_PSP_Get_Timebase in timer -** ticks per second. The timer resolution for accuracy should not be any slower -** than 1000000 ticks per second or 1 us per tick -*/ + * CFE_PSP_GetTimerTicksPerSecond provides the resolution of the least significant + * 32 bits of the 64 bit time stamp returned by CFE_PSP_Get_Timebase in timer + * ticks per second. The timer resolution for accuracy should not be any slower + * than 1000000 ticks per second or 1 us per tick + */ uint32 CFE_PSP_GetTimerLow32Rollover(void) { - // This is a pessimistic assumption - // TODO: Figure out if we can be more optimistic + /* This is a pessimistic assumption + * TODO: Figure out if we can be more optimistic + */ return 1000000; } -/* -** CFE_PSP_GetTimerLow32Rollover provides the number that the least significant -** 32 bits of the 64 bit time stamp returned by CFE_PSP_Get_Timebase rolls over. -** If the lower 32 bits rolls at 1 second, then the CFE_PSP_TIMER_LOW32_ROLLOVER -** will be 1000000. if the lower 32 bits rolls at its maximum value (2^32) then -** CFE_PSP_TIMER_LOW32_ROLLOVER will be 0. -*/ +/* CFE_PSP_GetTimerLow32Rollover provides the number that the least significant + * 32 bits of the 64 bit time stamp returned by CFE_PSP_Get_Timebase rolls over. + * If the lower 32 bits rolls at 1 second, then the CFE_PSP_TIMER_LOW32_ROLLOVER + * will be 1000000. if the lower 32 bits rolls at its maximum value (2^32) then + * CFE_PSP_TIMER_LOW32_ROLLOVER will be 0. + */ void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32 *Tbl) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ } -/* -** CFE_PSP_Get_Timebase -*/ + uint32 CFE_PSP_Get_Dec(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } /* -** CFE_PSP_Get_Dec -*/ + * CFE_PSP_Get_Dec + */ int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType) { - // Since all operations on reserved memory are unimplemented, it's safe to - // do nothing here + /* Since all operations on reserved memory are unimplemented, it's safe to + * do nothing here + */ return 0; } /* -** CFE_PSP_InitProcessorReservedMemory initializes all of the memory in the -** BSP that is preserved on a processor reset. The memory includes the -** Critical Data Store, the ES Reset Area, the Volatile Disk Memory, and -** the User Reserved Memory. In general, the memory areas will be initialized -** ( cleared ) on a Power On reset, and preserved during a processor reset. -*/ + * CFE_PSP_InitProcessorReservedMemory initializes all of the memory in the + * BSP that is preserved on a processor reset. The memory includes the + * Critical Data Store, the ES Reset Area, the Volatile Disk Memory, and + * the User Reserved Memory. In general, the memory areas will be initialized + * ( cleared ) on a Power On reset, and preserved during a processor reset. + */ char CDS_MEMORY[CFE_ES_CDS_SIZE]; @@ -199,8 +197,8 @@ CFE_PSP_GetCDSSize(uint32 *SizeOfCDS) return CFE_PSP_SUCCESS; } /* -** CFE_PSP_GetCDSSize fetches the size of the OS Critical Data Store area. -*/ + * CFE_PSP_GetCDSSize fetches the size of the OS Critical Data Store area. + */ int32 CFE_PSP_WriteToCDS(void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumBytes) @@ -212,8 +210,8 @@ CFE_PSP_WriteToCDS(void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumBytes) return CFE_PSP_SUCCESS; } /* -** CFE_PSP_WriteToCDS writes to the CDS Block. -*/ + * CFE_PSP_WriteToCDS writes to the CDS Block. + */ int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumBytes) @@ -225,10 +223,10 @@ CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumBytes) return CFE_PSP_SUCCESS; } /* -** CFE_PSP_ReadFromCDS reads from the CDS Block -*/ + * CFE_PSP_ReadFromCDS reads from the CDS Block + */ -// TODO: Make this dynamic based on constants +/* TODO: Make this dynamic based on constants */ char RESET_AREA[CFE_PSP_CDS_SIZE]; int32 @@ -240,21 +238,21 @@ CFE_PSP_GetResetArea(cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) return CFE_PSP_SUCCESS; } /* -** CFE_PSP_GetResetArea returns the location and size of the ES Reset information area. -** This area is preserved during a processor reset and is used to store the -** ER Log, System Log and reset related variables -*/ + * CFE_PSP_GetResetArea returns the location and size of the ES Reset information area. + * This area is preserved during a processor reset and is used to store the + * ER Log, System Log and reset related variables + */ int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } /* -** CFE_PSP_GetUserReservedArea returns the location and size of the memory used for the cFE -** User reserved area. -*/ + * CFE_PSP_GetUserReservedArea returns the location and size of the memory used for the cFE + * User reserved area. + */ int32 @@ -266,85 +264,85 @@ CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk) return CFE_PSP_SUCCESS; } /* -** CFE_PSP_GetVolatileDiskMem returns the location and size of the memory used for the cFE -** volatile disk. -*/ + * CFE_PSP_GetVolatileDiskMem returns the location and size of the memory used for the cFE + * volatile disk. + */ int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *SizeOfKernelSegment) { - // TODO: Verify this is ok to remain unimplemented + /* TODO: Verify this is ok to remain unimplemented */ return CFE_PSP_ERROR_NOT_IMPLEMENTED; } /* -** CFE_PSP_GetKernelTextSegmentInfo returns the location and size of the kernel memory. -*/ + * CFE_PSP_GetKernelTextSegmentInfo returns the location and size of the kernel memory. + */ int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFESegment) { - // TODO: Verify this is ok to remain unimplemented + /* TODO: Verify this is ok to remain unimplemented */ return CFE_PSP_ERROR_NOT_IMPLEMENTED; } /* -** CFE_PSP_GetCFETextSegmentInfo returns the location and size of the kernel memory. -*/ + * CFE_PSP_GetCFETextSegmentInfo returns the location and size of the kernel memory. + */ void CFE_PSP_WatchdogInit(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ } /* -** CFE_PSP_WatchdogInit configures the watchdog timer. -*/ + * CFE_PSP_WatchdogInit configures the watchdog timer. + */ void CFE_PSP_WatchdogEnable(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ } /* -** CFE_PSP_WatchdogEnable enables the watchdog timer. -*/ + * CFE_PSP_WatchdogEnable enables the watchdog timer. + */ void CFE_PSP_WatchdogDisable(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ } /* -** CFE_PSP_WatchdogDisable disables the watchdog timer. -*/ + * CFE_PSP_WatchdogDisable disables the watchdog timer. + */ void CFE_PSP_WatchdogService(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ } /* -** CFE_PSP_WatchdogService services the watchdog timer according to the -** value set in WatchDogSet. -*/ + * CFE_PSP_WatchdogService services the watchdog timer according to the + * value set in WatchDogSet. + */ uint32 CFE_PSP_WatchdogGet(void) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } /* -** CFE_PSP_WatchdogGet gets the watchdog time in milliseconds -*/ + * CFE_PSP_WatchdogGet gets the watchdog time in milliseconds + */ void CFE_PSP_WatchdogSet(uint32 WatchdogValue) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ } /* -** CFE_PSP_WatchdogSet sets the watchdog time in milliseconds -*/ + * CFE_PSP_WatchdogSet sets the watchdog time in milliseconds + */ void CFE_PSP_Panic(int32 ErrorCode) @@ -353,54 +351,55 @@ CFE_PSP_Panic(int32 ErrorCode) PANIC("PANICKING!"); } /* -** CFE_PSP_Panic is called by the cFE Core startup code when it needs to abort the -** cFE startup. This should not be called by applications. -*/ + * CFE_PSP_Panic is called by the cFE Core startup code when it needs to abort the + * cFE startup. This should not be called by applications. + */ int32 CFE_PSP_InitSSR(uint32 bus, uint32 device, char *DeviceName) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } /* -** CFE_PSP_InitSSR will initialize the Solid state recorder memory for a particular platform -*/ + * CFE_PSP_InitSSR will initialize the Solid state recorder memory for a particular platform + */ int32 CFE_PSP_Decompress(char *srcFileName, char *dstFileName) { - PANIC("Unimplemented method!"); // TODO: Implement me! + PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } /* -** CFE_PSP_Decompress will uncompress the source file to the file specified in the -** destination file name. The Decompress uses the "gzip" algorithm. Files can -** be compressed using the "gzip" program available on almost all host platforms. -*/ + * CFE_PSP_Decompress will uncompress the source file to the file specified in the + * destination file name. The Decompress uses the "gzip" algorithm. Files can + * be compressed using the "gzip" program available on almost all host platforms. + */ void CFE_PSP_AttachExceptions(void) { - // For now it is safe for this to do nothing - // TODO: Actually implement exception handling + /* For now it is safe for this to do nothing + * TODO: Actually implement exception handling + */ } /* -** CFE_PSP_AttachExceptions will setup the exception environment for the chosen platform -** On a board, this can be configured to look at a debug flag or switch in order to -** keep the standard OS exeption handlers, rather than restarting the system -*/ + * CFE_PSP_AttachExceptions will setup the exception environment for the chosen platform + * On a board, this can be configured to look at a debug flag or switch in order to + * keep the standard OS exeption handlers, rather than restarting the system + */ void CFE_PSP_SetDefaultExceptionEnvironment(void) { - // TODO: Figure out if it is safe for us to just do nothing here + /* TODO: Figure out if it is safe for us to just do nothing here */ } /* -** -** CFE_PSP_SetDefaultExceptionEnvironment defines the CPU and FPU exceptions that are enabled for each cFE Task/App -** -** Notes: The exception environment is local to each task Therefore this must be -** called for each task that that wants to do floating point and catch exceptions -*/ + * + * CFE_PSP_SetDefaultExceptionEnvironment defines the CPU and FPU exceptions that are enabled for each cFE Task/App + * + * Notes: The exception environment is local to each task Therefore this must be + * called for each task that that wants to do floating point and catch exceptions + */ diff --git a/src/components/implementation/no_interface/cFE_booter/tar.c b/src/components/implementation/no_interface/cFE_booter/tar.c index 37a81d9afd..715b83939c 100644 --- a/src/components/implementation/no_interface/cFE_booter/tar.c +++ b/src/components/implementation/no_interface/cFE_booter/tar.c @@ -3,12 +3,12 @@ #include #include -// should be overwritten by linking step in build process +/* should be overwritten by linking step in build process */ __attribute__((weak)) char _binary_cFE_fs_tar_size = 0; __attribute__((weak)) char _binary_cFE_fs_tar_start = 0; __attribute__((weak)) char _binary_cFE_fs_tar_end = 0; -// locations and size of tar +/* locations and size of tar */ char * tar_start; char * tar_end; size_t tar_size; @@ -20,7 +20,7 @@ round_to_blocksize(uint32 offset) return offset; } -// used to convert filesize in oct char string to dec, adapted from old fs code by gparmer +/* used to convert filesize in oct char string to dec, adapted from old fs code by gparmer */ static uint32 oct_to_dec(char *oct) { @@ -48,11 +48,11 @@ oct_to_dec(char *oct) uint32 tar_load() { - // First make sure that symbols have been overwritten by linking process + /* First make sure that symbols have been overwritten by linking process */ if (!_binary_cFE_fs_tar_start) return OS_FS_ERR_DRIVE_NOT_CREATED; - // Next check that file size is greater than 0 + /* Next check that file size is greater than 0 */ if (&_binary_cFE_fs_tar_size == 0) return OS_FS_ERR_DRIVE_NOT_CREATED; - // Check that the end of the tar is after the start + /* Check that the end of the tar is after the start */ if (&_binary_cFE_fs_tar_end < &_binary_cFE_fs_tar_start) return OS_FS_ERR_DRIVE_NOT_CREATED; tar_size = (size_t)&_binary_cFE_fs_tar_size; @@ -72,17 +72,18 @@ tar_load() uint32 tar_parse() { + uint32 offset = 0; + struct fsobj *o; + assert(tar_start && tar_end); assert(tar_size < INT32_MAX); assert(tar_end - tar_start > 0); assert(tar_size == (size_t)(tar_end - tar_start)); - uint32 offset = 0; - struct fsobj *o; while (offset + tar_start < tar_end) { if (file_get_new(&o)) return OS_FS_ERR_DRIVE_NOT_CREATED; - // tar ends after two empty records + /* tar ends after two empty records */ if (!(offset + tar_start)[0] && !(offset + tar_start)[TAR_BLOCKSIZE]) { o->ino = 0; return OS_FS_SUCCESS; @@ -97,7 +98,7 @@ tar_parse() */ offset += round_to_blocksize(o->size + 500); } - // tar ends before two empty records are found + /* tar ends before two empty records are found */ return OS_FS_ERROR; } @@ -107,14 +108,16 @@ tar_parse() uint32 tar_hdr_read(uint32 tar_offset, struct fsobj *file) { + char * location; + struct f_part *part; + assert(tar_offset < tar_size); assert(file->ino > 0); - struct f_part *part; part_get_new(&part); file->memtype = STATIC; - char *location = tar_start; + location = tar_start; location += tar_offset; memmove(location + 1, location, strlen(location)); location[0] = '/'; diff --git a/src/components/implementation/no_interface/cFE_booter/tar.h b/src/components/implementation/no_interface/cFE_booter/tar.h index 57b62a6d4b..271fde66fc 100644 --- a/src/components/implementation/no_interface/cFE_booter/tar.h +++ b/src/components/implementation/no_interface/cFE_booter/tar.h @@ -1,7 +1,7 @@ #define TAR_BLOCKSIZE 512 -#define INT32_MAX 0x7FFFFFF // 2^31 - 1 +#define INT32_MAX 0x7FFFFFF /* 2^31 - 1 */ -// from GNU +/*from GNU */ struct posix_header { /* byte offset */ char name[100]; /* 0 */ char mode[8]; /* 100 */ diff --git a/src/components/interface/cFE/cFE_emu.h b/src/components/interface/cFE/cFE_emu.h index 8877106b2a..1cb2fc8151 100644 --- a/src/components/interface/cFE/cFE_emu.h +++ b/src/components/interface/cFE/cFE_emu.h @@ -203,6 +203,7 @@ union shared_region { int emu_request_memory(spdid_t client); void emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_aepkey_t key); +int emu_is_printf_enabled(); int32 emu_CFE_ES_CalculateCRC(spdid_t client); int32 emu_CFE_ES_CopyToCDS(spdid_t client); diff --git a/src/components/interface/cFE/stubs/c_stub.c b/src/components/interface/cFE/stubs/c_stub.c index 0f87bcf41b..9102c2e62e 100644 --- a/src/components/interface/cFE/stubs/c_stub.c +++ b/src/components/interface/cFE/stubs/c_stub.c @@ -21,9 +21,12 @@ union shared_region *shared_region; spdid_t spdid; cos_aepkey_t time_sync_key; -// NOTE: This is tagged as currently unused in the docs -CFE_SB_Qos_t CFE_SB_Default_Qos = { 0 }; -size_t CDS_sizes[CFE_ES_CDS_MAX_NUM_ENTRIES]; +/* We could copy this from the cFE, but it's zero intialized there + * Also it's totally unused (according to cFE documentation) + */ +CFE_SB_Qos_t CFE_SB_Default_Qos = { 0 }; + +size_t CDS_sizes[CFE_ES_CDS_MAX_NUM_ENTRIES] = { 0 }; int sync_callbacks_are_setup = 0; CFE_TIME_SynchCallbackPtr_t sync_callbacks[CFE_TIME_MAX_NUM_SYNCH_FUNCS]; @@ -31,11 +34,11 @@ CFE_TIME_SynchCallbackPtr_t sync_callbacks[CFE_TIME_MAX_NUM_SYNCH_FUNCS]; void do_emulation_setup(spdid_t id) { - spdid = id; - + vaddr_t client_addr; int region_id = emu_request_memory(id); - vaddr_t client_addr = 0; + spdid = id; + memmgr_shared_page_map(region_id, &client_addr); assert(client_addr); shared_region = (void *)client_addr; @@ -46,8 +49,10 @@ do_emulation_setup(spdid_t id) void handle_sync_callbacks(arcvcap_t rcv, void *data) { + int pending; + while (1) { - int pending = cos_rcv(rcv, 0, NULL); + pending = cos_rcv(rcv, 0, NULL); if (pending) { int i; for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) { @@ -64,18 +69,20 @@ ensure_sync_callbacks_are_setup() { if (!sync_callbacks_are_setup) { + int32 result; thdclosure_index_t idx = cos_thd_init_alloc(handle_sync_callbacks, NULL); emu_create_aep_thread(spdid, idx, time_sync_key); - int32 result = emu_CFE_TIME_RegisterSynchCallback(time_sync_key); + result = emu_CFE_TIME_RegisterSynchCallback(time_sync_key); assert(result == CFE_SUCCESS); sync_callbacks_are_setup = 1; } } -// FIXME: Be more careful about user supplied pointers -// FIXME: Take a lock in each function, so shared memory can't be corrupted +/* FIXME: Be more careful about user supplied pointers + * FIXME: Take a lock in each function, so shared memory can't be corrupted + */ uint32 CFE_ES_CalculateCRC(const void *DataPtr, uint32 DataLength, uint32 InputCRC, uint32 TypeCRC) { @@ -89,53 +96,66 @@ CFE_ES_CalculateCRC(const void *DataPtr, uint32 DataLength, uint32 InputCRC, uin int32 CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t CDSHandle, void * DataToCopy) { + size_t data_size; + /* CDSHandle is unsigned, so it can't be invalid by being negative */ assert(CDSHandle < CFE_ES_CDS_MAX_NUM_ENTRIES); shared_region->cfe_es_copyToCDS.CDSHandle = CDSHandle; - size_t data_size = CDS_sizes[CDSHandle]; + data_size = CDS_sizes[CDSHandle]; assert(data_size <= EMU_BUF_SIZE); memcpy(shared_region->cfe_es_copyToCDS.DataToCopy, DataToCopy, data_size); - return emu_CFE_ES_CopyToCDS(spdid); } int32 CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName) { + int32 result; + assert(strlen(AppName) < EMU_BUF_SIZE); strcpy(shared_region->cfe_es_getAppIDByName.AppName, AppName); - int32 result = emu_CFE_ES_GetAppIDByName(spdid); + result = emu_CFE_ES_GetAppIDByName(spdid); *AppIdPtr = shared_region->cfe_es_getAppIDByName.AppId; + return result; } int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, uint32 AppId) { + int32 result; + shared_region->cfe_es_getAppInfo.AppId = AppId; - int32 result = emu_CFE_ES_GetAppInfo(spdid); + result = emu_CFE_ES_GetAppInfo(spdid); *AppInfo = shared_region->cfe_es_getAppInfo.AppInfo; + return result; } int32 CFE_ES_GetGenCount(uint32 CounterId, uint32 *Count) { + int32 result; + shared_region->cfe_es_getGenCount.CounterId = CounterId; - int32 result = emu_CFE_ES_GetGenCount(spdid); + result = emu_CFE_ES_GetGenCount(spdid); *Count = shared_region->cfe_es_getGenCount.Count; + return result; } int32 CFE_ES_GetGenCounterIDByName(uint32 *CounterIdPtr, const char *CounterName) { + int32 result; + strcpy(shared_region->cfe_es_getGenCounterIDByName.CounterName, CounterName); - int32 result = emu_CFE_ES_GetGenCounterIDByName(spdid); + result = emu_CFE_ES_GetGenCounterIDByName(spdid); *CounterIdPtr = shared_region->cfe_es_getGenCounterIDByName.CounterId; + return result; } @@ -143,6 +163,7 @@ int32 CFE_ES_GetResetType(uint32 *ResetSubtypePtr) { int32 result = emu_CFE_ES_GetResetType(spdid); + *ResetSubtypePtr = shared_region->cfe_es_getResetType.ResetSubtype; return result; } @@ -150,8 +171,10 @@ CFE_ES_GetResetType(uint32 *ResetSubtypePtr) int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, uint32 TaskId) { + int32 result; + shared_region->cfe_es_getTaskInfo.TaskId = TaskId; - int32 result = emu_CFE_ES_GetTaskInfo(spdid); + result = emu_CFE_ES_GetTaskInfo(spdid); *TaskInfo = shared_region->cfe_es_getTaskInfo.TaskInfo; return result; } @@ -159,12 +182,14 @@ CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, uint32 TaskId) int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, int32 BlockSize, const char *Name) { + int32 result; + assert(strlen(Name) < EMU_BUF_SIZE); shared_region->cfe_es_registerCDS.BlockSize = BlockSize; strcpy(shared_region->cfe_es_registerCDS.Name, Name); - int32 result = emu_CFE_ES_RegisterCDS(spdid); + result = emu_CFE_ES_RegisterCDS(spdid); if (result == CFE_SUCCESS) { CFE_ES_CDSHandle_t handle = shared_region->cfe_es_registerCDS.CDS_Handle; CDS_sizes[handle] = BlockSize; @@ -176,14 +201,17 @@ CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, int32 BlockSize, const char *N int32 CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t CDSHandle) { + int32 result; + size_t data_size; + shared_region->cfe_es_restoreFromCDS.CDSHandle = CDSHandle; - int32 result = emu_CFE_ES_RestoreFromCDS(spdid); + result = emu_CFE_ES_RestoreFromCDS(spdid); if (result == CFE_SUCCESS) { /* CDSHandle is unsigned, so it can't be invalid by being negative */ assert(CDSHandle < CFE_ES_CDS_MAX_NUM_ENTRIES); - size_t data_size = CDS_sizes[CDSHandle]; + data_size = CDS_sizes[CDSHandle]; assert(data_size <= EMU_BUF_SIZE); memcpy(RestoreToMemory, shared_region->cfe_es_restoreFromCDS.RestoreToMemory, data_size); @@ -195,8 +223,10 @@ CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t CDSHandle) int32 CFE_ES_RunLoop(uint32 *RunStatus) { + int32 result; + shared_region->cfe_es_runLoop.RunStatus = *RunStatus; - int32 result = emu_CFE_ES_RunLoop(spdid); + result = emu_CFE_ES_RunLoop(spdid); *RunStatus = shared_region->cfe_es_runLoop.RunStatus; return result; } @@ -217,12 +247,19 @@ int32 CFE_EVS_Register(void * Filters, /* Pointer to an array of filte uint16 NumFilteredEvents, /* How many elements in the array? */ uint16 FilterScheme) /* Filtering Algorithm to be implemented */ { - if (FilterScheme != CFE_EVS_BINARY_FILTER) { return CFE_EVS_UNKNOWN_FILTER; } - CFE_EVS_BinFilter_t *bin_filters = Filters; int i; - for (i = 0; i < NumFilteredEvents; i++) { shared_region->cfe_evs_register.filters[i] = bin_filters[i]; } + CFE_EVS_BinFilter_t *bin_filters; + + if (FilterScheme != CFE_EVS_BINARY_FILTER) { return CFE_EVS_UNKNOWN_FILTER; } + bin_filters = Filters; + + for (i = 0; i < NumFilteredEvents; i++) { + shared_region->cfe_evs_register.filters[i] = bin_filters[i]; + } + shared_region->cfe_evs_register.NumEventFilters = NumFilteredEvents; shared_region->cfe_evs_register.FilterScheme = FilterScheme; + return emu_CFE_EVS_Register(spdid); } @@ -255,8 +292,9 @@ CFE_FS_Decompress(const char *SourceFile, const char *DestinationFile) int32 CFE_FS_WriteHeader(int32 FileDes, CFE_FS_Header_t *Hdr) { + int32 result; shared_region->cfe_fs_writeHeader.FileDes = FileDes; - int32 result = emu_CFE_FS_WriteHeader(spdid); + result = emu_CFE_FS_WriteHeader(spdid); *Hdr = shared_region->cfe_fs_writeHeader.Hdr; return result; } @@ -277,19 +315,23 @@ int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n) int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *PipeName) { + int32 result; + shared_region->cfe_sb_createPipe.Depth = Depth; strncpy(shared_region->cfe_sb_createPipe.PipeName, PipeName, OS_MAX_API_NAME); - int32 ret = emu_CFE_SB_CreatePipe(spdid); + result = emu_CFE_SB_CreatePipe(spdid); *PipeIdPtr = shared_region->cfe_sb_createPipe.PipeId; - return ret; + return result; } uint16 CFE_SB_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr) { + char *msg_ptr; uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); - char *msg_ptr = (char *)MsgPtr; + msg_ptr = (char *)MsgPtr; memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); return emu_CFE_SB_GetCmdCode(spdid); } @@ -297,9 +339,11 @@ CFE_SB_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr) CFE_SB_MsgId_t CFE_SB_GetMsgId(CFE_SB_MsgPtr_t MsgPtr) { + char *msg_ptr; uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); - char *msg_ptr = (char *)MsgPtr; + msg_ptr = (char *)MsgPtr; memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); return emu_CFE_SB_GetMsgId(spdid); } @@ -308,9 +352,11 @@ CFE_SB_GetMsgId(CFE_SB_MsgPtr_t MsgPtr) CFE_TIME_SysTime_t CFE_SB_GetMsgTime(CFE_SB_MsgPtr_t MsgPtr) { + char *msg_ptr; uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); - char *msg_ptr = (char *)MsgPtr; + msg_ptr = (char *)MsgPtr; memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); emu_CFE_SB_GetMsgTime(spdid); return shared_region->time; @@ -350,26 +396,33 @@ struct { int32 CFE_SB_RcvMsg(CFE_SB_MsgPtr_t *BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut) { + int32 result; + shared_region->cfe_sb_rcvMsg.PipeId = PipeId; shared_region->cfe_sb_rcvMsg.TimeOut = TimeOut; - int32 result = emu_CFE_SB_RcvMsg(spdid); + result = emu_CFE_SB_RcvMsg(spdid); + if (result == CFE_SUCCESS) { memcpy(pipe_buffers[PipeId].buf, shared_region->cfe_sb_rcvMsg.Msg, EMU_BUF_SIZE); *BufPtr = (CFE_SB_MsgPtr_t)pipe_buffers[PipeId].buf; } + return result; } int32 CFE_SB_SetCmdCode(CFE_SB_MsgPtr_t MsgPtr, uint16 CmdCode) { + int32 result; + char *msg_ptr; uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); - char *msg_ptr = (char *)MsgPtr; + msg_ptr = (char *)MsgPtr; memcpy(shared_region->cfe_sb_setCmdCode.Msg, msg_ptr, (size_t)msg_len); shared_region->cfe_sb_setCmdCode.CmdCode = CmdCode; - int32 result = emu_CFE_SB_SetCmdCode(spdid); + result = emu_CFE_SB_SetCmdCode(spdid); /* TODO: Verify we can assume the msg_len won't change */ memcpy(msg_ptr, shared_region->cfe_sb_setCmdCode.Msg, msg_len); return result; @@ -378,10 +431,13 @@ int32 CFE_SB_SetCmdCode(CFE_SB_MsgPtr_t MsgPtr, uint16 CmdCode) int32 CFE_SB_SendMsg(CFE_SB_Msg_t *MsgPtr) { + char *msg_ptr; uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); - char *msg_ptr = (char *)MsgPtr; + msg_ptr = (char *)MsgPtr; memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); + return emu_CFE_SB_SendMsg(spdid); } @@ -398,9 +454,11 @@ CFE_SB_SubscribeEx(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, CFE_SB_Qos_t Qu void CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr) { + char *msg_ptr; uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); - char *msg_ptr = (char *)MsgPtr; + msg_ptr = (char *)MsgPtr; memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); emu_CFE_SB_TimeStampMsg(spdid); memcpy(msg_ptr, shared_region->cfe_sb_msg.Msg, (size_t)msg_len); @@ -409,10 +467,13 @@ CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr) boolean CFE_SB_ValidateChecksum (CFE_SB_MsgPtr_t MsgPtr) { + char *msg_ptr; uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); + assert(msg_len <= EMU_BUF_SIZE); - char *msg_ptr = (char *)MsgPtr; + msg_ptr = (char *)MsgPtr; memcpy(shared_region->cfe_sb_msg.Msg, msg_ptr, (size_t)msg_len); + return emu_CFE_SB_ValidateChecksum(spdid); } @@ -452,9 +513,9 @@ CFE_TIME_Print(char *PrintBuffer, CFE_TIME_SysTime_t TimeToPrint) int32 CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr) { + int i; ensure_sync_callbacks_are_setup(); - int i; for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) { if (!sync_callbacks[i]) { @@ -502,8 +563,10 @@ OS_creat(const char *path, int32 access) int32 OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) { + int32 result; + shared_region->os_FDGetInfo.filedes = filedes; - int32 result = emu_OS_FDGetInfo(spdid); + result = emu_OS_FDGetInfo(spdid); *fd_prop = shared_region->os_FDGetInfo.fd_prop; return result; } @@ -511,10 +574,12 @@ OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) int32 OS_fsBytesFree(const char *name, uint64 *bytes_free) { + int32 result; + assert(strlen(name) < EMU_BUF_SIZE); strcpy(shared_region->os_fsBytesFree.name, name); - int32 result = emu_OS_fsBytesFree(spdid); + result = emu_OS_fsBytesFree(spdid); *bytes_free = shared_region->os_fsBytesFree.bytes_free; return result; @@ -565,11 +630,13 @@ OS_opendir(const char *path) int32 OS_read(int32 filedes, void *buffer, uint32 nbytes) { + int32 result; + assert(nbytes <= EMU_BUF_SIZE); shared_region->os_read.filedes = filedes; shared_region->os_read.nbytes = nbytes; - int32 result = emu_OS_read(spdid); + result = emu_OS_read(spdid); memcpy(buffer, shared_region->os_read.buffer, nbytes); return result; } @@ -618,10 +685,12 @@ OS_rmdir(const char *path) int32 OS_stat(const char *path, os_fstat_t *filestats) { + int32 result; + assert(strlen(path) < EMU_BUF_SIZE); strcpy(shared_region->os_stat.path, path); - int32 result = emu_OS_stat(spdid); + result = emu_OS_stat(spdid); *filestats = shared_region->os_stat.filestats; return result; } @@ -639,12 +708,14 @@ OS_write(int32 filedes, void *buffer, uint32 nbytes) int32 OS_BinSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { + int32 result; + assert(strlen(sem_name) < EMU_BUF_SIZE); strcpy(shared_region->os_semCreate.sem_name, sem_name); shared_region->os_semCreate.sem_initial_value = sem_initial_value; shared_region->os_semCreate.options = options; - int32 result = emu_OS_BinSemCreate(spdid); + result = emu_OS_BinSemCreate(spdid); *sem_id = shared_region->os_semCreate.sem_id; return result; } @@ -652,12 +723,14 @@ OS_BinSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, int32 OS_CountSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options) { + int32 result; + assert(strlen(sem_name) < EMU_BUF_SIZE); strcpy(shared_region->os_semCreate.sem_name, sem_name); shared_region->os_semCreate.sem_initial_value = sem_initial_value; shared_region->os_semCreate.options = options; - int32 result = emu_OS_CountSemCreate(spdid); + result = emu_OS_CountSemCreate(spdid); *sem_id = shared_region->os_semCreate.sem_id; return result; } @@ -665,11 +738,13 @@ OS_CountSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value int32 OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) { + int32 result; + assert(strlen(sem_name) < EMU_BUF_SIZE); strcpy(shared_region->os_mutSemCreate.sem_name, sem_name); shared_region->os_mutSemCreate.options = options; - int32 result = emu_OS_MutSemCreate(spdid); + result = emu_OS_MutSemCreate(spdid); *sem_id = shared_region->os_mutSemCreate.sem_id; return result; @@ -678,10 +753,12 @@ OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) int32 OS_TaskGetIdByName(uint32 *task_id, const char *task_name) { + int32 result; + assert(strlen(task_name) < EMU_BUF_SIZE); strcpy(shared_region->os_taskGetIdByName.task_name, task_name); - int32 result = emu_OS_TaskGetIdByName(spdid); + result = emu_OS_TaskGetIdByName(spdid); *task_id = shared_region->os_taskGetIdByName.task_id; return result; } @@ -689,22 +766,22 @@ OS_TaskGetIdByName(uint32 *task_id, const char *task_name) int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) { + int32 result; + assert(strlen(symbol_name) < EMU_BUF_SIZE); strcpy(shared_region->os_symbolLookup.symbol_name, symbol_name); - int32 result = emu_OS_SymbolLookup(spdid); + result = emu_OS_SymbolLookup(spdid); *symbol_address = shared_region->os_symbolLookup.symbol_address; return result; } /* Methods that are completly emulated */ -// FIXME: Query the cFE to decide whether printf is enabled -int is_printf_enabled = 1; void OS_printf(const char *string, ...) { - if (is_printf_enabled) { + if (emu_is_printf_enabled()) { char s[OS_BUFFER_SIZE]; va_list arg_ptr; int ret, len = OS_BUFFER_SIZE; diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index 8305a46d41..d0b3e2646e 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -49,6 +49,7 @@ cos_asm_server_stub(OS_rewinddir) // Emulated methods cos_asm_server_stub(emu_request_memory) cos_asm_server_stub(emu_create_aep_thread) +cos_asm_server_stub(emu_is_printf_enabled) cos_asm_server_stub(emu_CFE_ES_CalculateCRC) cos_asm_server_stub(emu_CFE_ES_CopyToCDS) From 939705b6358cd6286d1f969c62cc6b8646012a41 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 16 Apr 2018 13:35:33 -0400 Subject: [PATCH 115/122] Implement child task creation for the cFE interface --- .../no_interface/cFE_booter/cFE_emu_support.c | 53 ++++++++++++++++++- .../no_interface/cFE_booter/ostask.c | 22 +++++++- src/components/interface/cFE/cFE_emu.h | 22 ++++++++ src/components/interface/cFE/stubs/c_stub.c | 25 +++++++++ src/components/interface/cFE/stubs/s_stub.S | 7 ++- 5 files changed, 123 insertions(+), 6 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c index 4e5b23d222..ab024c0bb9 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -49,16 +49,56 @@ emu_request_memory(spdid_t client) return id; } - void emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_aepkey_t key) { + struct sl_thd *thd; + sched_param_t aep_priority; struct cos_defcompinfo child_dci; + cos_defcompinfo_childid_init(&child_dci, client); - sl_thd_aep_alloc_ext(&child_dci, NULL, idx, 1, 0, key, NULL); + thd = sl_thd_aep_alloc_ext(&child_dci, NULL, idx, 1, 0, key, NULL); + assert(thd); + + aep_priority = sched_param_pack(SCHEDP_PRIO, CFE_TIME_1HZ_TASK_PRIORITY); + sl_thd_param_set(thd, aep_priority); +} + +/* Methods for stashing and retrieving a idx, spdid pair + * This is done when a OS_TaskCreate call is rooted in another component + */ +struct { + thdclosure_index_t idx; + spdid_t spdid; +} stashed_task_values; + +void +emu_stash(thdclosure_index_t idx, spdid_t spdid) +{ + assert(stashed_task_values.idx == 0 && stashed_task_values.spdid == 0); + stashed_task_values.idx = idx; + stashed_task_values.spdid = spdid; +} + +void emu_stash_clear() +{ + stashed_task_values.idx = 0; + stashed_task_values.spdid = 0; +} + + +thdclosure_index_t +emu_stash_retrieve_thdclosure() +{ + return stashed_task_values.idx; } +spdid_t +emu_stash_retrieve_spdid() +{ + return stashed_task_values.spdid; +} int32 emu_CFE_ES_CalculateCRC(spdid_t client) @@ -75,6 +115,15 @@ emu_CFE_ES_CopyToCDS(spdid_t client) return CFE_ES_CopyToCDS(s->cfe_es_copyToCDS.CDSHandle, s->cfe_es_copyToCDS.DataToCopy); } +int32 +emu_CFE_ES_CreateChildTask(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_ES_CreateChildTask(&s->cfe_es_createChildTask.TaskId, s->cfe_es_createChildTask.TaskName, + s->cfe_es_createChildTask.FunctionPtr, NULL, + 0, s->cfe_es_createChildTask.Priority, s->cfe_es_createChildTask.Flags); +} + int32 emu_CFE_ES_GetAppIDByName(spdid_t client) diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index f21850c152..a12bc625ed 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -2,6 +2,8 @@ #include #include +#include + #include "cFE_util.h" #include "ostask.h" @@ -112,6 +114,7 @@ OS_TaskCreate(uint32 *task_id, const char *task_name, osal_task_entry function_p struct sl_thd * thd; sched_param_t sp; struct cfe_task_info *task_info; + struct cos_defcompinfo child_dci; if (task_id == NULL || task_name == NULL || function_pointer == NULL) { return OS_INVALID_POINTER; } @@ -121,8 +124,23 @@ OS_TaskCreate(uint32 *task_id, const char *task_name, osal_task_entry function_p if (priority > 255 || priority < 1) { return OS_ERR_INVALID_PRIORITY; } - thd = sl_thd_alloc(osal_task_entry_wrapper, function_pointer); - assert(thd); + /* If the create call is rooted in another component, STASH_MAGIC_VALUE will be passed as the function_pointer */ + if (function_pointer == STASH_MAGIC_VALUE) { + /* Since we know this is rooted in another component, we take the values from the stash */ + thdclosure_index_t idx = emu_stash_retrieve_thdclosure(); + spdid_t spdid = emu_stash_retrieve_spdid(); + + printc("task create in server (task_name = %s, fp = %p, idx = %d, spdid = %d)\n", task_name, function_pointer, idx, spdid); + + cos_defcompinfo_childid_init(&child_dci, spdid); + + thd = sl_thd_aep_alloc_ext(&child_dci, NULL, idx, 0, 0, 0, NULL); + assert(thd); + } else { + thd = sl_thd_alloc(osal_task_entry_wrapper, function_pointer); + assert(thd); + } + sp = sched_param_pack(SCHEDP_PRIO, priority); sl_thd_param_set(thd, sp); diff --git a/src/components/interface/cFE/cFE_emu.h b/src/components/interface/cFE/cFE_emu.h index 1cb2fc8151..9c48313a3a 100644 --- a/src/components/interface/cFE/cFE_emu.h +++ b/src/components/interface/cFE/cFE_emu.h @@ -1,3 +1,8 @@ +#ifndef _CFE_EMU_ +#define _CFE_EMU_ + +#include + #include #include @@ -199,14 +204,29 @@ union shared_region { CFE_ES_CDSHandle_t CDSHandle; char RestoreToMemory[EMU_BUF_SIZE]; } cfe_es_restoreFromCDS; + struct { + uint32 TaskId; + char TaskName[EMU_BUF_SIZE]; + CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr; + uint32 Priority; + uint32 Flags; + } cfe_es_createChildTask; }; int emu_request_memory(spdid_t client); void emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_aepkey_t key); int emu_is_printf_enabled(); +#define STASH_MAGIC_VALUE ((void *) 0xBEAFBEAF) + +void emu_stash(thdclosure_index_t idx, spdid_t spdid); +thdclosure_index_t emu_stash_retrieve_thdclosure(); +spdid_t emu_stash_retrieve_spdid(); +void emu_stash_clear(); + int32 emu_CFE_ES_CalculateCRC(spdid_t client); int32 emu_CFE_ES_CopyToCDS(spdid_t client); +int32 emu_CFE_ES_CreateChildTask(spdid_t client); int32 emu_CFE_ES_GetAppIDByName(spdid_t client); int32 emu_CFE_ES_GetAppInfo(spdid_t client); int32 emu_CFE_ES_GetGenCount(spdid_t client); @@ -265,3 +285,5 @@ int32 emu_OS_MutSemCreate(spdid_t client); int32 emu_OS_TaskGetIdByName(spdid_t client); int32 emu_OS_SymbolLookup(spdid_t client); + +#endif diff --git a/src/components/interface/cFE/stubs/c_stub.c b/src/components/interface/cFE/stubs/c_stub.c index 9102c2e62e..9a0a07c4c8 100644 --- a/src/components/interface/cFE/stubs/c_stub.c +++ b/src/components/interface/cFE/stubs/c_stub.c @@ -109,6 +109,31 @@ CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t CDSHandle, void * DataToCopy) return emu_CFE_ES_CopyToCDS(spdid); } +int32 +CFE_ES_CreateChildTask(uint32 *TaskIdPtr, const char *TaskName, + CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, uint32 *StackPtr, + uint32 StackSize, uint32 Priority, uint32 Flags) +{ + int32 result; + thdclosure_index_t idx = cos_thd_init_alloc(FunctionPtr, NULL); + + assert(strlen(TaskName) < EMU_BUF_SIZE); + strcpy(shared_region->cfe_es_createChildTask.TaskName, TaskName); + + emu_stash(idx, spdid); + + shared_region->cfe_es_createChildTask.FunctionPtr = STASH_MAGIC_VALUE; + shared_region->cfe_es_createChildTask.Priority = Priority; + shared_region->cfe_es_createChildTask.Flags = Flags; + + result = emu_CFE_ES_CreateChildTask(spdid); + *TaskIdPtr = shared_region->cfe_es_createChildTask.TaskId; + + emu_stash_clear(); + + return result; +} + int32 CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName) { diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index d0b3e2646e..a4c8b443e0 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -13,6 +13,7 @@ cos_asm_server_stub(CFE_ES_DeleteApp) cos_asm_server_stub(CFE_ES_ExitApp) +cos_asm_server_stub(CFE_ES_ExitChildTask) cos_asm_server_stub(CFE_ES_PerfLogAdd) cos_asm_server_stub(CFE_ES_RegisterApp) cos_asm_server_stub(CFE_ES_RegisterChildTask) @@ -29,8 +30,6 @@ cos_asm_server_stub(CFE_SB_Subscribe) cos_asm_server_stub(CFE_SB_Unsubscribe) cos_asm_server_stub(CFE_SB_UnsubscribeLocal) -cos_asm_server_stub(CFE_TBL_NotifyByMessage) - cos_asm_server_stub(CFE_TIME_FS2CFESeconds) cos_asm_server_stub(OS_CountSemGive) @@ -51,8 +50,12 @@ cos_asm_server_stub(emu_request_memory) cos_asm_server_stub(emu_create_aep_thread) cos_asm_server_stub(emu_is_printf_enabled) +cos_asm_server_stub(emu_stash) +cos_asm_server_stub(emu_stash_clear) + cos_asm_server_stub(emu_CFE_ES_CalculateCRC) cos_asm_server_stub(emu_CFE_ES_CopyToCDS) +cos_asm_server_stub(emu_CFE_ES_CreateChildTask) cos_asm_server_stub(emu_CFE_ES_GetAppIDByName) cos_asm_server_stub(emu_CFE_ES_GetAppInfo) cos_asm_server_stub(emu_CFE_ES_GetGenCount) From 80e66393a7db53cdd5fb383c9233cabcf59cba85 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Wed, 18 Apr 2018 00:31:11 -0400 Subject: [PATCH 116/122] Implement TBL api for the cFE interface (also autoformat it) --- .../no_interface/cFE_booter/cFE_emu_support.c | 86 +++++- src/components/interface/cFE/cFE_emu.h | 172 +++++++----- src/components/interface/cFE/stubs/c_stub.c | 248 ++++++++++++------ src/components/interface/cFE/stubs/s_stub.S | 14 + 4 files changed, 357 insertions(+), 163 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c index ab024c0bb9..fe91f35cdf 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -52,8 +52,8 @@ emu_request_memory(spdid_t client) void emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_aepkey_t key) { - struct sl_thd *thd; - sched_param_t aep_priority; + struct sl_thd * thd; + sched_param_t aep_priority; struct cos_defcompinfo child_dci; cos_defcompinfo_childid_init(&child_dci, client); @@ -70,20 +70,21 @@ emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_aepkey_t key) */ struct { thdclosure_index_t idx; - spdid_t spdid; + spdid_t spdid; } stashed_task_values; void emu_stash(thdclosure_index_t idx, spdid_t spdid) { assert(stashed_task_values.idx == 0 && stashed_task_values.spdid == 0); - stashed_task_values.idx = idx; + stashed_task_values.idx = idx; stashed_task_values.spdid = spdid; } -void emu_stash_clear() +void +emu_stash_clear() { - stashed_task_values.idx = 0; + stashed_task_values.idx = 0; stashed_task_values.spdid = 0; } @@ -100,6 +101,10 @@ emu_stash_retrieve_spdid() return stashed_task_values.spdid; } +/* Methods that wrap cFE methods + * They use data in memory shared with the calling component + */ + int32 emu_CFE_ES_CalculateCRC(spdid_t client) { @@ -120,8 +125,8 @@ emu_CFE_ES_CreateChildTask(spdid_t client) { union shared_region *s = shared_regions[client]; return CFE_ES_CreateChildTask(&s->cfe_es_createChildTask.TaskId, s->cfe_es_createChildTask.TaskName, - s->cfe_es_createChildTask.FunctionPtr, NULL, - 0, s->cfe_es_createChildTask.Priority, s->cfe_es_createChildTask.Flags); + s->cfe_es_createChildTask.FunctionPtr, NULL, 0, + s->cfe_es_createChildTask.Priority, s->cfe_es_createChildTask.Flags); } @@ -329,6 +334,71 @@ emu_CFE_SB_ValidateChecksum(spdid_t client) return CFE_SB_ValidateChecksum((CFE_SB_MsgPtr_t)s->cfe_sb_msg.Msg); } +struct { + size_t size; + void * tbl_ptr; /* FIXME: Wrap CFE_TBL_ReleaseAddress to set this back to NULL */ +} table_info[CFE_TBL_MAX_NUM_HANDLES]; + +int32 +emu_CFE_TBL_GetAddress(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + CFE_TBL_Handle_t handle = s->cfe_tbl_getAddress.TblHandle; + int32 result = CFE_TBL_GetAddress(&table_info[handle].tbl_ptr, handle); + + if (result == CFE_SUCCESS || result == CFE_TBL_INFO_UPDATED) { + memcpy(s->cfe_tbl_getAddress.Buffer, table_info[handle].tbl_ptr, table_info[handle].size); + } + + return result; +} + +int32 +emu_CFE_TBL_GetInfo(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_TBL_GetInfo(&s->cfe_tbl_getInfo.TblInfo, s->cfe_tbl_getInfo.TblName); +} + +int32 +emu_CFE_TBL_Load(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_TBL_Load(s->cfe_tbl_load.TblHandle, s->cfe_tbl_load.SrcType, s->cfe_tbl_load.SrcData); +} + +int32 +emu_CFE_TBL_Modified(spdid_t client) +{ + /* FIXME: We assume the passed data is valid, which isn't safe */ + + union shared_region *s = shared_regions[client]; + CFE_TBL_Handle_t handle = s->cfe_tbl_modified.TblHandle; + void * tbl_ptr = table_info[handle].tbl_ptr; + size_t size = table_info[handle].size; + + assert(tbl_ptr); + memcpy(tbl_ptr, s->cfe_tbl_modified.Buffer, size); + + return CFE_TBL_Modified(handle); +} + + +int32 +emu_CFE_TBL_Register(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + int32 result = CFE_TBL_Register(&s->cfe_tbl_register.TblHandle, s->cfe_tbl_register.Name, + s->cfe_tbl_register.TblSize, s->cfe_tbl_register.TblOptionFlags, NULL); + + if (result == CFE_SUCCESS || result == CFE_TBL_INFO_RECOVERED_TBL) { + table_info[s->cfe_tbl_register.TblHandle].size = s->cfe_tbl_register.TblSize; + } + + return result; +} + + void emu_CFE_TIME_Add(spdid_t client) { diff --git a/src/components/interface/cFE/cFE_emu.h b/src/components/interface/cFE/cFE_emu.h index 9c48313a3a..ea83c57d4e 100644 --- a/src/components/interface/cFE/cFE_emu.h +++ b/src/components/interface/cFE/cFE_emu.h @@ -5,8 +5,11 @@ #include +#include #include #include +#include +#include #define EMU_BUF_SIZE 512 @@ -49,11 +52,11 @@ union shared_region { } cfe_sb_msg; CFE_TIME_SysTime_t time; struct { - char PrintBuffer[CFE_TIME_PRINTED_STRING_SIZE]; + char PrintBuffer[CFE_TIME_PRINTED_STRING_SIZE]; CFE_TIME_SysTime_t TimeToPrint; } cfe_time_print; struct { - char Msg[EMU_BUF_SIZE]; + char Msg[EMU_BUF_SIZE]; uint16 CmdCode; } cfe_sb_setCmdCode; struct { @@ -68,7 +71,7 @@ union shared_region { } cfe_time_compare; struct { CFE_ES_TaskInfo_t TaskInfo; - uint32 TaskId; + uint32 TaskId; } cfe_es_getTaskInfo; struct { uint32 ResetSubtype; @@ -79,10 +82,10 @@ union shared_region { } cfe_es_getGenCount; struct { uint32 CounterId; - char CounterName[EMU_BUF_SIZE]; + char CounterName[EMU_BUF_SIZE]; } cfe_es_getGenCounterIDByName; struct { - int32 FileDes; + int32 FileDes; CFE_FS_Header_t Hdr; } cfe_fs_writeHeader; struct { @@ -90,21 +93,21 @@ union shared_region { char DestinationFile[EMU_BUF_SIZE]; } cfe_fs_decompress; struct { - char path[EMU_BUF_SIZE]; + char path[EMU_BUF_SIZE]; int32 access; } os_creat; struct { - int32 filedes; - char buffer[EMU_BUF_SIZE]; + int32 filedes; + char buffer[EMU_BUF_SIZE]; uint32 nbytes; } os_write; struct { cpuaddr symbol_address; - char symbol_name[EMU_BUF_SIZE]; + char symbol_name[EMU_BUF_SIZE]; } os_symbolLookup; struct { uint32 sem_id; - char sem_name[EMU_BUF_SIZE]; + char sem_name[EMU_BUF_SIZE]; uint32 sem_initial_value; uint32 options; } os_semCreate; @@ -113,20 +116,20 @@ union shared_region { char dest[EMU_BUF_SIZE]; } os_cp; struct { - int32 filedes; + int32 filedes; OS_FDTableEntry fd_prop; } os_FDGetInfo; struct { - char name[EMU_BUF_SIZE]; + char name[EMU_BUF_SIZE]; uint64 bytes_free; } os_fsBytesFree; struct { - char path[EMU_BUF_SIZE]; + char path[EMU_BUF_SIZE]; uint32 access; } os_mkdir; struct { uint32 sem_id; - char sem_name[EMU_BUF_SIZE]; + char sem_name[EMU_BUF_SIZE]; uint32 options; } os_mutSemCreate; struct { @@ -137,8 +140,8 @@ union shared_region { char path[EMU_BUF_SIZE]; } os_opendir; struct { - int32 filedes; - char buffer[EMU_BUF_SIZE]; + int32 filedes; + char buffer[EMU_BUF_SIZE]; uint32 nbytes; } os_read; struct { @@ -152,77 +155,100 @@ union shared_region { char path[EMU_BUF_SIZE]; } os_rmdir; struct { - char path[EMU_BUF_SIZE]; + char path[EMU_BUF_SIZE]; os_fstat_t filestats; } os_stat; struct { - os_dirp_t directory; + os_dirp_t directory; os_dirent_t dirent; } os_readdir; struct { uint32 task_id; - char task_name[EMU_BUF_SIZE]; + char task_name[EMU_BUF_SIZE]; } os_taskGetIdByName; struct { char String[EMU_BUF_SIZE]; } cfe_es_writeToSysLog; struct { - char path[EMU_BUF_SIZE]; - int32 access; + char path[EMU_BUF_SIZE]; + int32 access; uint32 mode; } os_open; struct { - char Data[EMU_BUF_SIZE]; + char Data[EMU_BUF_SIZE]; uint32 DataLength; uint32 InputCRC; uint32 TypeCRC; } cfe_es_calculateCRC; struct { uint32 AppId; - char AppName[EMU_BUF_SIZE]; + char AppName[EMU_BUF_SIZE]; } cfe_es_getAppIDByName; struct { CFE_ES_AppInfo_t AppInfo; - uint32 AppId; + uint32 AppId; } cfe_es_getAppInfo; struct { - CFE_SB_MsgId_t MsgId; + CFE_SB_MsgId_t MsgId; CFE_SB_PipeId_t PipeId; - CFE_SB_Qos_t Quality; - uint16 MsgLim; + CFE_SB_Qos_t Quality; + uint16 MsgLim; } cfe_sb_subscribeEx; struct { CFE_ES_CDSHandle_t CDS_Handle; - int32 BlockSize; - char Name[EMU_BUF_SIZE]; + int32 BlockSize; + char Name[EMU_BUF_SIZE]; } cfe_es_registerCDS; struct { CFE_ES_CDSHandle_t CDSHandle; - char DataToCopy[EMU_BUF_SIZE]; + char DataToCopy[EMU_BUF_SIZE]; } cfe_es_copyToCDS; struct { CFE_ES_CDSHandle_t CDSHandle; - char RestoreToMemory[EMU_BUF_SIZE]; + char RestoreToMemory[EMU_BUF_SIZE]; } cfe_es_restoreFromCDS; struct { - uint32 TaskId; - char TaskName[EMU_BUF_SIZE]; + uint32 TaskId; + char TaskName[EMU_BUF_SIZE]; CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr; - uint32 Priority; - uint32 Flags; + uint32 Priority; + uint32 Flags; } cfe_es_createChildTask; + struct { + CFE_TBL_Handle_t TblHandle; + char Name[EMU_BUF_SIZE]; + uint32 TblSize; + uint16 TblOptionFlags; + } cfe_tbl_register; + struct { + CFE_TBL_Handle_t TblHandle; + char Buffer[EMU_BUF_SIZE]; + } cfe_tbl_getAddress; + struct { + CFE_TBL_Handle_t TblHandle; + char Buffer[EMU_BUF_SIZE]; + } cfe_tbl_modified; + struct { + CFE_TBL_Handle_t TblHandle; + CFE_TBL_SrcEnum_t SrcType; + char SrcData[EMU_BUF_SIZE]; + } cfe_tbl_load; + struct { + CFE_TBL_Info_t TblInfo; + char TblName[EMU_BUF_SIZE]; + } cfe_tbl_getInfo; }; -int emu_request_memory(spdid_t client); +int emu_request_memory(spdid_t client); void emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_aepkey_t key); -int emu_is_printf_enabled(); +int emu_is_printf_enabled(); -#define STASH_MAGIC_VALUE ((void *) 0xBEAFBEAF) +#define STASH_MAGIC_VALUE ((void *)0xBEAFBEAF) -void emu_stash(thdclosure_index_t idx, spdid_t spdid); +void emu_stash(thdclosure_index_t idx, spdid_t spdid); thdclosure_index_t emu_stash_retrieve_thdclosure(); -spdid_t emu_stash_retrieve_spdid(); -void emu_stash_clear(); +spdid_t emu_stash_retrieve_spdid(); +void emu_stash_clear(); int32 emu_CFE_ES_CalculateCRC(spdid_t client); int32 emu_CFE_ES_CopyToCDS(spdid_t client); @@ -244,40 +270,46 @@ int32 emu_CFE_EVS_SendEvent(spdid_t client); int32 emu_CFE_FS_Decompress(spdid_t client); int32 emu_CFE_FS_WriteHeader(spdid_t client); -int32 emu_CFE_SB_CreatePipe(spdid_t client); -uint16 emu_CFE_SB_GetCmdCode(spdid_t client); +int32 emu_CFE_SB_CreatePipe(spdid_t client); +uint16 emu_CFE_SB_GetCmdCode(spdid_t client); CFE_SB_MsgId_t emu_CFE_SB_GetMsgId(spdid_t client); -void emu_CFE_SB_GetMsgTime(spdid_t client); -uint16 emu_CFE_SB_GetTotalMsgLength(spdid_t client); -void emu_CFE_SB_InitMsg(spdid_t client); -int32 emu_CFE_SB_RcvMsg(spdid_t client); -int32 emu_CFE_SB_SetCmdCode(spdid_t client); -int32 emu_CFE_SB_SendMsg(spdid_t client); -int32 emu_CFE_SB_SubscribeEx(spdid_t client); -void emu_CFE_SB_TimeStampMsg(spdid_t client); -boolean emu_CFE_SB_ValidateChecksum(spdid_t client); +void emu_CFE_SB_GetMsgTime(spdid_t client); +uint16 emu_CFE_SB_GetTotalMsgLength(spdid_t client); +void emu_CFE_SB_InitMsg(spdid_t client); +int32 emu_CFE_SB_RcvMsg(spdid_t client); +int32 emu_CFE_SB_SetCmdCode(spdid_t client); +int32 emu_CFE_SB_SendMsg(spdid_t client); +int32 emu_CFE_SB_SubscribeEx(spdid_t client); +void emu_CFE_SB_TimeStampMsg(spdid_t client); +boolean emu_CFE_SB_ValidateChecksum(spdid_t client); + +int32 emu_CFE_TBL_GetAddress(spdid_t client); +int32 emu_CFE_TBL_GetInfo(spdid_t client); +int32 emu_CFE_TBL_Load(spdid_t client); +int32 emu_CFE_TBL_Modified(spdid_t client); +int32 emu_CFE_TBL_Register(spdid_t client); -void emu_CFE_TIME_Add(spdid_t client); -void emu_CFE_TIME_Compare(spdid_t client); -void emu_CFE_TIME_GetTime(spdid_t client); -void emu_CFE_TIME_Print(spdid_t client); +void emu_CFE_TIME_Add(spdid_t client); +void emu_CFE_TIME_Compare(spdid_t client); +void emu_CFE_TIME_GetTime(spdid_t client); +void emu_CFE_TIME_Print(spdid_t client); int32 emu_CFE_TIME_RegisterSynchCallback(cos_aepkey_t key); -int32 emu_OS_cp(spdid_t client); -int32 emu_OS_creat(spdid_t client); -int32 emu_OS_FDGetInfo(spdid_t client); -int32 emu_OS_fsBytesFree(spdid_t client); -int32 emu_OS_mkdir(spdid_t client); -int32 emu_OS_mv(spdid_t client); -int32 emu_OS_open(spdid_t client); +int32 emu_OS_cp(spdid_t client); +int32 emu_OS_creat(spdid_t client); +int32 emu_OS_FDGetInfo(spdid_t client); +int32 emu_OS_fsBytesFree(spdid_t client); +int32 emu_OS_mkdir(spdid_t client); +int32 emu_OS_mv(spdid_t client); +int32 emu_OS_open(spdid_t client); os_dirp_t emu_OS_opendir(spdid_t client); -int32 emu_OS_read(spdid_t client); -void emu_OS_readdir(spdid_t client); -int32 emu_OS_remove(spdid_t client); -int32 emu_OS_rename(spdid_t client); -int32 emu_OS_rmdir(spdid_t client); -int32 emu_OS_stat(spdid_t client); -int32 emu_OS_write(spdid_t client); +int32 emu_OS_read(spdid_t client); +void emu_OS_readdir(spdid_t client); +int32 emu_OS_remove(spdid_t client); +int32 emu_OS_rename(spdid_t client); +int32 emu_OS_rmdir(spdid_t client); +int32 emu_OS_stat(spdid_t client); +int32 emu_OS_write(spdid_t client); int32 emu_OS_BinSemCreate(spdid_t client); int32 emu_OS_CountSemCreate(spdid_t client); diff --git a/src/components/interface/cFE/stubs/c_stub.c b/src/components/interface/cFE/stubs/c_stub.c index 9a0a07c4c8..4970c50ecc 100644 --- a/src/components/interface/cFE/stubs/c_stub.c +++ b/src/components/interface/cFE/stubs/c_stub.c @@ -8,34 +8,29 @@ #include #include "../interface/capmgr/memmgr.h" -#include -#include -#include -#include - #include #define BASE_AEP_KEY 0xBEAFCAFE union shared_region *shared_region; spdid_t spdid; -cos_aepkey_t time_sync_key; +cos_aepkey_t time_sync_key; /* We could copy this from the cFE, but it's zero intialized there * Also it's totally unused (according to cFE documentation) */ -CFE_SB_Qos_t CFE_SB_Default_Qos = { 0 }; +CFE_SB_Qos_t CFE_SB_Default_Qos = {0}; -size_t CDS_sizes[CFE_ES_CDS_MAX_NUM_ENTRIES] = { 0 }; +size_t CDS_sizes[CFE_ES_CDS_MAX_NUM_ENTRIES] = {0}; -int sync_callbacks_are_setup = 0; +int sync_callbacks_are_setup = 0; CFE_TIME_SynchCallbackPtr_t sync_callbacks[CFE_TIME_MAX_NUM_SYNCH_FUNCS]; void do_emulation_setup(spdid_t id) { vaddr_t client_addr; - int region_id = emu_request_memory(id); + int region_id = emu_request_memory(id); spdid = id; @@ -56,9 +51,7 @@ handle_sync_callbacks(arcvcap_t rcv, void *data) if (pending) { int i; for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) { - if (sync_callbacks[i]){ - sync_callbacks[i](); - } + if (sync_callbacks[i]) { sync_callbacks[i](); } } } } @@ -67,9 +60,8 @@ handle_sync_callbacks(arcvcap_t rcv, void *data) void ensure_sync_callbacks_are_setup() { - if (!sync_callbacks_are_setup) - { - int32 result; + if (!sync_callbacks_are_setup) { + int32 result; thdclosure_index_t idx = cos_thd_init_alloc(handle_sync_callbacks, NULL); emu_create_aep_thread(spdid, idx, time_sync_key); @@ -82,6 +74,7 @@ ensure_sync_callbacks_are_setup() /* FIXME: Be more careful about user supplied pointers * FIXME: Take a lock in each function, so shared memory can't be corrupted + * FIXME: Don't pass spdid, use the builtin functionality instead */ uint32 CFE_ES_CalculateCRC(const void *DataPtr, uint32 DataLength, uint32 InputCRC, uint32 TypeCRC) @@ -89,12 +82,12 @@ CFE_ES_CalculateCRC(const void *DataPtr, uint32 DataLength, uint32 InputCRC, uin assert(DataLength < EMU_BUF_SIZE); memcpy(shared_region->cfe_es_calculateCRC.Data, DataPtr, DataLength); shared_region->cfe_es_calculateCRC.InputCRC = InputCRC; - shared_region->cfe_es_calculateCRC.TypeCRC = TypeCRC; + shared_region->cfe_es_calculateCRC.TypeCRC = TypeCRC; return emu_CFE_ES_CalculateCRC(spdid); } int32 -CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t CDSHandle, void * DataToCopy) +CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t CDSHandle, void *DataToCopy) { size_t data_size; @@ -110,11 +103,10 @@ CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t CDSHandle, void * DataToCopy) } int32 -CFE_ES_CreateChildTask(uint32 *TaskIdPtr, const char *TaskName, - CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, uint32 *StackPtr, - uint32 StackSize, uint32 Priority, uint32 Flags) +CFE_ES_CreateChildTask(uint32 *TaskIdPtr, const char *TaskName, CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, + uint32 *StackPtr, uint32 StackSize, uint32 Priority, uint32 Flags) { - int32 result; + int32 result; thdclosure_index_t idx = cos_thd_init_alloc(FunctionPtr, NULL); assert(strlen(TaskName) < EMU_BUF_SIZE); @@ -123,10 +115,10 @@ CFE_ES_CreateChildTask(uint32 *TaskIdPtr, const char *TaskName, emu_stash(idx, spdid); shared_region->cfe_es_createChildTask.FunctionPtr = STASH_MAGIC_VALUE; - shared_region->cfe_es_createChildTask.Priority = Priority; - shared_region->cfe_es_createChildTask.Flags = Flags; + shared_region->cfe_es_createChildTask.Priority = Priority; + shared_region->cfe_es_createChildTask.Flags = Flags; - result = emu_CFE_ES_CreateChildTask(spdid); + result = emu_CFE_ES_CreateChildTask(spdid); *TaskIdPtr = shared_region->cfe_es_createChildTask.TaskId; emu_stash_clear(); @@ -142,7 +134,7 @@ CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName) assert(strlen(AppName) < EMU_BUF_SIZE); strcpy(shared_region->cfe_es_getAppIDByName.AppName, AppName); - result = emu_CFE_ES_GetAppIDByName(spdid); + result = emu_CFE_ES_GetAppIDByName(spdid); *AppIdPtr = shared_region->cfe_es_getAppIDByName.AppId; return result; @@ -154,8 +146,8 @@ CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, uint32 AppId) int32 result; shared_region->cfe_es_getAppInfo.AppId = AppId; - result = emu_CFE_ES_GetAppInfo(spdid); - *AppInfo = shared_region->cfe_es_getAppInfo.AppInfo; + result = emu_CFE_ES_GetAppInfo(spdid); + *AppInfo = shared_region->cfe_es_getAppInfo.AppInfo; return result; } @@ -166,8 +158,8 @@ CFE_ES_GetGenCount(uint32 CounterId, uint32 *Count) int32 result; shared_region->cfe_es_getGenCount.CounterId = CounterId; - result = emu_CFE_ES_GetGenCount(spdid); - *Count = shared_region->cfe_es_getGenCount.Count; + result = emu_CFE_ES_GetGenCount(spdid); + *Count = shared_region->cfe_es_getGenCount.Count; return result; } @@ -178,7 +170,7 @@ CFE_ES_GetGenCounterIDByName(uint32 *CounterIdPtr, const char *CounterName) int32 result; strcpy(shared_region->cfe_es_getGenCounterIDByName.CounterName, CounterName); - result = emu_CFE_ES_GetGenCounterIDByName(spdid); + result = emu_CFE_ES_GetGenCounterIDByName(spdid); *CounterIdPtr = shared_region->cfe_es_getGenCounterIDByName.CounterId; return result; @@ -199,8 +191,8 @@ CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, uint32 TaskId) int32 result; shared_region->cfe_es_getTaskInfo.TaskId = TaskId; - result = emu_CFE_ES_GetTaskInfo(spdid); - *TaskInfo = shared_region->cfe_es_getTaskInfo.TaskInfo; + result = emu_CFE_ES_GetTaskInfo(spdid); + *TaskInfo = shared_region->cfe_es_getTaskInfo.TaskInfo; return result; } @@ -217,8 +209,8 @@ CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, int32 BlockSize, const char *N result = emu_CFE_ES_RegisterCDS(spdid); if (result == CFE_SUCCESS) { CFE_ES_CDSHandle_t handle = shared_region->cfe_es_registerCDS.CDS_Handle; - CDS_sizes[handle] = BlockSize; - *HandlePtr = handle; + CDS_sizes[handle] = BlockSize; + *HandlePtr = handle; } return result; } @@ -226,7 +218,7 @@ CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, int32 BlockSize, const char *N int32 CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t CDSHandle) { - int32 result; + int32 result; size_t data_size; shared_region->cfe_es_restoreFromCDS.CDSHandle = CDSHandle; @@ -278,9 +270,7 @@ int32 CFE_EVS_Register(void * Filters, /* Pointer to an array of filte if (FilterScheme != CFE_EVS_BINARY_FILTER) { return CFE_EVS_UNKNOWN_FILTER; } bin_filters = Filters; - for (i = 0; i < NumFilteredEvents; i++) { - shared_region->cfe_evs_register.filters[i] = bin_filters[i]; - } + for (i = 0; i < NumFilteredEvents; i++) { shared_region->cfe_evs_register.filters[i] = bin_filters[i]; } shared_region->cfe_evs_register.NumEventFilters = NumFilteredEvents; shared_region->cfe_evs_register.FilterScheme = FilterScheme; @@ -319,8 +309,8 @@ CFE_FS_WriteHeader(int32 FileDes, CFE_FS_Header_t *Hdr) { int32 result; shared_region->cfe_fs_writeHeader.FileDes = FileDes; - result = emu_CFE_FS_WriteHeader(spdid); - *Hdr = shared_region->cfe_fs_writeHeader.Hdr; + result = emu_CFE_FS_WriteHeader(spdid); + *Hdr = shared_region->cfe_fs_writeHeader.Hdr; return result; } @@ -331,7 +321,8 @@ CFE_PSP_MemCpy(void *dest, void *src, uint32 n) return CFE_PSP_SUCCESS; } -int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n) +int32 +CFE_PSP_MemSet(void *dest, uint8 value, uint32 n) { memset(dest, value, n); return CFE_PSP_SUCCESS; @@ -344,7 +335,7 @@ CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *PipeName shared_region->cfe_sb_createPipe.Depth = Depth; strncpy(shared_region->cfe_sb_createPipe.PipeName, PipeName, OS_MAX_API_NAME); - result = emu_CFE_SB_CreatePipe(spdid); + result = emu_CFE_SB_CreatePipe(spdid); *PipeIdPtr = shared_region->cfe_sb_createPipe.PipeId; return result; } @@ -352,7 +343,7 @@ CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *PipeName uint16 CFE_SB_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr) { - char *msg_ptr; + char * msg_ptr; uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); assert(msg_len <= EMU_BUF_SIZE); @@ -364,7 +355,7 @@ CFE_SB_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr) CFE_SB_MsgId_t CFE_SB_GetMsgId(CFE_SB_MsgPtr_t MsgPtr) { - char *msg_ptr; + char * msg_ptr; uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); assert(msg_len <= EMU_BUF_SIZE); @@ -377,7 +368,7 @@ CFE_SB_GetMsgId(CFE_SB_MsgPtr_t MsgPtr) CFE_TIME_SysTime_t CFE_SB_GetMsgTime(CFE_SB_MsgPtr_t MsgPtr) { - char *msg_ptr; + char * msg_ptr; uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); assert(msg_len <= EMU_BUF_SIZE); @@ -435,10 +426,11 @@ CFE_SB_RcvMsg(CFE_SB_MsgPtr_t *BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut) return result; } -int32 CFE_SB_SetCmdCode(CFE_SB_MsgPtr_t MsgPtr, uint16 CmdCode) +int32 +CFE_SB_SetCmdCode(CFE_SB_MsgPtr_t MsgPtr, uint16 CmdCode) { - int32 result; - char *msg_ptr; + int32 result; + char * msg_ptr; uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); assert(msg_len <= EMU_BUF_SIZE); @@ -456,7 +448,7 @@ int32 CFE_SB_SetCmdCode(CFE_SB_MsgPtr_t MsgPtr, uint16 CmdCode) int32 CFE_SB_SendMsg(CFE_SB_Msg_t *MsgPtr) { - char *msg_ptr; + char * msg_ptr; uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); assert(msg_len <= EMU_BUF_SIZE); @@ -469,17 +461,17 @@ CFE_SB_SendMsg(CFE_SB_Msg_t *MsgPtr) int32 CFE_SB_SubscribeEx(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, CFE_SB_Qos_t Quality, uint16 MsgLim) { - shared_region->cfe_sb_subscribeEx.MsgId = MsgId; - shared_region->cfe_sb_subscribeEx.PipeId = PipeId; + shared_region->cfe_sb_subscribeEx.MsgId = MsgId; + shared_region->cfe_sb_subscribeEx.PipeId = PipeId; shared_region->cfe_sb_subscribeEx.Quality = Quality; - shared_region->cfe_sb_subscribeEx.MsgLim = MsgLim; + shared_region->cfe_sb_subscribeEx.MsgLim = MsgLim; return emu_CFE_SB_SubscribeEx(spdid); } void CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr) { - char *msg_ptr; + char * msg_ptr; uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); assert(msg_len <= EMU_BUF_SIZE); @@ -490,9 +482,9 @@ CFE_SB_TimeStampMsg(CFE_SB_MsgPtr_t MsgPtr) } boolean -CFE_SB_ValidateChecksum (CFE_SB_MsgPtr_t MsgPtr) +CFE_SB_ValidateChecksum(CFE_SB_MsgPtr_t MsgPtr) { - char *msg_ptr; + char * msg_ptr; uint16 msg_len = CFE_SB_GetTotalMsgLength(MsgPtr); assert(msg_len <= EMU_BUF_SIZE); @@ -502,6 +494,94 @@ CFE_SB_ValidateChecksum (CFE_SB_MsgPtr_t MsgPtr) return emu_CFE_SB_ValidateChecksum(spdid); } +struct { + size_t size; + char buffer[EMU_BUF_SIZE]; +} table_info[CFE_TBL_MAX_NUM_HANDLES]; + +int32 +CFE_TBL_GetAddress(void **TblPtr, CFE_TBL_Handle_t TblHandle) +{ + int32 result; + + shared_region->cfe_tbl_getAddress.TblHandle = TblHandle; + + result = emu_CFE_TBL_GetAddress(spdid); + + if (result == CFE_SUCCESS || result == CFE_TBL_INFO_UPDATED) { + memcpy(table_info[TblHandle].buffer, shared_region->cfe_tbl_getAddress.Buffer, + table_info[TblHandle].size); + + *TblPtr = table_info[TblHandle].buffer; + } + + return result; +} + +int32 +CFE_TBL_GetInfo(CFE_TBL_Info_t *TblInfoPtr, const char *TblName) +{ + int32 result; + + assert(strlen(TblName) < EMU_BUF_SIZE); + strcpy(shared_region->cfe_tbl_getInfo.TblName, TblName); + + result = emu_CFE_TBL_GetInfo(spdid); + if (result == CFE_SUCCESS) { *TblInfoPtr = shared_region->cfe_tbl_getInfo.TblInfo; } + return result; +} + +int32 +CFE_TBL_Load(CFE_TBL_Handle_t TblHandle, CFE_TBL_SrcEnum_t SrcType, const void *SrcDataPtr) +{ + shared_region->cfe_tbl_load.TblHandle = TblHandle; + shared_region->cfe_tbl_load.SrcType = SrcType; + + if (SrcType == CFE_TBL_SRC_FILE) { + assert(strlen(SrcDataPtr) < EMU_BUF_SIZE); + strcpy(shared_region->cfe_tbl_load.SrcData, SrcDataPtr); + } else if (SrcType == CFE_TBL_SRC_ADDRESS) { + assert(TblHandle < CFE_TBL_MAX_NUM_HANDLES); + memcpy(shared_region->cfe_tbl_load.SrcData, SrcDataPtr, table_info[TblHandle].size); + } else { + return CFE_TBL_ERR_ILLEGAL_SRC_TYPE; + } + return emu_CFE_TBL_Load(spdid); +} + +int32 +CFE_TBL_Modified(CFE_TBL_Handle_t TblHandle) +{ + assert(TblHandle < CFE_TBL_MAX_NUM_HANDLES); + memcpy(shared_region->cfe_tbl_modified.Buffer, table_info[TblHandle].buffer, table_info[TblHandle].size); + + shared_region->cfe_tbl_modified.TblHandle = TblHandle; + + return emu_CFE_TBL_Modified(spdid); +} + +int32 +CFE_TBL_Register(CFE_TBL_Handle_t *TblHandlePtr, const char *Name, uint32 TblSize, uint16 TblOptionFlags, + CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr) +{ + int32 result; + + assert(strlen(Name) < EMU_BUF_SIZE); + + strcpy(shared_region->cfe_tbl_register.Name, Name); + shared_region->cfe_tbl_register.TblSize = TblSize; + shared_region->cfe_tbl_register.TblOptionFlags = TblOptionFlags; + /* FIXME: Validation callbacks barely matter, implement them later */ + + result = emu_CFE_TBL_Register(spdid); + if (result == CFE_SUCCESS || result == CFE_TBL_INFO_RECOVERED_TBL) { + table_info[shared_region->cfe_tbl_register.TblHandle].size = TblSize; + assert(TblSize <= EMU_BUF_SIZE); + } + + return result; +} + CFE_TIME_SysTime_t CFE_TIME_Add(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Time2) { @@ -541,8 +621,7 @@ CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr) int i; ensure_sync_callbacks_are_setup(); - for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) - { + for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) { if (!sync_callbacks[i]) { sync_callbacks[i] = CallbackFuncPtr; return CFE_SUCCESS; @@ -555,8 +634,7 @@ int32 CFE_TIME_UnregisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr) { int i; - for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) - { + for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) { if (sync_callbacks[i] == CallbackFuncPtr) { sync_callbacks[i] = NULL; return CFE_SUCCESS; @@ -578,7 +656,7 @@ OS_cp(const char *src, const char *dest) int32 OS_creat(const char *path, int32 access) { - assert(strlen(path) < EMU_BUF_SIZE); + assert(strlen(path) < EMU_BUF_SIZE); strcpy(shared_region->os_creat.path, path); shared_region->os_creat.access = access; @@ -591,8 +669,8 @@ OS_FDGetInfo(int32 filedes, OS_FDTableEntry *fd_prop) int32 result; shared_region->os_FDGetInfo.filedes = filedes; - result = emu_OS_FDGetInfo(spdid); - *fd_prop = shared_region->os_FDGetInfo.fd_prop; + result = emu_OS_FDGetInfo(spdid); + *fd_prop = shared_region->os_FDGetInfo.fd_prop; return result; } @@ -601,10 +679,10 @@ OS_fsBytesFree(const char *name, uint64 *bytes_free) { int32 result; - assert(strlen(name) < EMU_BUF_SIZE); + assert(strlen(name) < EMU_BUF_SIZE); strcpy(shared_region->os_fsBytesFree.name, name); - result = emu_OS_fsBytesFree(spdid); + result = emu_OS_fsBytesFree(spdid); *bytes_free = shared_region->os_fsBytesFree.bytes_free; return result; @@ -613,7 +691,7 @@ OS_fsBytesFree(const char *name, uint64 *bytes_free) int32 OS_mkdir(const char *path, uint32 access) { - assert(strlen(path) < EMU_BUF_SIZE); + assert(strlen(path) < EMU_BUF_SIZE); strcpy(shared_region->os_mkdir.path, path); shared_region->os_mkdir.access = access; @@ -638,7 +716,7 @@ OS_open(const char *path, int32 access, uint32 mode) strcpy(shared_region->os_open.path, path); shared_region->os_open.access = access; - shared_region->os_open.mode = mode; + shared_region->os_open.mode = mode; return emu_OS_open(spdid); } @@ -660,8 +738,8 @@ OS_read(int32 filedes, void *buffer, uint32 nbytes) assert(nbytes <= EMU_BUF_SIZE); shared_region->os_read.filedes = filedes; - shared_region->os_read.nbytes = nbytes; - result = emu_OS_read(spdid); + shared_region->os_read.nbytes = nbytes; + result = emu_OS_read(spdid); memcpy(buffer, shared_region->os_read.buffer, nbytes); return result; } @@ -678,7 +756,7 @@ OS_remove(const char *path) os_dirent_t buffered_dirent; -os_dirent_t* +os_dirent_t * OS_readdir(os_dirp_t directory) { shared_region->os_readdir.directory = directory; @@ -715,7 +793,7 @@ OS_stat(const char *path, os_fstat_t *filestats) assert(strlen(path) < EMU_BUF_SIZE); strcpy(shared_region->os_stat.path, path); - result = emu_OS_stat(spdid); + result = emu_OS_stat(spdid); *filestats = shared_region->os_stat.filestats; return result; } @@ -723,7 +801,7 @@ OS_stat(const char *path, os_fstat_t *filestats) int32 OS_write(int32 filedes, void *buffer, uint32 nbytes) { - assert(nbytes < EMU_BUF_SIZE); + assert(nbytes < EMU_BUF_SIZE); shared_region->os_write.filedes = filedes; memcpy(shared_region->os_write.buffer, buffer, nbytes); shared_region->os_write.nbytes = nbytes; @@ -735,13 +813,13 @@ OS_BinSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, { int32 result; - assert(strlen(sem_name) < EMU_BUF_SIZE); + assert(strlen(sem_name) < EMU_BUF_SIZE); strcpy(shared_region->os_semCreate.sem_name, sem_name); shared_region->os_semCreate.sem_initial_value = sem_initial_value; - shared_region->os_semCreate.options = options; - result = emu_OS_BinSemCreate(spdid); - *sem_id = shared_region->os_semCreate.sem_id; + shared_region->os_semCreate.options = options; + result = emu_OS_BinSemCreate(spdid); + *sem_id = shared_region->os_semCreate.sem_id; return result; } @@ -750,13 +828,13 @@ OS_CountSemCreate(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value { int32 result; - assert(strlen(sem_name) < EMU_BUF_SIZE); + assert(strlen(sem_name) < EMU_BUF_SIZE); strcpy(shared_region->os_semCreate.sem_name, sem_name); shared_region->os_semCreate.sem_initial_value = sem_initial_value; - shared_region->os_semCreate.options = options; - result = emu_OS_CountSemCreate(spdid); - *sem_id = shared_region->os_semCreate.sem_id; + shared_region->os_semCreate.options = options; + result = emu_OS_CountSemCreate(spdid); + *sem_id = shared_region->os_semCreate.sem_id; return result; } @@ -765,12 +843,12 @@ OS_MutSemCreate(uint32 *sem_id, const char *sem_name, uint32 options) { int32 result; - assert(strlen(sem_name) < EMU_BUF_SIZE); + assert(strlen(sem_name) < EMU_BUF_SIZE); strcpy(shared_region->os_mutSemCreate.sem_name, sem_name); shared_region->os_mutSemCreate.options = options; - result = emu_OS_MutSemCreate(spdid); - *sem_id = shared_region->os_mutSemCreate.sem_id; + result = emu_OS_MutSemCreate(spdid); + *sem_id = shared_region->os_mutSemCreate.sem_id; return result; } @@ -783,7 +861,7 @@ OS_TaskGetIdByName(uint32 *task_id, const char *task_name) assert(strlen(task_name) < EMU_BUF_SIZE); strcpy(shared_region->os_taskGetIdByName.task_name, task_name); - result = emu_OS_TaskGetIdByName(spdid); + result = emu_OS_TaskGetIdByName(spdid); *task_id = shared_region->os_taskGetIdByName.task_id; return result; } @@ -796,7 +874,7 @@ OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) assert(strlen(symbol_name) < EMU_BUF_SIZE); strcpy(shared_region->os_symbolLookup.symbol_name, symbol_name); - result = emu_OS_SymbolLookup(spdid); + result = emu_OS_SymbolLookup(spdid); *symbol_address = shared_region->os_symbolLookup.symbol_address; return result; } diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index a4c8b443e0..a0785fd8e4 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -30,6 +30,14 @@ cos_asm_server_stub(CFE_SB_Subscribe) cos_asm_server_stub(CFE_SB_Unsubscribe) cos_asm_server_stub(CFE_SB_UnsubscribeLocal) +cos_asm_server_stub(CFE_TBL_DumpToBuffer) +cos_asm_server_stub(CFE_TBL_GetStatus) +cos_asm_server_stub(CFE_TBL_Manage) +cos_asm_server_stub(CFE_TBL_NotifyByMessage) +cos_asm_server_stub(CFE_TBL_ReleaseAddress) +cos_asm_server_stub(CFE_TBL_Update) +cos_asm_server_stub(CFE_TBL_Validate) + cos_asm_server_stub(CFE_TIME_FS2CFESeconds) cos_asm_server_stub(OS_CountSemGive) @@ -86,6 +94,12 @@ cos_asm_server_stub(emu_CFE_SB_SubscribeEx) cos_asm_server_stub(emu_CFE_SB_TimeStampMsg) cos_asm_server_stub(emu_CFE_SB_ValidateChecksum) +cos_asm_server_stub(emu_CFE_TBL_GetInfo) +cos_asm_server_stub(emu_CFE_TBL_GetAddress) +cos_asm_server_stub(emu_CFE_TBL_Modified) +cos_asm_server_stub(emu_CFE_TBL_Register) +cos_asm_server_stub(emu_CFE_TBL_Load) + cos_asm_server_stub(emu_CFE_TIME_Add) cos_asm_server_stub(emu_CFE_TIME_Compare) cos_asm_server_stub(emu_CFE_TIME_GetTime) From 419497e5756eb7cb2f2c547df470c095195ce251 Mon Sep 17 00:00:00 2001 From: base0x10 Date: Fri, 20 Apr 2018 12:48:55 -0400 Subject: [PATCH 117/122] small makefile update --- src/components/implementation/no_interface/ds/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/implementation/no_interface/ds/Makefile b/src/components/implementation/no_interface/ds/Makefile index 1db070a233..6ed41699e4 100644 --- a/src/components/implementation/no_interface/ds/Makefile +++ b/src/components/implementation/no_interface/ds/Makefile @@ -2,7 +2,7 @@ ASM_OBJS= COMPONENT=ds_app.o INTERFACES= -DEPENDENCIES=cFE +DEPENDENCIES=cFE capmgr IF_LIB:=./cFE_ds_app.o ./cFE_ds_cmds.o ./cFE_ds_file.o ./cFE_ds_table.o ADDITIONAL_LIBS=-lcos_kernel_api From 5df1cda4fb182bb14e793c3f6c97cad232fda63a Mon Sep 17 00:00:00 2001 From: base0x10 Date: Mon, 23 Apr 2018 00:40:33 -0400 Subject: [PATCH 118/122] Move cFE configuration to real componentized apps Brought five new apps into the cFE repo. They each run as their own component. mm is current not working, requiring more stubs to be written. All of the infrastructure is there from the cFE side of things, but it is excluded from the make.py list of apps. --- .../implementation/no_interface/cfs_lib/Makefile | 10 ---------- .../implementation/no_interface/ds/Makefile | 2 +- .../implementation/no_interface/fm/Makefile | 4 ++-- .../implementation/no_interface/hs/Makefile | 2 +- .../implementation/no_interface/mm/Makefile | 4 ++-- .../no_interface/sample_app/Makefile | 10 ---------- .../no_interface/sample_app/init.c | 16 ---------------- .../no_interface/sample_lib/Makefile | 10 ---------- .../no_interface/sample_lib/init.c | 16 ---------------- .../implementation/no_interface/sc/Makefile | 2 +- src/components/interface/cFE/stubs/s_stub.S | 1 + src/extern/cFE | 2 +- 12 files changed, 9 insertions(+), 70 deletions(-) delete mode 100644 src/components/implementation/no_interface/cfs_lib/Makefile delete mode 100644 src/components/implementation/no_interface/sample_app/Makefile delete mode 100644 src/components/implementation/no_interface/sample_app/init.c delete mode 100644 src/components/implementation/no_interface/sample_lib/Makefile delete mode 100644 src/components/implementation/no_interface/sample_lib/init.c diff --git a/src/components/implementation/no_interface/cfs_lib/Makefile b/src/components/implementation/no_interface/cfs_lib/Makefile deleted file mode 100644 index c96dd1478c..0000000000 --- a/src/components/implementation/no_interface/cfs_lib/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c -ASM_OBJS= -COMPONENT=cfs_util.o -INTERFACES= -DEPENDENCIES=cFE -IF_LIB:=./cFE_cfs_utils.o -ADDITIONAL_LIBS=-lcos_kernel_api - -include ../../Makefile.subsubdir -MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/ds/Makefile b/src/components/implementation/no_interface/ds/Makefile index 6ed41699e4..8449cb5385 100644 --- a/src/components/implementation/no_interface/ds/Makefile +++ b/src/components/implementation/no_interface/ds/Makefile @@ -3,7 +3,7 @@ ASM_OBJS= COMPONENT=ds_app.o INTERFACES= DEPENDENCIES=cFE capmgr -IF_LIB:=./cFE_ds_app.o ./cFE_ds_cmds.o ./cFE_ds_file.o ./cFE_ds_table.o +IF_LIB:=./cFE_ds_app.o ./cFE_ds_cmds.o ./cFE_ds_file.o ./cFE_ds_table.o ./cFE_cfs_utils.o ADDITIONAL_LIBS=-lcos_kernel_api include ../../Makefile.subsubdir diff --git a/src/components/implementation/no_interface/fm/Makefile b/src/components/implementation/no_interface/fm/Makefile index 9a0dd0b059..de55f449a2 100644 --- a/src/components/implementation/no_interface/fm/Makefile +++ b/src/components/implementation/no_interface/fm/Makefile @@ -2,8 +2,8 @@ ASM_OBJS= COMPONENT=fm_app.o INTERFACES= -DEPENDENCIES=cFE -IF_LIB:=./cFE_fm_app.o ./cFE_fm_child.o ./cFE_fm_cmds.o ./cFE_fm_cmd_utils.o cFE_fm_tbl.o +DEPENDENCIES=cFE capmgr +IF_LIB:=./cFE_fm_app.o ./cFE_fm_child.o ./cFE_fm_cmds.o ./cFE_fm_cmd_utils.o cFE_fm_tbl.o ./cFE_cfs_utils.o ADDITIONAL_LIBS=-lcos_kernel_api include ../../Makefile.subsubdir diff --git a/src/components/implementation/no_interface/hs/Makefile b/src/components/implementation/no_interface/hs/Makefile index 3525a3e6b5..e04437ad01 100644 --- a/src/components/implementation/no_interface/hs/Makefile +++ b/src/components/implementation/no_interface/hs/Makefile @@ -2,7 +2,7 @@ ASM_OBJS= COMPONENT=hs_app.o INTERFACES= -DEPENDENCIES=cFE +DEPENDENCIES=cFE capmgr IF_LIB:=./cFE_hs_app.o ./cFE_hs_cmds.o ./cFE_hs_custom.o ./cFE_hs_monitors.o ADDITIONAL_LIBS=-lcos_kernel_api diff --git a/src/components/implementation/no_interface/mm/Makefile b/src/components/implementation/no_interface/mm/Makefile index 0eeef67b8b..4e93fdf4c2 100644 --- a/src/components/implementation/no_interface/mm/Makefile +++ b/src/components/implementation/no_interface/mm/Makefile @@ -2,8 +2,8 @@ ASM_OBJS= COMPONENT=mm_app.o INTERFACES= -DEPENDENCIES=cFE -IF_LIB:=./cFE_mm_app.o ./cFE_mm_dump.o ./cFE_mm_load.o cFE_mm_mem16.o ./cFE_mm_mem32 ./cFE_mm_mem8.o ./cFE_mm_utils.o +DEPENDENCIES=cFE capmgr +IF_LIB:=./cFE_mm_app.o ./cFE_mm_dump.o ./cFE_mm_load.o ./cFE_mm_mem16.o ./cFE_mm_mem32.o ./cFE_mm_mem8.o ./cFE_mm_utils.o ./cFE_cfs_utils.o ADDITIONAL_LIBS=-lcos_kernel_api include ../../Makefile.subsubdir diff --git a/src/components/implementation/no_interface/sample_app/Makefile b/src/components/implementation/no_interface/sample_app/Makefile deleted file mode 100644 index b8b0f29a9f..0000000000 --- a/src/components/implementation/no_interface/sample_app/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c -ASM_OBJS= -COMPONENT=sample_app.o -INTERFACES= -DEPENDENCIES=cFE capmgr -IF_LIB:=./cFE_sample_app.o -ADDITIONAL_LIBS=-lcos_kernel_api - -include ../../Makefile.subsubdir -MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/sample_app/init.c b/src/components/implementation/no_interface/sample_app/init.c deleted file mode 100644 index 4b87b8ed03..0000000000 --- a/src/components/implementation/no_interface/sample_app/init.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -#include - -extern void SAMPLE_AppMain(); -extern void OS_IdleLoop(); -extern void do_emulation_setup(spdid_t id); - -void cos_init(void) -{ - do_emulation_setup(cos_comp_info.cos_this_spd_id); - printc("Starting app main\n"); - SAMPLE_AppMain(); - printc("Ending app main\n"); - while(1) OS_IdleLoop(); -} diff --git a/src/components/implementation/no_interface/sample_lib/Makefile b/src/components/implementation/no_interface/sample_lib/Makefile deleted file mode 100644 index 93af46b2e3..0000000000 --- a/src/components/implementation/no_interface/sample_lib/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c -ASM_OBJS= -COMPONENT=sample_lib.o -INTERFACES= -DEPENDENCIES=cFE capmgr -IF_LIB:=./cFE_sample_lib.o -ADDITIONAL_LIBS=-lcos_kernel_api - -include ../../Makefile.subsubdir -MANDITORY_LIB=simple_stklib.o diff --git a/src/components/implementation/no_interface/sample_lib/init.c b/src/components/implementation/no_interface/sample_lib/init.c deleted file mode 100644 index e775f717e9..0000000000 --- a/src/components/implementation/no_interface/sample_lib/init.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -#include - -extern void SAMPLE_LibInit(); -extern void OS_IdleLoop(); -extern void do_emulation_setup(spdid_t id); - -void cos_init(void) -{ - do_emulation_setup(cos_comp_info.cos_this_spd_id); - printc("Starting lib init\n"); - SAMPLE_LibInit(); - printc("Ending lib init\n"); - while(1) OS_IdleLoop(); -} diff --git a/src/components/implementation/no_interface/sc/Makefile b/src/components/implementation/no_interface/sc/Makefile index 3b6f43f6b8..18fa10337d 100644 --- a/src/components/implementation/no_interface/sc/Makefile +++ b/src/components/implementation/no_interface/sc/Makefile @@ -2,7 +2,7 @@ ASM_OBJS= COMPONENT=sc_app.o INTERFACES= -DEPENDENCIES=cFE +DEPENDENCIES=cFE capmgr IF_LIB:=./cFE_sc_app.o ./cFE_sc_atsrq.o ./cFE_sc_cmds.o ./cFE_sc_loads.o ./cFE_sc_rtsrq.o ./cFE_sc_state.o ./cFE_sc_utils.o ADDITIONAL_LIBS=-lcos_kernel_api diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index a0785fd8e4..dc24cef028 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -50,6 +50,7 @@ cos_asm_server_stub(OS_TaskDelay) // FS methods // Relies on the assumption that dirp_t are never dereferenced outside the cFE cos_asm_server_stub(OS_closedir) +cos_asm_server_stub(OS_close) cos_asm_server_stub(OS_lseek) cos_asm_server_stub(OS_rewinddir) diff --git a/src/extern/cFE b/src/extern/cFE index 35d2ed699c..9a64b21c3a 160000 --- a/src/extern/cFE +++ b/src/extern/cFE @@ -1 +1 @@ -Subproject commit 35d2ed699ca975fc804d69feca2042367d11f1e0 +Subproject commit 9a64b21c3aff917681056c960c0d817ab90541e8 From 51051c8bb2f761d04219a2332bcb7b5318c8010f Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Mon, 23 Apr 2018 19:32:16 -0400 Subject: [PATCH 119/122] Make open sat kit apps run on the system --- .../no_interface/cFE_booter/cFE_emu_support.c | 6 ++ .../no_interface/cFE_booter/osloader.c | 50 +++++++++--- .../implementation/no_interface/ds/Makefile | 2 +- .../implementation/no_interface/ds/init.c | 16 ++++ .../implementation/no_interface/fm/Makefile | 2 +- .../implementation/no_interface/fm/init.c | 16 ++++ .../implementation/no_interface/hs/Makefile | 2 +- .../implementation/no_interface/hs/init.c | 16 ++++ .../implementation/no_interface/mm/Makefile | 2 +- .../implementation/no_interface/mm/init.c | 16 ++++ .../implementation/no_interface/sc/Makefile | 2 +- .../implementation/no_interface/sc/init.c | 16 ++++ .../no_interface/sch_lab/init.c | 4 +- src/components/interface/cFE/cFE_emu.h | 10 ++- src/components/interface/cFE/stubs/c_stub.c | 81 +++++++++++++++++++ src/components/interface/cFE/stubs/s_stub.S | 10 +++ src/extern/cFE | 2 +- src/platform/i386/runscripts/llboot_cFE.sh | 3 +- 18 files changed, 236 insertions(+), 20 deletions(-) create mode 100644 src/components/implementation/no_interface/ds/init.c create mode 100644 src/components/implementation/no_interface/fm/init.c create mode 100644 src/components/implementation/no_interface/hs/init.c create mode 100644 src/components/implementation/no_interface/mm/init.c create mode 100644 src/components/implementation/no_interface/sc/init.c diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c index fe91f35cdf..7d7610f906 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -218,6 +218,12 @@ emu_CFE_FS_Decompress(spdid_t client) return CFE_FS_Decompress(s->cfe_fs_decompress.SourceFile, s->cfe_fs_decompress.DestinationFile); } +int32 +emu_CFE_FS_ReadHeader(spdid_t client) +{ + union shared_region *s = shared_regions[client]; + return CFE_FS_ReadHeader(&s->cfe_fs_writeHeader.Hdr, s->cfe_fs_writeHeader.FileDes); +} int32 emu_CFE_FS_WriteHeader(spdid_t client) diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index 6076b6e95b..30b1aa8bae 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -70,35 +70,66 @@ launch_other_component(int child_id, int is_library) // 1) Do all the cFE stuff // 2) Create a component from the app // 3) Add an init routine in the component -// 4) Add a proxy here +// 4) Add a proxy here (sensitive to runscript changes) void -sample_lib_proxy() +ds_proxy() { - launch_other_component(1, 1); + launch_other_component(1, 0); } void -sample_app_proxy() +fm_proxy() { launch_other_component(3, 0); } void -sch_lab_proxy() +hs_proxy() +{ + launch_other_component(6, 0); +} + +void +mm_proxy() +{ + launch_other_component(7, 0); +} + +void +sc_proxy() { launch_other_component(5, 0); } +void +shc_lab_proxy() +{ + launch_other_component(8, 0); +} + +int32 +cfs_lib_proxy() +{ + /* This is a total fake! CFS Lib doesn't do useful initialization... */ + OS_printf("CFS Lib Initialized. Version [FAKE INITIALIZTION]"); + + return OS_SUCCESS; +} + struct symbol_proxy { char *symbol_name; void *proxy; }; -#define NUM_PROXIES 3 -struct symbol_proxy proxies[NUM_PROXIES] = {{"SAMPLE_LibInit", sample_lib_proxy}, - {"SAMPLE_AppMain", sample_app_proxy}, - {"SCH_Lab_AppMain", sch_lab_proxy}}; +#define NUM_PROXIES 7 +struct symbol_proxy proxies[NUM_PROXIES] = {{"DS_AppMain", ds_proxy}, + {"FM_AppMain", fm_proxy}, + {"HS_AppMain", hs_proxy}, + {"MM_AppMain", mm_proxy}, + {"SC_AppMain", sc_proxy}, + {"SCH_Lab_AppMain", shc_lab_proxy}, + {"CFS_LibInit", cfs_lib_proxy}}; int32 OS_SymbolLookup(cpuaddr *symbol_address, const char *symbol_name) @@ -123,5 +154,6 @@ int32 OS_SymbolTableDump(const char *filename, uint32 size_limit) { /* Not needed. */ + assert(0); return OS_ERR_NOT_IMPLEMENTED; } diff --git a/src/components/implementation/no_interface/ds/Makefile b/src/components/implementation/no_interface/ds/Makefile index 8449cb5385..db9fa3b9dc 100644 --- a/src/components/implementation/no_interface/ds/Makefile +++ b/src/components/implementation/no_interface/ds/Makefile @@ -1,6 +1,6 @@ # C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c ASM_OBJS= -COMPONENT=ds_app.o +COMPONENT=ds.o INTERFACES= DEPENDENCIES=cFE capmgr IF_LIB:=./cFE_ds_app.o ./cFE_ds_cmds.o ./cFE_ds_file.o ./cFE_ds_table.o ./cFE_cfs_utils.o diff --git a/src/components/implementation/no_interface/ds/init.c b/src/components/implementation/no_interface/ds/init.c new file mode 100644 index 0000000000..fe22a95473 --- /dev/null +++ b/src/components/implementation/no_interface/ds/init.c @@ -0,0 +1,16 @@ +#include +#include +#include + +extern void DS_AppMain(); +extern void OS_IdleLoop(); +extern void do_emulation_setup(spdid_t id); + +void cos_init(void) +{ + do_emulation_setup(cos_comp_info.cos_this_spd_id); + printc("Starting DS main\n"); + DS_AppMain(); + printc("Ending DS main\n"); + while(1) OS_IdleLoop(); +} diff --git a/src/components/implementation/no_interface/fm/Makefile b/src/components/implementation/no_interface/fm/Makefile index de55f449a2..80d96fb94c 100644 --- a/src/components/implementation/no_interface/fm/Makefile +++ b/src/components/implementation/no_interface/fm/Makefile @@ -1,6 +1,6 @@ # C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c ASM_OBJS= -COMPONENT=fm_app.o +COMPONENT=fm.o INTERFACES= DEPENDENCIES=cFE capmgr IF_LIB:=./cFE_fm_app.o ./cFE_fm_child.o ./cFE_fm_cmds.o ./cFE_fm_cmd_utils.o cFE_fm_tbl.o ./cFE_cfs_utils.o diff --git a/src/components/implementation/no_interface/fm/init.c b/src/components/implementation/no_interface/fm/init.c new file mode 100644 index 0000000000..9b120e2b16 --- /dev/null +++ b/src/components/implementation/no_interface/fm/init.c @@ -0,0 +1,16 @@ +#include +#include +#include + +extern void FM_AppMain(); +extern void OS_IdleLoop(); +extern void do_emulation_setup(spdid_t id); + +void cos_init(void) +{ + do_emulation_setup(cos_comp_info.cos_this_spd_id); + printc("Starting FM main\n"); + FM_AppMain(); + printc("Ending FM main\n"); + while(1) OS_IdleLoop(); +} diff --git a/src/components/implementation/no_interface/hs/Makefile b/src/components/implementation/no_interface/hs/Makefile index e04437ad01..b448701611 100644 --- a/src/components/implementation/no_interface/hs/Makefile +++ b/src/components/implementation/no_interface/hs/Makefile @@ -1,6 +1,6 @@ # C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c ASM_OBJS= -COMPONENT=hs_app.o +COMPONENT=hs.o INTERFACES= DEPENDENCIES=cFE capmgr IF_LIB:=./cFE_hs_app.o ./cFE_hs_cmds.o ./cFE_hs_custom.o ./cFE_hs_monitors.o diff --git a/src/components/implementation/no_interface/hs/init.c b/src/components/implementation/no_interface/hs/init.c new file mode 100644 index 0000000000..617a615b4c --- /dev/null +++ b/src/components/implementation/no_interface/hs/init.c @@ -0,0 +1,16 @@ +#include +#include +#include + +extern void HS_AppMain(); +extern void OS_IdleLoop(); +extern void do_emulation_setup(spdid_t id); + +void cos_init(void) +{ + do_emulation_setup(cos_comp_info.cos_this_spd_id); + printc("Starting HS main\n"); + HS_AppMain(); + printc("Ending HS main\n"); + while(1) OS_IdleLoop(); +} diff --git a/src/components/implementation/no_interface/mm/Makefile b/src/components/implementation/no_interface/mm/Makefile index 4e93fdf4c2..a5e068bf4d 100644 --- a/src/components/implementation/no_interface/mm/Makefile +++ b/src/components/implementation/no_interface/mm/Makefile @@ -1,6 +1,6 @@ # C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c ASM_OBJS= -COMPONENT=mm_app.o +COMPONENT=mm.o INTERFACES= DEPENDENCIES=cFE capmgr IF_LIB:=./cFE_mm_app.o ./cFE_mm_dump.o ./cFE_mm_load.o ./cFE_mm_mem16.o ./cFE_mm_mem32.o ./cFE_mm_mem8.o ./cFE_mm_utils.o ./cFE_cfs_utils.o diff --git a/src/components/implementation/no_interface/mm/init.c b/src/components/implementation/no_interface/mm/init.c new file mode 100644 index 0000000000..6252308eb2 --- /dev/null +++ b/src/components/implementation/no_interface/mm/init.c @@ -0,0 +1,16 @@ +#include +#include +#include + +extern void MM_AppMain(); +extern void OS_IdleLoop(); +extern void do_emulation_setup(spdid_t id); + +void cos_init(void) +{ + do_emulation_setup(cos_comp_info.cos_this_spd_id); + printc("Starting MM main\n"); + MM_AppMain(); + printc("Ending MM main\n"); + while(1) OS_IdleLoop(); +} diff --git a/src/components/implementation/no_interface/sc/Makefile b/src/components/implementation/no_interface/sc/Makefile index 18fa10337d..97b8d7617b 100644 --- a/src/components/implementation/no_interface/sc/Makefile +++ b/src/components/implementation/no_interface/sc/Makefile @@ -1,6 +1,6 @@ # C_OBJS=cFE_entrypoint.o cFE_stub.o osapi.o osfiles.o osloader.o osqueue.o ostask.o ostimer.o osnetwork.o psp.o scheddev/sl.c scheddev/sl_mod_fprr.c ASM_OBJS= -COMPONENT=sc_app.o +COMPONENT=sc.o INTERFACES= DEPENDENCIES=cFE capmgr IF_LIB:=./cFE_sc_app.o ./cFE_sc_atsrq.o ./cFE_sc_cmds.o ./cFE_sc_loads.o ./cFE_sc_rtsrq.o ./cFE_sc_state.o ./cFE_sc_utils.o diff --git a/src/components/implementation/no_interface/sc/init.c b/src/components/implementation/no_interface/sc/init.c new file mode 100644 index 0000000000..298e74ac3a --- /dev/null +++ b/src/components/implementation/no_interface/sc/init.c @@ -0,0 +1,16 @@ +#include +#include +#include + +extern void SC_AppMain(); +extern void OS_IdleLoop(); +extern void do_emulation_setup(spdid_t id); + +void cos_init(void) +{ + do_emulation_setup(cos_comp_info.cos_this_spd_id); + printc("Starting SC main\n"); + SC_AppMain(); + printc("Ending SC main\n"); + while(1) OS_IdleLoop(); +} diff --git a/src/components/implementation/no_interface/sch_lab/init.c b/src/components/implementation/no_interface/sch_lab/init.c index 837b85f3fb..d530f10959 100644 --- a/src/components/implementation/no_interface/sch_lab/init.c +++ b/src/components/implementation/no_interface/sch_lab/init.c @@ -9,8 +9,8 @@ extern void do_emulation_setup(spdid_t id); void cos_init(void) { do_emulation_setup(cos_comp_info.cos_this_spd_id); - printc("Starting sch main\n"); + printc("Starting SCH_LAB main\n"); SCH_Lab_AppMain(); - printc("Ending sch main\n"); + printc("Ending SCH_LAB main\n"); while(1) OS_IdleLoop(); } diff --git a/src/components/interface/cFE/cFE_emu.h b/src/components/interface/cFE/cFE_emu.h index ea83c57d4e..b1eac8044f 100644 --- a/src/components/interface/cFE/cFE_emu.h +++ b/src/components/interface/cFE/cFE_emu.h @@ -11,7 +11,7 @@ #include #include -#define EMU_BUF_SIZE 512 +#define EMU_BUF_SIZE 1024 /* TODO: Alphabetize me! */ union shared_region { @@ -237,11 +237,14 @@ union shared_region { CFE_TBL_Info_t TblInfo; char TblName[EMU_BUF_SIZE]; } cfe_tbl_getInfo; + struct { + int32 FileDes; + CFE_FS_Header_t Hdr; + } cfe_fs_readHeader; }; int emu_request_memory(spdid_t client); void emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_aepkey_t key); -int emu_is_printf_enabled(); #define STASH_MAGIC_VALUE ((void *)0xBEAFBEAF) @@ -250,6 +253,8 @@ thdclosure_index_t emu_stash_retrieve_thdclosure(); spdid_t emu_stash_retrieve_spdid(); void emu_stash_clear(); +int emu_is_printf_enabled(); + int32 emu_CFE_ES_CalculateCRC(spdid_t client); int32 emu_CFE_ES_CopyToCDS(spdid_t client); int32 emu_CFE_ES_CreateChildTask(spdid_t client); @@ -268,6 +273,7 @@ int32 emu_CFE_EVS_Register(spdid_t sp); int32 emu_CFE_EVS_SendEvent(spdid_t client); int32 emu_CFE_FS_Decompress(spdid_t client); +int32 emu_CFE_FS_ReadHeader(spdid_t client); int32 emu_CFE_FS_WriteHeader(spdid_t client); int32 emu_CFE_SB_CreatePipe(spdid_t client); diff --git a/src/components/interface/cFE/stubs/c_stub.c b/src/components/interface/cFE/stubs/c_stub.c index 4970c50ecc..472001654d 100644 --- a/src/components/interface/cFE/stubs/c_stub.c +++ b/src/components/interface/cFE/stubs/c_stub.c @@ -39,6 +39,9 @@ do_emulation_setup(spdid_t id) shared_region = (void *)client_addr; time_sync_key = BASE_AEP_KEY + id; + + /* End with a quick consistency check */ + assert(sizeof(union shared_region) <= PAGE_SIZE); } void @@ -304,6 +307,19 @@ CFE_FS_Decompress(const char *SourceFile, const char *DestinationFile) return emu_CFE_FS_Decompress(spdid); } +int32 +CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, int32 FileDes) +{ + int32 result; + + shared_region->cfe_fs_readHeader.FileDes = FileDes; + + result = emu_CFE_FS_ReadHeader(spdid); + *Hdr = shared_region->cfe_fs_readHeader.Hdr; + + return result; +} + int32 CFE_FS_WriteHeader(int32 FileDes, CFE_FS_Header_t *Hdr) { @@ -321,6 +337,38 @@ CFE_PSP_MemCpy(void *dest, void *src, uint32 n) return CFE_PSP_SUCCESS; } +int32 +CFE_PSP_MemRead8(cpuaddr MemoryAddress, uint8 *ByteValue) +{ + + *ByteValue = *((uint8 *)MemoryAddress) ; + + return CFE_PSP_SUCCESS; +} + +int32 +CFE_PSP_MemRead16(cpuaddr MemoryAddress, uint16 *uint16Value) +{ + /* check 16 bit alignment */ + if (MemoryAddress & 0x00000001) { + return CFE_PSP_ERROR_ADDRESS_MISALIGNED; + } + *uint16Value = *((uint16 *)MemoryAddress) ; + return CFE_PSP_SUCCESS; +} + +int32 +CFE_PSP_MemRead32(cpuaddr MemoryAddress, uint32 *uint32Value) +{ + /* check 32 bit alignment */ + if (MemoryAddress & 0x00000003) { + return CFE_PSP_ERROR_ADDRESS_MISALIGNED; + } + *uint32Value = *((uint32 *)MemoryAddress); + + return CFE_PSP_SUCCESS; +} + int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n) { @@ -328,6 +376,39 @@ CFE_PSP_MemSet(void *dest, uint8 value, uint32 n) return CFE_PSP_SUCCESS; } + +int32 +CFE_PSP_MemWrite8(cpuaddr MemoryAddress, uint8 ByteValue) +{ + *((uint8 *)MemoryAddress) = ByteValue; + return CFE_PSP_SUCCESS; + +} + +int32 +CFE_PSP_MemWrite16(cpuaddr MemoryAddress, uint16 uint16Value ) +{ + /* check 16 bit alignment , check the 1st lsb */ + if (MemoryAddress & 0x00000001) { + return CFE_PSP_ERROR_ADDRESS_MISALIGNED; + } + *((uint16 *)MemoryAddress) = uint16Value; + return CFE_PSP_SUCCESS; +} + +int32 +CFE_PSP_MemWrite32(cpuaddr MemoryAddress, uint32 uint32Value) +{ + /* check 32 bit alignment */ + if (MemoryAddress & 0x00000003) { + return CFE_PSP_ERROR_ADDRESS_MISALIGNED; + } + + *((uint32 *)MemoryAddress) = uint32Value; + + return CFE_PSP_SUCCESS; +} + int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *PipeName) { diff --git a/src/components/interface/cFE/stubs/s_stub.S b/src/components/interface/cFE/stubs/s_stub.S index dc24cef028..f1def0cce7 100644 --- a/src/components/interface/cFE/stubs/s_stub.S +++ b/src/components/interface/cFE/stubs/s_stub.S @@ -21,6 +21,12 @@ cos_asm_server_stub(CFE_ES_ResetCFE) cos_asm_server_stub(CFE_ES_RestartApp) cos_asm_server_stub(CFE_ES_WaitForStartupSync) +cos_asm_server_stub(CFE_PSP_EepromWriteEnable) +cos_asm_server_stub(CFE_PSP_EepromWriteDisable) +cos_asm_server_stub(CFE_PSP_EepromWrite8) +cos_asm_server_stub(CFE_PSP_EepromWrite16) +cos_asm_server_stub(CFE_PSP_EepromWrite32) +cos_asm_server_stub(CFE_PSP_MemValidateRange) cos_asm_server_stub(CFE_PSP_WatchdogDisable) cos_asm_server_stub(CFE_PSP_WatchdogEnable) cos_asm_server_stub(CFE_PSP_WatchdogSet) @@ -43,8 +49,11 @@ cos_asm_server_stub(CFE_TIME_FS2CFESeconds) cos_asm_server_stub(OS_CountSemGive) cos_asm_server_stub(OS_CountSemTake) cos_asm_server_stub(OS_IdleLoop) +cos_asm_server_stub(OS_IntLock) +cos_asm_server_stub(OS_IntUnlock) cos_asm_server_stub(OS_MutSemGive) cos_asm_server_stub(OS_MutSemTake) +cos_asm_server_stub(OS_SymbolTableDump) cos_asm_server_stub(OS_TaskDelay) // FS methods @@ -80,6 +89,7 @@ cos_asm_server_stub(emu_CFE_EVS_Register) cos_asm_server_stub(emu_CFE_EVS_SendEvent) cos_asm_server_stub(emu_CFE_FS_Decompress) +cos_asm_server_stub(emu_CFE_FS_ReadHeader) cos_asm_server_stub(emu_CFE_FS_WriteHeader) cos_asm_server_stub(emu_CFE_SB_CreatePipe) diff --git a/src/extern/cFE b/src/extern/cFE index 9a64b21c3a..3b5f706597 160000 --- a/src/extern/cFE +++ b/src/extern/cFE @@ -1 +1 @@ -Subproject commit 9a64b21c3aff917681056c960c0d817ab90541e8 +Subproject commit 3b5f7065974572de03f6b40f92eff440cbc608b9 diff --git a/src/platform/i386/runscripts/llboot_cFE.sh b/src/platform/i386/runscripts/llboot_cFE.sh index b53f6a3f16..1c731f431f 100644 --- a/src/platform/i386/runscripts/llboot_cFE.sh +++ b/src/platform/i386/runscripts/llboot_cFE.sh @@ -4,4 +4,5 @@ cp llboot_comp.o llboot.o cp cFE_booter.o boot.o -./cos_linker 'llboot.o, ;sample_lib.o, ;capmgr.o, ;sample_app.o, ;*boot.o, ;sch_lab.o, :boot.o-capmgr.o;sample_app.o-boot.o;sample_lib.o-boot.o;sch_lab.o-boot.o;sample_app.o-capmgr.o;sample_lib.o-capmgr.o;sch_lab.o-capmgr.o' ./gen_client_stub +# ds fm sc hs mm +./cos_linker 'llboot.o, ;ds.o, ;capmgr.o, ;fm.o, ;*boot.o, ;sc.o, ;hs.o, ;mm.o, ;sch_lab.o, :boot.o-capmgr.o;ds.o-boot.o;fm.o-boot.o;sc.o-boot.o;hs.o-boot.o;mm.o-boot.o;sch_lab.o-boot.o;ds.o-capmgr.o;fm.o-capmgr.o;sc.o-capmgr.o;hs.o-capmgr.o;mm.o-capmgr.o;sch_lab.o-capmgr.o' ./gen_client_stub From 6d5c47fdcb87070a1d2b550b56c75a7ad9c1df66 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Tue, 24 Apr 2018 17:17:20 -0400 Subject: [PATCH 120/122] Expand cFE_booter functionality for newly created apps --- .../no_interface/cFE_booter/cFE_emu_support.c | 9 +- .../no_interface/cFE_booter/cFE_util.c | 2 +- .../no_interface/cFE_booter/ostask.c | 5 +- .../no_interface/cFE_booter/ostimer.c | 56 +++--- .../no_interface/cFE_booter/psp.c | 166 +++++++++++++----- src/components/interface/cFE/cFE_emu.h | 11 +- src/components/interface/cFE/stubs/c_stub.c | 26 ++- src/extern/cFE | 2 +- 8 files changed, 184 insertions(+), 93 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c index 7d7610f906..c8350545ac 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -35,7 +35,7 @@ int emu_request_memory(spdid_t client) { vaddr_t our_addr = 0; - int id = memmgr_shared_page_alloc(&our_addr); + int id = memmgr_shared_page_allocn(SHARED_REGION_NUM_PAGES, &our_addr); assert(our_addr); shared_regions[client] = (void *)our_addr; @@ -49,20 +49,23 @@ emu_request_memory(spdid_t client) return id; } -void +arcvcap_t emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_aepkey_t key) { struct sl_thd * thd; sched_param_t aep_priority; struct cos_defcompinfo child_dci; + arcvcap_t extrcv; cos_defcompinfo_childid_init(&child_dci, client); - thd = sl_thd_aep_alloc_ext(&child_dci, NULL, idx, 1, 0, key, NULL); + thd = sl_thd_aep_alloc_ext(&child_dci, NULL, idx, 1, 0, key, &extrcv); assert(thd); aep_priority = sched_param_pack(SCHEDP_PRIO, CFE_TIME_1HZ_TASK_PRIORITY); sl_thd_param_set(thd, aep_priority); + + return extrcv; } /* Methods for stashing and retrieving a idx, spdid pair diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.c b/src/components/implementation/no_interface/cFE_booter/cFE_util.c index 1cdb29f917..080b7b755d 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.c @@ -19,7 +19,7 @@ llprint(const char *s, int len) void panic_impl(const char *function, char *message) { - printc("cFE panic in %s: %s", function, message); + printc("cFE panic in %s: %s\n", function, message); assert(0); } diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index a12bc625ed..b2e7c9b6e1 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -161,10 +161,13 @@ int32 OS_TaskDelete(uint32 task_id) { struct cfe_task_info *task_info; - struct sl_thd * thd = sl_thd_lkup(task_id); + struct sl_thd * thd; osal_task_entry delete_handler; + thd = sl_thd_lkup(task_id); if (!thd) { return OS_ERR_INVALID_ID; } + /* FIXME: Need to handle the deletion of a thread pretending to be another thread */ + if (thd->state == SL_THD_FREE) { return OS_SUCCESS; } task_info = &cfe_tasks[task_id]; diff --git a/src/components/implementation/no_interface/cFE_booter/ostimer.c b/src/components/implementation/no_interface/cFE_booter/ostimer.c index 143e17df23..3dfc4b57bb 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostimer.c +++ b/src/components/implementation/no_interface/cFE_booter/ostimer.c @@ -7,6 +7,11 @@ ** Timer API */ +struct { + int used; + OS_timer_prop_t props; +} timers[OS_MAX_TIMERS]; + int32 OS_TimerAPIInit(void) { @@ -16,70 +21,69 @@ OS_TimerAPIInit(void) /* TODO: Verify this API really insn't necessary */ int32 -OS_TimeBaseCreate(uint32 *timer_id, const char *timebase_name, OS_TimerSync_t external_sync) +OS_TimerCreate(uint32 *timer_id, const char *timer_name, uint32 *clock_accuracy, OS_TimerCallback_t callback_ptr) { - return OS_ERR_NOT_IMPLEMENTED; + PANIC("Unimplemented method!"); /* TODO: Implement me! */ + return 0; } int32 -OS_TimeBaseSet(uint32 timer_id, uint32 start_time, uint32 interval_time) +OS_TimerAdd(uint32 *timer_id, const char *timer_name, uint32 timebase_id, OS_ArgCallback_t callback_ptr, + void *callback_arg) { - return OS_ERR_NOT_IMPLEMENTED; + PANIC("Unimplemented method!"); /* TODO: Implement me! */ + return 0; } int32 -OS_TimeBaseDelete(uint32 timer_id) +OS_TimerSet(uint32 timer_id, uint32 start_time, uint32 interval_time) { - return OS_ERR_NOT_IMPLEMENTED; + PANIC("Unimplemented method!"); /* TODO: Implement me! */ + return 0; } int32 -OS_TimeBaseGetIdByName(uint32 *timer_id, const char *timebase_name) +OS_TimerDelete(uint32 timer_id) { - return OS_ERR_NOT_IMPLEMENTED; + PANIC("Unimplemented method!"); /* TODO: Implement me! */ + return 0; } int32 -OS_TimerCreate(uint32 *timer_id, const char *timer_name, uint32 *clock_accuracy, OS_TimerCallback_t callback_ptr) +OS_TimerGetIdByName(uint32 *timer_id, const char *timer_name) { PANIC("Unimplemented method!"); /* TODO: Implement me! */ return 0; } int32 -OS_TimerAdd(uint32 *timer_id, const char *timer_name, uint32 timebase_id, OS_ArgCallback_t callback_ptr, - void *callback_arg) +OS_TimerGetInfo(uint32 timer_id, OS_timer_prop_t *timer_prop) { - PANIC("Unimplemented method!"); /* TODO: Implement me! */ - return 0; + return OS_ERR_NAME_NOT_FOUND; } +/* We don't implement the TimeBase API */ int32 -OS_TimerSet(uint32 timer_id, uint32 start_time, uint32 interval_time) +OS_TimeBaseCreate(uint32 *timer_id, const char *timebase_name, OS_TimerSync_t external_sync) { - PANIC("Unimplemented method!"); /* TODO: Implement me! */ - return 0; + return OS_ERR_NOT_IMPLEMENTED; } int32 -OS_TimerDelete(uint32 timer_id) +OS_TimeBaseSet(uint32 timer_id, uint32 start_time, uint32 interval_time) { - PANIC("Unimplemented method!"); /* TODO: Implement me! */ - return 0; + return OS_ERR_NOT_IMPLEMENTED; } - int32 -OS_TimerGetIdByName(uint32 *timer_id, const char *timer_name) +OS_TimeBaseDelete(uint32 timer_id) { - PANIC("Unimplemented method!"); /* TODO: Implement me! */ - return 0; + return OS_ERR_NOT_IMPLEMENTED; } int32 -OS_TimerGetInfo(uint32 timer_id, OS_timer_prop_t *timer_prop) +OS_TimeBaseGetIdByName(uint32 *timer_id, const char *timebase_name) { - PANIC("Unimplemented method!"); /* TODO: Implement me! */ - return 0; + return OS_ERR_NOT_IMPLEMENTED; } diff --git a/src/components/implementation/no_interface/cFE_booter/psp.c b/src/components/implementation/no_interface/cFE_booter/psp.c index c3c74f348f..6dfa64e119 100644 --- a/src/components/implementation/no_interface/cFE_booter/psp.c +++ b/src/components/implementation/no_interface/cFE_booter/psp.c @@ -288,61 +288,131 @@ CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFESegment * CFE_PSP_GetCFETextSegmentInfo returns the location and size of the kernel memory. */ -void -CFE_PSP_WatchdogInit(void) -{ - PANIC("Unimplemented method!"); /* TODO: Implement me! */ -} -/* - * CFE_PSP_WatchdogInit configures the watchdog timer. - */ -void -CFE_PSP_WatchdogEnable(void) -{ - PANIC("Unimplemented method!"); /* TODO: Implement me! */ -} -/* - * CFE_PSP_WatchdogEnable enables the watchdog timer. - */ +/* FIXME: The watchdog never actually triggers */ -void -CFE_PSP_WatchdogDisable(void) -{ - PANIC("Unimplemented method!"); /* TODO: Implement me! */ -} /* - * CFE_PSP_WatchdogDisable disables the watchdog timer. - */ - -void -CFE_PSP_WatchdogService(void) +** The watchdog time in milliseconds +*/ +uint32 CFE_PSP_WatchdogValue = CFE_PSP_WATCHDOG_MAX; + +/* Function: CFE_PSP_WatchdogInit() +** +** Purpose: +** To setup the timer resolution and/or other settings custom to this platform. +** +** Arguments: +** +** Return: +*/ +void CFE_PSP_WatchdogInit(void) { - PANIC("Unimplemented method!"); /* TODO: Implement me! */ -} -/* - * CFE_PSP_WatchdogService services the watchdog timer according to the - * value set in WatchDogSet. - */ -uint32 -CFE_PSP_WatchdogGet(void) -{ - PANIC("Unimplemented method!"); /* TODO: Implement me! */ - return 0; -} -/* - * CFE_PSP_WatchdogGet gets the watchdog time in milliseconds - */ + /* + ** Just set it to a value right now + ** The pc-linux desktop platform does not actually implement a watchdog + ** timeout ( but could with a signal ) + */ + CFE_PSP_WatchdogValue = CFE_PSP_WATCHDOG_MAX; -void -CFE_PSP_WatchdogSet(uint32 WatchdogValue) -{ - PANIC("Unimplemented method!"); /* TODO: Implement me! */ } -/* - * CFE_PSP_WatchdogSet sets the watchdog time in milliseconds - */ + + + /****************************************************************************** + ** Function: CFE_PSP_WatchdogEnable() + ** + ** Purpose: + ** Enable the watchdog timer + ** + ** Arguments: + ** + ** Return: + */ + void CFE_PSP_WatchdogEnable(void) + { + + } + + + /****************************************************************************** + ** Function: CFE_PSP_WatchdogDisable() + ** + ** Purpose: + ** Disable the watchdog timer + ** + ** Arguments: + ** + ** Return: + */ + void CFE_PSP_WatchdogDisable(void) + { + + } + + /****************************************************************************** + ** Function: CFE_PSP_WatchdogService() + ** + ** Purpose: + ** Load the watchdog timer with a count that corresponds to the millisecond + ** time given in the parameter. + ** + ** Arguments: + ** None. + ** + ** Return: + ** None + ** + ** Notes: + ** + */ + void CFE_PSP_WatchdogService(void) + { + + + } + + /****************************************************************************** + ** Function: CFE_PSP_WatchdogGet + ** + ** Purpose: + ** Get the current watchdog value. + ** + ** Arguments: + ** none + ** + ** Return: + ** the current watchdog value + ** + ** Notes: + ** + */ + uint32 CFE_PSP_WatchdogGet(void) + { + return(CFE_PSP_WatchdogValue); + } + + + /****************************************************************************** + ** Function: CFE_PSP_WatchdogSet + ** + ** Purpose: + ** Get the current watchdog value. + ** + ** Arguments: + ** The new watchdog value + ** + ** Return: + ** nothing + ** + ** Notes: + ** + */ + void CFE_PSP_WatchdogSet(uint32 WatchdogValue) + { + + CFE_PSP_WatchdogValue = WatchdogValue; + + } void CFE_PSP_Panic(int32 ErrorCode) diff --git a/src/components/interface/cFE/cFE_emu.h b/src/components/interface/cFE/cFE_emu.h index b1eac8044f..d20ed2d25c 100644 --- a/src/components/interface/cFE/cFE_emu.h +++ b/src/components/interface/cFE/cFE_emu.h @@ -11,7 +11,10 @@ #include #include +#define SHARED_REGION_NUM_PAGES 5 + #define EMU_BUF_SIZE 1024 +#define EMU_TBL_BUF_SIZE (4 * 4096) /* TODO: Alphabetize me! */ union shared_region { @@ -222,16 +225,16 @@ union shared_region { } cfe_tbl_register; struct { CFE_TBL_Handle_t TblHandle; - char Buffer[EMU_BUF_SIZE]; + char Buffer[EMU_TBL_BUF_SIZE]; } cfe_tbl_getAddress; struct { CFE_TBL_Handle_t TblHandle; - char Buffer[EMU_BUF_SIZE]; + char Buffer[EMU_TBL_BUF_SIZE]; } cfe_tbl_modified; struct { CFE_TBL_Handle_t TblHandle; CFE_TBL_SrcEnum_t SrcType; - char SrcData[EMU_BUF_SIZE]; + char SrcData[EMU_TBL_BUF_SIZE]; } cfe_tbl_load; struct { CFE_TBL_Info_t TblInfo; @@ -244,7 +247,7 @@ union shared_region { }; int emu_request_memory(spdid_t client); -void emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_aepkey_t key); +arcvcap_t emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_aepkey_t key); #define STASH_MAGIC_VALUE ((void *)0xBEAFBEAF) diff --git a/src/components/interface/cFE/stubs/c_stub.c b/src/components/interface/cFE/stubs/c_stub.c index 472001654d..f793076d94 100644 --- a/src/components/interface/cFE/stubs/c_stub.c +++ b/src/components/interface/cFE/stubs/c_stub.c @@ -24,6 +24,7 @@ CFE_SB_Qos_t CFE_SB_Default_Qos = {0}; size_t CDS_sizes[CFE_ES_CDS_MAX_NUM_ENTRIES] = {0}; int sync_callbacks_are_setup = 0; +arcvcap_t sync_callback_rcv = 0; CFE_TIME_SynchCallbackPtr_t sync_callbacks[CFE_TIME_MAX_NUM_SYNCH_FUNCS]; void @@ -41,16 +42,17 @@ do_emulation_setup(spdid_t id) time_sync_key = BASE_AEP_KEY + id; /* End with a quick consistency check */ - assert(sizeof(union shared_region) <= PAGE_SIZE); + assert(sizeof(union shared_region) <= SHARED_REGION_NUM_PAGES * PAGE_SIZE); } void -handle_sync_callbacks(arcvcap_t rcv, void *data) +handle_sync_callbacks(void *data) { int pending; while (1) { - pending = cos_rcv(rcv, 0, NULL); + assert(sync_callback_rcv); + pending = cos_rcv(sync_callback_rcv, 0, NULL); if (pending) { int i; for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) { @@ -66,7 +68,7 @@ ensure_sync_callbacks_are_setup() if (!sync_callbacks_are_setup) { int32 result; thdclosure_index_t idx = cos_thd_init_alloc(handle_sync_callbacks, NULL); - emu_create_aep_thread(spdid, idx, time_sync_key); + sync_callback_rcv = emu_create_aep_thread(spdid, idx, time_sync_key); result = emu_CFE_TIME_RegisterSynchCallback(time_sync_key); assert(result == CFE_SUCCESS); @@ -182,9 +184,14 @@ CFE_ES_GetGenCounterIDByName(uint32 *CounterIdPtr, const char *CounterName) int32 CFE_ES_GetResetType(uint32 *ResetSubtypePtr) { - int32 result = emu_CFE_ES_GetResetType(spdid); + int32 result; + + result = emu_CFE_ES_GetResetType(spdid); + + if (ResetSubtypePtr) { + *ResetSubtypePtr = shared_region->cfe_es_getResetType.ResetSubtype; + } - *ResetSubtypePtr = shared_region->cfe_es_getResetType.ResetSubtype; return result; } @@ -577,7 +584,7 @@ CFE_SB_ValidateChecksum(CFE_SB_MsgPtr_t MsgPtr) struct { size_t size; - char buffer[EMU_BUF_SIZE]; + char buffer[EMU_TBL_BUF_SIZE]; } table_info[CFE_TBL_MAX_NUM_HANDLES]; int32 @@ -619,7 +626,7 @@ CFE_TBL_Load(CFE_TBL_Handle_t TblHandle, CFE_TBL_SrcEnum_t SrcType, const void * shared_region->cfe_tbl_load.SrcType = SrcType; if (SrcType == CFE_TBL_SRC_FILE) { - assert(strlen(SrcDataPtr) < EMU_BUF_SIZE); + assert(strlen(SrcDataPtr) < EMU_TBL_BUF_SIZE); strcpy(shared_region->cfe_tbl_load.SrcData, SrcDataPtr); } else if (SrcType == CFE_TBL_SRC_ADDRESS) { assert(TblHandle < CFE_TBL_MAX_NUM_HANDLES); @@ -657,7 +664,7 @@ CFE_TBL_Register(CFE_TBL_Handle_t *TblHandlePtr, const char *Name, uint32 TblSiz result = emu_CFE_TBL_Register(spdid); if (result == CFE_SUCCESS || result == CFE_TBL_INFO_RECOVERED_TBL) { table_info[shared_region->cfe_tbl_register.TblHandle].size = TblSize; - assert(TblSize <= EMU_BUF_SIZE); + assert(TblSize <= EMU_TBL_BUF_SIZE); } return result; @@ -700,6 +707,7 @@ int32 CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr) { int i; + ensure_sync_callbacks_are_setup(); for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) { diff --git a/src/extern/cFE b/src/extern/cFE index 3b5f706597..6e6febcde8 160000 --- a/src/extern/cFE +++ b/src/extern/cFE @@ -1 +1 @@ -Subproject commit 3b5f7065974572de03f6b40f92eff440cbc608b9 +Subproject commit 6e6febcde8788f900e3d308161ed2bab3e973962 From caf490c219ebe9cfb3b112d5551c18db57c2eea4 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Sat, 28 Apr 2018 14:46:32 -0400 Subject: [PATCH 121/122] Fix bug in CFE_TBL_Register stub, address more PR comments --- .../no_interface/cFE_booter/cFE_util.c | 10 +------ .../no_interface/cFE_booter/cFE_util.h | 9 +------ .../no_interface/cFE_booter/osapi.c | 2 +- .../no_interface/cFE_booter/tar.c | 13 ++++++--- src/components/include/llprint.h | 27 +++++++++++++++---- src/components/interface/cFE/stubs/c_stub.c | 4 ++- src/components/lib/cos_component.c | 9 ++++--- 7 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.c b/src/components/implementation/no_interface/cFE_booter/cFE_util.c index 080b7b755d..5fab5a84c2 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.c @@ -1,21 +1,13 @@ #include #include -#include #include -#include +#include #include -#include #include "gen/osapi.h" #include "cFE_util.h" -void -llprint(const char *s, int len) -{ - call_cap(PRINT_CAP_TEMP, (int)s, len, 0, 0); -} - void panic_impl(const char *function, char *message) { diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_util.h b/src/components/implementation/no_interface/cFE_booter/cFE_util.h index 886be7b1cc..ceb5fb06dc 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_util.h +++ b/src/components/implementation/no_interface/cFE_booter/cFE_util.h @@ -6,10 +6,7 @@ #include #include -#include - -#include - +#include #include "gen/common_types.h" @@ -17,10 +14,6 @@ uint32 CFE_PSP_SpacecraftId; uint32 CFE_PSP_CpuId; -void llprint(const char *s, int len); - -int __attribute__((format(printf, 1, 2))) printc(char *fmt, ...); - #define PANIC(a) panic_impl(__func__, a) void panic_impl(const char *function, char *message); diff --git a/src/components/implementation/no_interface/cFE_booter/osapi.c b/src/components/implementation/no_interface/cFE_booter/osapi.c index 27b1a50ca0..093ce94875 100644 --- a/src/components/implementation/no_interface/cFE_booter/osapi.c +++ b/src/components/implementation/no_interface/cFE_booter/osapi.c @@ -427,7 +427,7 @@ OS_printf(const char *string, ...) va_start(arg_ptr, string); ret = vsnprintf(s, len, string, arg_ptr); va_end(arg_ptr); - llprint(s, ret); + cos_llprint(s, ret); } void diff --git a/src/components/implementation/no_interface/cFE_booter/tar.c b/src/components/implementation/no_interface/cFE_booter/tar.c index 715b83939c..e18f13dfa8 100644 --- a/src/components/implementation/no_interface/cFE_booter/tar.c +++ b/src/components/implementation/no_interface/cFE_booter/tar.c @@ -1,8 +1,10 @@ -#include "osfilesys.h" -#include "tar.h" #include + #include +#include "osfilesys.h" +#include "tar.h" + /* should be overwritten by linking step in build process */ __attribute__((weak)) char _binary_cFE_fs_tar_size = 0; __attribute__((weak)) char _binary_cFE_fs_tar_start = 0; @@ -110,6 +112,7 @@ tar_hdr_read(uint32 tar_offset, struct fsobj *file) { char * location; struct f_part *part; + uint32 file_data_offset; assert(tar_offset < tar_size); assert(file->ino > 0); @@ -123,6 +126,10 @@ tar_hdr_read(uint32 tar_offset, struct fsobj *file) location[0] = '/'; file->name = path_to_name(location); + file_data_offset = round_to_blocksize(tar_offset + 500); + + PRINT_LOG(PRINT_DEBUG, "Found file in tar: name = %s\n", file->name); + if (*(location + strlen(location) - 1) == '/') { file->type = FSOBJ_DIR; file->size = 0; @@ -130,7 +137,7 @@ tar_hdr_read(uint32 tar_offset, struct fsobj *file) file->type = FSOBJ_FILE; file->size = oct_to_dec(location + 124); file->file_part = part; - file->file_part->data = location + 500; + file->file_part->data = tar_start + file_data_offset; } return OS_FS_SUCCESS; } diff --git a/src/components/include/llprint.h b/src/components/include/llprint.h index 034fb978a3..43ab058cc4 100644 --- a/src/components/include/llprint.h +++ b/src/components/include/llprint.h @@ -40,13 +40,12 @@ printc(char *fmt, ...) typedef enum { PRINT_ERROR = 0, /* print only error messages */ - PRINT_WARN, /* print errors and warnings */ - PRINT_DEBUG /* print errors, warnings and debug messages */ + PRINT_WARN, /* print errors and warnings */ + PRINT_INFO, /* print info messages, errors, and warnings */ + PRINT_DEBUG /* print errors, warnings, info messsages, and debug messages */ } cos_print_level_t; -#ifndef PRINT_LEVEL_MAX -#define PRINT_LEVEL_MAX 3 -#endif +#define PRINT_LEVEL_COUNT 4 extern cos_print_level_t cos_print_level; extern int cos_print_lvl_str; @@ -54,6 +53,7 @@ extern const char *cos_print_str[]; /* Prints with current spdid and the thdid */ #define PRINTC(format, ...) printc("%lu,%u=> " format, cos_spd_id(), cos_thdid(), ## __VA_ARGS__) + /* Prints only if @level is <= cos_print_level */ #define PRINTLOG(level, format, ...) \ { \ @@ -63,4 +63,21 @@ extern const char *cos_print_str[]; } \ } +#define PRINT_LOG PRINTLOG + +static void +log_bytes(cos_print_level_t level, char *message, char *bytes, size_t bytes_count) +{ + if (level <= cos_print_level) { + size_t i; + + PRINT_LOG(level, "%s [ ", message); + for (i = 0; i < bytes_count; i++) { + printc("%X ", bytes[i]); + } + printc("]\n"); + } +} + + #endif /* LLPRINT_H */ diff --git a/src/components/interface/cFE/stubs/c_stub.c b/src/components/interface/cFE/stubs/c_stub.c index f793076d94..2d24d93bcf 100644 --- a/src/components/interface/cFE/stubs/c_stub.c +++ b/src/components/interface/cFE/stubs/c_stub.c @@ -663,8 +663,10 @@ CFE_TBL_Register(CFE_TBL_Handle_t *TblHandlePtr, const char *Name, uint32 TblSiz result = emu_CFE_TBL_Register(spdid); if (result == CFE_SUCCESS || result == CFE_TBL_INFO_RECOVERED_TBL) { - table_info[shared_region->cfe_tbl_register.TblHandle].size = TblSize; assert(TblSize <= EMU_TBL_BUF_SIZE); + + table_info[shared_region->cfe_tbl_register.TblHandle].size = TblSize; + *TblHandlePtr = shared_region->cfe_tbl_register.TblHandle; } return result; diff --git a/src/components/lib/cos_component.c b/src/components/lib/cos_component.c index 6d65500328..f4dba79ec3 100644 --- a/src/components/lib/cos_component.c +++ b/src/components/lib/cos_component.c @@ -117,10 +117,11 @@ cos_thd_entry_static(u32_t idx) return 0; } -const char *cos_print_str[PRINT_LEVEL_MAX] = { - "ERR:", - "WARN:", - "DBG:", +const char *cos_print_str[PRINT_LEVEL_COUNT] = { + "ERR: ", + "WARN: ", + "INFO: ", + "DBG: ", }; cos_print_level_t cos_print_level = PRINT_ERROR; From 176901cacba770e6ce3c268dc2317a5e35f042c6 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Thu, 27 Feb 2020 11:57:18 -0500 Subject: [PATCH 122/122] Fixup problems created after merge This includes a critical hypercall to advance intialization --- .../no_interface/cFE_booter/cFE_emu_support.c | 7 +++---- .../implementation/no_interface/cFE_booter/osloader.c | 2 +- .../implementation/no_interface/cFE_booter/ostask.c | 11 ++++++++--- src/components/interface/cFE/cFE_emu.h | 4 ++-- src/components/interface/cFE/stubs/c_stub.c | 2 +- src/components/lib/ps | 2 +- tools/Vagrantfile | 3 +-- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c index c8350545ac..a117fea84e 100644 --- a/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c +++ b/src/components/implementation/no_interface/cFE_booter/cFE_emu_support.c @@ -50,7 +50,7 @@ emu_request_memory(spdid_t client) } arcvcap_t -emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_aepkey_t key) +emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_channelkey_t key) { struct sl_thd * thd; sched_param_t aep_priority; @@ -58,8 +58,7 @@ emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_aepkey_t key) arcvcap_t extrcv; cos_defcompinfo_childid_init(&child_dci, client); - - thd = sl_thd_aep_alloc_ext(&child_dci, NULL, idx, 1, 0, key, &extrcv); + thd = sl_thd_aep_alloc_ext(&child_dci, NULL, idx, 1, 0, key, 0, 0, &extrcv); assert(thd); aep_priority = sched_param_pack(SCHEDP_PRIO, CFE_TIME_1HZ_TASK_PRIORITY); @@ -437,7 +436,7 @@ emu_CFE_TIME_Print(spdid_t client) } int32 -emu_CFE_TIME_RegisterSynchCallback(cos_aepkey_t key) +emu_CFE_TIME_RegisterSynchCallback(cos_channelkey_t key) { int i; for (i = 0; i < CFE_TIME_MAX_NUM_SYNCH_FUNCS; i++) { diff --git a/src/components/implementation/no_interface/cFE_booter/osloader.c b/src/components/implementation/no_interface/cFE_booter/osloader.c index 30b1aa8bae..25498bbf84 100644 --- a/src/components/implementation/no_interface/cFE_booter/osloader.c +++ b/src/components/implementation/no_interface/cFE_booter/osloader.c @@ -49,7 +49,7 @@ launch_other_component(int child_id, int is_library) struct cos_defcompinfo child_dci; cos_defcompinfo_childid_init(&child_dci, child_id); - t = sl_thd_initaep_alloc(&child_dci, NULL, 0, 0, 0); + t = sl_thd_initaep_alloc(&child_dci, NULL, 0, 0, 0, 0, 0); /* We need to override the delegate thread id, so the cFE think it's this thread * Otherwise cFE application id detection is broken diff --git a/src/components/implementation/no_interface/cFE_booter/ostask.c b/src/components/implementation/no_interface/cFE_booter/ostask.c index b2e7c9b6e1..2ffe9dd603 100644 --- a/src/components/implementation/no_interface/cFE_booter/ostask.c +++ b/src/components/implementation/no_interface/cFE_booter/ostask.c @@ -1,4 +1,5 @@ #include +#include #include #include @@ -76,7 +77,12 @@ OS_SchedulerStart(cos_thd_fn_t main_delegate) sl_thd_param_set(timer_thd, timer_window); sl_thd_param_set(timer_thd, timer_priority); - sl_sched_loop(); + // Must call this before entering scheduler loop + hypercall_comp_init_done(); + + OS_printf("CFE_PSP: Entering scheduler loop...\n"); + sl_sched_loop_nonblock(); + OS_printf("CFE_PSP: Exiting scheduler loop???\n"); } void @@ -133,8 +139,7 @@ OS_TaskCreate(uint32 *task_id, const char *task_name, osal_task_entry function_p printc("task create in server (task_name = %s, fp = %p, idx = %d, spdid = %d)\n", task_name, function_pointer, idx, spdid); cos_defcompinfo_childid_init(&child_dci, spdid); - - thd = sl_thd_aep_alloc_ext(&child_dci, NULL, idx, 0, 0, 0, NULL); + thd = sl_thd_aep_alloc_ext(&child_dci, NULL, idx, 0, 0, 0, 0, 0, NULL); assert(thd); } else { thd = sl_thd_alloc(osal_task_entry_wrapper, function_pointer); diff --git a/src/components/interface/cFE/cFE_emu.h b/src/components/interface/cFE/cFE_emu.h index d20ed2d25c..3e09e01ea7 100644 --- a/src/components/interface/cFE/cFE_emu.h +++ b/src/components/interface/cFE/cFE_emu.h @@ -247,7 +247,7 @@ union shared_region { }; int emu_request_memory(spdid_t client); -arcvcap_t emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_aepkey_t key); +arcvcap_t emu_create_aep_thread(spdid_t client, thdclosure_index_t idx, cos_channelkey_t key); #define STASH_MAGIC_VALUE ((void *)0xBEAFBEAF) @@ -302,7 +302,7 @@ void emu_CFE_TIME_Add(spdid_t client); void emu_CFE_TIME_Compare(spdid_t client); void emu_CFE_TIME_GetTime(spdid_t client); void emu_CFE_TIME_Print(spdid_t client); -int32 emu_CFE_TIME_RegisterSynchCallback(cos_aepkey_t key); +int32 emu_CFE_TIME_RegisterSynchCallback(cos_channelkey_t key); int32 emu_OS_cp(spdid_t client); int32 emu_OS_creat(spdid_t client); diff --git a/src/components/interface/cFE/stubs/c_stub.c b/src/components/interface/cFE/stubs/c_stub.c index 2d24d93bcf..3ffe69d512 100644 --- a/src/components/interface/cFE/stubs/c_stub.c +++ b/src/components/interface/cFE/stubs/c_stub.c @@ -14,7 +14,7 @@ union shared_region *shared_region; spdid_t spdid; -cos_aepkey_t time_sync_key; +cos_channelkey_t time_sync_key; /* We could copy this from the cFE, but it's zero intialized there * Also it's totally unused (according to cFE documentation) diff --git a/src/components/lib/ps b/src/components/lib/ps index 5749bd695f..33f7771466 160000 --- a/src/components/lib/ps +++ b/src/components/lib/ps @@ -1 +1 @@ -Subproject commit 5749bd695f8eb4529b879bd4d9cfdfe6add3bdd0 +Subproject commit 33f77714661eb553c4d5034ec68366859410d8a8 diff --git a/tools/Vagrantfile b/tools/Vagrantfile index 8a8810b442..c1b2590ccc 100644 --- a/tools/Vagrantfile +++ b/tools/Vagrantfile @@ -5,8 +5,7 @@ Vagrant.configure(2) do |config| config.vm.box = "ubuntu/trusty32" config.vm.provider "virtualbox" do |v| - v.name = "composite_dev" - v.memory = 1024 + v.memory = 2048 v.cpus = 2 v.customize ["modifyvm", :id, "--paravirtprovider", "kvm"] end