diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..afd7a788 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,64 @@ +{ + "editor.tabSize": 8, + "[c]": { + "editor.tabSize": 8 + }, + "[cpp]": { + "editor.tabSize": 8 + }, + "[json]": { + "editor.tabSize": 8 + }, + "[makefile]": { + "editor.tabSize": 8 + }, + "[python]": { + "editor.tabSize": 8 + }, + "editor.selectionHighlight": true, + "editor.semanticHighlighting.enabled": true, + "editor.trimAutoWhitespace": true, + "editor.autoClosingQuotes": "always", + "editor.autoClosingBrackets": "always", + "editor.wordBasedSuggestions": true, + "editor.insertSpaces": false, + "editor.autoIndent": "advanced", + "editor.detectIndentation": true, + "editor.codeLens": true, + "editor.columnSelection": false, + "editor.colorDecorators": true, + "editor.cursorBlinking": "blink", + "editor.lightbulb.enabled": true, + "editor.lineNumbers": "on", + "editor.suggest.showFunctions": true, + "diffEditor.codeLens": true, + "diffEditor.wordWrap": "on", + "editor.suggest.showStatusBar": true, + "editor.formatOnSave": false, + "files.associations": { + "*.sx": "c", + "*.{c,c.dev.c.temp,c.tmp,c.old,h,h.dev,h.old,h.temp,h.tmp)": "C", + "*.{cpp,cpp.dev,cpp.temp,cpp.tmp,cpp.old}": "C++", + "*.{S,S.old,S.dev.S.temp,S.tmp,s.old,s.temp,s.tmp,s.dev,asm,asm.old,asm.dev.asm.temp,asm.tmp,inc,inc.old,inc.temp,inc.tmp,ld,ld.old,ld.temp,ld.tmp,ld.sx,ld.sx.old,ld.sx.temp,ld.sx.tmp,lst}": "coffeescript", + "cc_os_sched.h": "c", + "cc_os.h": "c" + }, + "files.autoSave": "afterDelay", + "files.autoSaveDelay": 100, + "files.defaultLanguage": "C", + "files.insertFinalNewline": true, + "files.trimTrailingWhitespace": true, + "files.trimFinalNewlines": true, + "files.simpleDialog.enable": true, + "workbench.activityBar.iconClickBehavior": "focus", + "workbench.editor.closeOnFileDelete": true, + "workbench.editor.decorations.badges": true, + "workbench.editor.enablePreviewFromCodeNavigation": true, + "workbench.editor.enablePreviewFromQuickOpen": true, + "workbench.editor.highlightModifiedTabs": true, + "workbench.settings.openDefaultKeybindings": true, + "C_Cpp.autocompleteAddParentheses": true, + "git.alwaysSignOff": true, + "files.autoGuessEncoding": true, + "sonarlint.pathToCompileCommands": "${workspaceFolder}/.vscode/compile_commands.json" +} diff --git a/projects/demo_cc_os_avr/cc_os_config.mk b/projects/demo_cc_os_avr/cc_os_config.mk index 828c47c8..215c4300 100644 --- a/projects/demo_cc_os_avr/cc_os_config.mk +++ b/projects/demo_cc_os_avr/cc_os_config.mk @@ -8,10 +8,10 @@ # Organisation : Cyancore Core-Team # -ccosconfig_CC_OS_USE_DYNAMIC := 1 -ccosconfig_CC_OS_HEAP_SIZE := 1024 -ccosconfig_CC_OS_MAX_THREAD := 3 -ccosconfig_CC_OS_TASK_STACK_LEN := 255 -ccosconfig_CC_OS_POWER_SAVE_EN := 0 +CC_OS_USE_DYNAMIC := 1 +CC_OS_HEAP_SIZE := 1024 +CC_OS_MAX_THREAD := 3 +CC_OS_TASK_STACK_LEN := 255 +CC_OS_POWER_SAVE_EN := 0 include $(CC_OS_ROOT)/cc_os_config.mk diff --git a/projects/demo_cc_os_riscv/cc_os_config.mk b/projects/demo_cc_os_riscv/cc_os_config.mk index 1ec963e5..c8e63fc8 100644 --- a/projects/demo_cc_os_riscv/cc_os_config.mk +++ b/projects/demo_cc_os_riscv/cc_os_config.mk @@ -8,10 +8,10 @@ # Organisation : Cyancore Core-Team # -ccosconfig_CC_OS_USE_DYNAMIC := 1 -ccosconfig_CC_OS_HEAP_SIZE := 1024 -ccosconfig_CC_OS_MAX_THREAD := 3 -ccosconfig_CC_OS_TASK_STACK_LEN := 255 -ccosconfig_CC_OS_POWER_SAVE_EN := 0 +CC_OS_USE_DYNAMIC := 1 +CC_OS_HEAP_SIZE := 1024 +CC_OS_MAX_THREAD := 3 +CC_OS_TASK_STACK_LEN := 255 +CC_OS_POWER_SAVE_EN := 0 include $(CC_OS_ROOT)/cc_os_config.mk diff --git a/src/include/visor/terravisor/cc_os/cc_os_config.h b/src/include/visor/terravisor/cc_os/cc_os_config.h index f9f2f9ef..5ca697b1 100644 --- a/src/include/visor/terravisor/cc_os/cc_os_config.h +++ b/src/include/visor/terravisor/cc_os/cc_os_config.h @@ -14,16 +14,16 @@ * @brief Shall CC_OS use dynamic resource allocation * @note Possible values : 1/0 */ -#ifndef ccosconfig_CC_OS_USE_DYNAMIC -#define ccosconfig_CC_OS_USE_DYNAMIC 1 +#ifndef CC_OS_USE_DYNAMIC +#define CC_OS_USE_DYNAMIC 1 #endif /** * @brief Heap size to be allocated to CC_OS * @note Possible values : Depends on available RAM */ -#ifndef ccosconfig_CC_OS_HEAP_SIZE -#define ccosconfig_CC_OS_HEAP_SIZE 1024 +#ifndef CC_OS_HEAP_SIZE +#define CC_OS_HEAP_SIZE 1024 #endif /** @@ -32,38 +32,31 @@ * User may have to keep it optimised so as to use as low BSS section * to be used as possible for the application being created. */ -#ifndef ccosconfig_CC_OS_MAX_THREAD -#define ccosconfig_CC_OS_MAX_THREAD 10 -#endif - -/** - * @brief Max number of characters allowed to be used for task name - */ -#ifndef ccosconfig_CC_OS_TASK_NAME_LEN -#define ccosconfig_CC_OS_TASK_NAME_LEN 16 +#ifndef CC_OS_MAX_THREAD +#define CC_OS_MAX_THREAD 10 #endif /** * @brief Task priority of IDLE task * @note Possible values : 1 -> 255 */ -#ifndef ccosconfig_CC_OS_IDLE_TASK_PRIORITY -#define ccosconfig_CC_OS_IDLE_TASK_PRIORITY 0x01 +#ifndef CC_OS_IDLE_TASK_PRIORITY +#define CC_OS_IDLE_TASK_PRIORITY 0x01 #endif /** * @brief Stack size used by IDLE task * @note The stack size is either allocated statically or dynamically as - * per the setting of ccosconfig_CC_OS_USE_DYNAMIC + * per the setting of CC_OS_USE_DYNAMIC */ -#ifndef ccosconfig_CC_OS_TASK_STACK_LEN -#define ccosconfig_CC_OS_TASK_STACK_LEN 255 +#ifndef CC_OS_TASK_STACK_LEN +#define CC_OS_TASK_STACK_LEN 255 #endif /** * @brief If the Kernel shall enter poer save mode during IDLE * */ -#ifndef ccosconfig_CC_OS_POWER_SAVE_EN -#define ccosconfig_CC_OS_POWER_SAVE_EN 0 +#ifndef CC_OS_POWER_SAVE_EN +#define CC_OS_POWER_SAVE_EN 0 #endif diff --git a/src/include/visor/terravisor/cc_os/cc_os_config.mk b/src/include/visor/terravisor/cc_os/cc_os_config.mk index 9285fe01..ce9244a0 100644 --- a/src/include/visor/terravisor/cc_os/cc_os_config.mk +++ b/src/include/visor/terravisor/cc_os/cc_os_config.mk @@ -8,14 +8,14 @@ # Organisation : Cyancore Core-Team # -ccosconfig_CC_OS_USE_DYNAMIC ?= 0 -ccosconfig_CC_OS_HEAP_SIZE ?= 1024 -ccosconfig_CC_OS_MAX_THREAD ?= 2 -ccosconfig_CC_OS_TASK_STACK_LEN ?= 255 -ccosconfig_CC_OS_POWER_SAVE_EN ?= 0 +CC_OS_USE_DYNAMIC ?= 0 +CC_OS_HEAP_SIZE ?= 1024 +CC_OS_MAX_THREAD ?= 2 +CC_OS_TASK_STACK_LEN ?= 255 +CC_OS_POWER_SAVE_EN ?= 0 -$(eval $(call add_define,ccosconfig_CC_OS_USE_DYNAMIC)) -$(eval $(call add_define,ccosconfig_CC_OS_HEAP_SIZE)) -$(eval $(call add_define,ccosconfig_CC_OS_MAX_THREAD)) -$(eval $(call add_define,ccosconfig_CC_OS_TASK_STACK_LEN)) -$(eval $(call add_define,ccosconfig_CC_OS_POWER_SAVE_EN)) +$(eval $(call add_define,CC_OS_USE_DYNAMIC)) +$(eval $(call add_define,CC_OS_HEAP_SIZE)) +$(eval $(call add_define,CC_OS_MAX_THREAD)) +$(eval $(call add_define,CC_OS_TASK_STACK_LEN)) +$(eval $(call add_define,CC_OS_POWER_SAVE_EN)) diff --git a/src/include/visor/terravisor/cc_os/cc_os_tasks.h b/src/include/visor/terravisor/cc_os/cc_os_tasks.h index a0b62866..3de13ca7 100644 --- a/src/include/visor/terravisor/cc_os/cc_os_tasks.h +++ b/src/include/visor/terravisor/cc_os/cc_os_tasks.h @@ -34,7 +34,7 @@ typedef struct cc_os_task task_fn task_fn; ///>> Task funcion os_args args; ///>> Task Args ptr c_char *name; ///>> String name of the task - uint8_t *stack_ptr; ///>> Stack pointer of the task + uintptr_t stack_ptr; ///>> Stack pointer of the task uint8_t priority; ///>> For waited tasks size_t stack_len; ///>> Stack lengths of the task cc_sched_tcb_t *task_tcb_ptr; ///>> For internal use only @@ -59,7 +59,7 @@ typedef struct cc_os_task .task_fn = _fn, \ .name = #_NAME, \ .priority = _PRI, \ - .stack_ptr = _NAME##_stack, \ + .stack_ptr = (uintptr_t) _NAME##_stack, \ .stack_len = STACK_LEN} #else #define CC_TASK_DEF(_NAME, _fn, _args, _PRI, STACK_LEN) \ @@ -69,7 +69,7 @@ typedef struct cc_os_task .task_fn = _fn, \ .name = #_NAME, \ .priority = _PRI, \ - .stack_ptr = CC_OS_NULL_PTR, \ + .stack_ptr = (uintptr_t) CC_OS_NULL_PTR, \ .stack_len = STACK_LEN} #endif /** diff --git a/src/include/visor/terravisor/cc_os/utils/cc_os_sched.h b/src/include/visor/terravisor/cc_os/utils/cc_os_sched.h index 00034c8e..770bed1e 100644 --- a/src/include/visor/terravisor/cc_os/utils/cc_os_sched.h +++ b/src/include/visor/terravisor/cc_os/utils/cc_os_sched.h @@ -25,7 +25,7 @@ #define CC_OS_NULL_PTR NULL #define CC_OS_DELAY_MAX ((size_t) -1) -#define CC_OS_DYNAMIC ccosconfig_CC_OS_USE_DYNAMIC +#define CC_OS_DYNAMIC CC_OS_USE_DYNAMIC #define CC_OS_ASSERT_IF_FALSE(con) RET_ON_FAIL(con, error_func_inval_arg) @@ -61,7 +61,7 @@ struct cc_sched_tcb { c_char * name; ///> Name of the Current Task uint8_t priority; ///> Priority of the task - void * stack_ptr; ///> Stack Pointer + uintptr_t stack_ptr; ///> Stack Pointer wres_t wait_res; ///> Wait Task resource link_t ready_link; ///> Ready Linked List Pointers link_t wait_link; ///> Wait Linked List Pointers diff --git a/src/visor/terravisor/services/kernel/cc_os_sched.c b/src/visor/terravisor/services/kernel/cc_os_sched.c index c055a35a..3f1f060d 100644 --- a/src/visor/terravisor/services/kernel/cc_os_sched.c +++ b/src/visor/terravisor/services/kernel/cc_os_sched.c @@ -30,8 +30,8 @@ static void __cc_sched_algo_priority_driven_fn(cc_sched_ctrl_t * sched_ctrl); /***************************************************** * GLOBAL DECLARATIONS *****************************************************/ -#if !ccosconfig_CC_OS_USE_DYNAMIC -cc_sched_tcb_t g_cc_os_tcb_list [ccosconfig_CC_OS_MAX_THREAD]; +#if !CC_OS_USE_DYNAMIC +cc_sched_tcb_t g_cc_os_tcb_list [CC_OS_MAX_THREAD]; #else cc_sched_tcb_t * g_cc_os_tcb_list = CC_OS_NULL_PTR; #endif @@ -44,7 +44,7 @@ cc_sched_t g_cc_sched_list [] = cc_sched_ctrl_t g_sched_ctrl = { -#if !ccosconfig_CC_OS_USE_DYNAMIC +#if !CC_OS_USE_DYNAMIC .ready_list_head = &(g_cc_os_tcb_list[CC_OS_FALSE]), .curr_task = &(g_cc_os_tcb_list[CC_OS_FALSE]), #else diff --git a/src/visor/terravisor/services/kernel/cc_os_task_idle.c b/src/visor/terravisor/services/kernel/cc_os_task_idle.c index 7fdbf50d..43bd7d62 100644 --- a/src/visor/terravisor/services/kernel/cc_os_task_idle.c +++ b/src/visor/terravisor/services/kernel/cc_os_task_idle.c @@ -34,7 +34,7 @@ static cc_sched_tcb_t * __free_terminated_task(cc_sched_tcb_t * ptr) ptr->ready_link.next = CC_OS_NULL_PTR; ptr->ready_link.prev = CC_OS_NULL_PTR; #else - cc_os_free(ptr->stack_ptr); + cc_os_free((void *)ptr->stack_ptr); cc_os_free(ptr); #endif } @@ -55,7 +55,7 @@ void _cc_os_idle_task_fn(os_args args) /* Clean up task if terminated */ ptr = __free_terminated_task(ptr); -#if ccosconfig_CC_OS_POWER_SAVE_EN +#if CC_OS_POWER_SAVE_EN /* Power Save code */ #endif diff --git a/src/visor/terravisor/services/kernel/cc_os_tasks.c b/src/visor/terravisor/services/kernel/cc_os_tasks.c index 14ba70f9..c62cf9e1 100644 --- a/src/visor/terravisor/services/kernel/cc_os_tasks.c +++ b/src/visor/terravisor/services/kernel/cc_os_tasks.c @@ -51,8 +51,8 @@ CC_TASK_DEF( cc_os_idle, /* Name of the instance */ _cc_os_idle_task_fn, /* Function pointer */ &g_sched_ctrl, /* Task Args*/ - ccosconfig_CC_OS_IDLE_TASK_PRIORITY, /* Task Priority */ - ccosconfig_CC_OS_TASK_STACK_LEN /* Stack Length of IDLE Task */ + CC_OS_IDLE_TASK_PRIORITY, /* Task Priority */ + CC_OS_TASK_STACK_LEN /* Stack Length of IDLE Task */ ); /***************************************************** * STATIC FUNCTION DEFINATIONS @@ -68,10 +68,10 @@ status_t cc_os_add_task (cc_os_task_t * cc_os_task) { CC_OS_ASSERT_IF_FALSE(cc_os_task != CC_OS_NULL_PTR); CC_OS_ASSERT_IF_FALSE(cc_os_task->name != CC_OS_NULL_PTR); - CC_OS_ASSERT_IF_FALSE(cc_os_task->stack_ptr != CC_OS_NULL_PTR); + CC_OS_ASSERT_IF_FALSE(cc_os_task->stack_ptr != (uintptr_t) CC_OS_NULL_PTR); CC_OS_ASSERT_IF_FALSE(cc_os_task->task_fn != CC_OS_NULL_PTR); CC_OS_ASSERT_IF_FALSE(cc_os_task->stack_len != CC_OS_FALSE); - CC_OS_ASSERT_IF_FALSE(cc_os_task->priority >= ccosconfig_CC_OS_IDLE_TASK_PRIORITY); + CC_OS_ASSERT_IF_FALSE(cc_os_task->priority >= CC_OS_IDLE_TASK_PRIORITY); CC_OS_ASSERT_IF_FALSE(cc_os_task->priority < CC_OS_PRIORITY_MAX); cc_os_pause_all_task(); @@ -99,7 +99,7 @@ status_t cc_os_add_task (cc_os_task_t * cc_os_task) { #if CC_OS_DYNAMIC == CC_OS_FALSE /* Static Task Allocation */ - for (size_t i = CC_OS_FALSE; i < ccosconfig_CC_OS_MAX_THREAD; i++) + for (size_t i = CC_OS_FALSE; i < CC_OS_MAX_THREAD; i++) { /* Get an available node from global tcb list */ if (g_cc_os_tcb_list[i].task_status == cc_sched_task_status_exit) @@ -118,7 +118,7 @@ status_t cc_os_add_task (cc_os_task_t * cc_os_task) #endif /* Fill tcb details */ ptr->name = cc_os_task->name; - ptr->stack_ptr = (uint8_t *) malloc(cc_os_task->stack_len); + ptr->stack_ptr = (uintptr_t) malloc(cc_os_task->stack_len); ptr->priority = cc_os_task->priority; } else