Skip to content

Commit

Permalink
<CC_OS> Review Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pranjalchanda08 committed Jan 5, 2023
1 parent 2bc1a09 commit 3c9af03
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 56 deletions.
64 changes: 64 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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"
}
10 changes: 5 additions & 5 deletions projects/demo_cc_os_avr/cc_os_config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions projects/demo_cc_os_riscv/cc_os_config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
33 changes: 13 additions & 20 deletions src/include/visor/terravisor/cc_os/cc_os_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand All @@ -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
20 changes: 10 additions & 10 deletions src/include/visor/terravisor/cc_os/cc_os_config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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))
6 changes: 3 additions & 3 deletions src/include/visor/terravisor/cc_os/cc_os_tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) \
Expand All @@ -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
/**
Expand Down
4 changes: 2 additions & 2 deletions src/include/visor/terravisor/cc_os/utils/cc_os_sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/visor/terravisor/services/kernel/cc_os_sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/visor/terravisor/services/kernel/cc_os_task_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/visor/terravisor/services/kernel/cc_os_tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 3c9af03

Please sign in to comment.