Skip to content

Commit

Permalink
Merge branch 'cc_os_stage' into test/pranjalchanda08/181-cc_os-testin…
Browse files Browse the repository at this point in the history
…g-on-platforms
  • Loading branch information
pranjalchanda08 committed Jan 31, 2023
2 parents 8bf74da + 2a5a31d commit 9f9b6dd
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 30 deletions.
2 changes: 0 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
"*.{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,
Expand Down
24 changes: 17 additions & 7 deletions mk/picotool.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SILENT_LOGS := > cbuild.log 2> /dev/null
endif

P_TARGETS += elf2uf2
T_ALLOWLIST += get_picotool pt_clean install_pt_dep
T_ALLOWLIST += get_picotool clean_picotool install_pt_dep

get_picotool: $(PICO_TOOL) $(ELF2UF2)

Expand All @@ -30,36 +30,46 @@ $(PICO_TOOL): $(PICO_TOOL_BUILD)
cp $(PICO_TOOL_PATH)/build/picotool $@

$(PICO_TOOL_BUILD): $(PICO_SDK_PATH) $(PICO_TOOL_PATH)
@echo "Building picotool ..."
@echo "< ! > Building picotool ..."
cd $(PICO_TOOL_PATH) && mkdir -p build && \
cd build && export PICO_SDK_PATH=$(PICO_SDK_PATH) && \
cmake ../ $(SILENT_LOGS) \
&& make $(SILENT_LOGS)
@echo "< / > Done!"

$(ELF2UF2): $(PICO_SDK_PATH)
@echo "Building elf2uf2 ..."
@echo "< ! > Building elf2uf2 ..."
mkdir -p $(MISC_TOOLS)/temp
cd $(MISC_TOOLS)/temp; \
cmake $(PICO_SDK_PATH)/tools/elf2uf2 2>/dev/null >/dev/null; \
make >/dev/null 2>/dev/null
cp $(MISC_TOOLS)/temp/elf2uf2 $@
rm -rf $(MISC_TOOLS)/temp
@echo "< ! > Cleaning up build space ..."
rm -rf $(PICO_SDK_PATH) $(PICO_TOOL_PATH)
@echo "< / > Done!"

elf2uf2: $(ELF2UF2) elf
@echo "Generating $(notdir $(ELF:.elf=.uf2)) ..."
$(ELF2UF2) $(ELF) $(ELF:.elf=.uf2)
@echo "< / > Done!"

$(PICO_SDK_PATH):
@echo "Fetching PICO SDK ..."
@echo "< ! > Fetching PICO SDK ..."
git clone $(PICO_SDK_GIT) --quiet $@
@echo "< / > Done!"

$(PICO_TOOL_PATH):
@echo "Fetching PICO Tool ..."
@echo "< ! > Fetching PICO Tool ..."
git clone $(PICO_TOOL_GIT) --quiet $@
@echo "< / > Done!"

install_pt_dep:
@echo "Installing Dependencies ..."
@echo "< ! > Installing Dependencies ..."
@sudo apt-get install build-essential pkg-config libusb-1.0-0-dev -y -qq > /dev/null
@echo "< / > Done!"

pt_clean:
clean_picotool:
@echo "< ! > Removing picotools ..."
rm -rf $(PICO_SDK_PATH) $(PICO_TOOL_PATH) $(PICO_TOOL) $(ELF2UF2)
@echo "< / > Done!"
32 changes: 23 additions & 9 deletions mk/qemu.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,38 @@
# Organisation : Cyancore Core-Team
#

T_ALLOWLIST += get_qemu
T_ALLOWLIST += get_qemu clean_qemu

get_qemu: | $(TOOLS_ROOT)/qemu/ $(TOOLS_ROOT)/qemu/build/
QEMU_CHECKOUT := v7.2.0
QEMU_PATH := $(TOOLS_ROOT)/qemu
QEMU_BUILD_PATH := $(QEMU_PATH)/build
QEMU_OUT_PATH := $(TOOLS_ROOT)/cc_qemu
QEMU_TLIST := avr-softmmu,arm-softmmu,riscv32-softmmu

$(TOOLS_ROOT)/qemu/:
get_qemu: $(QEMU_OUT_PATH)

$(TOOLS_ROOT)/qemu:
@echo "< ! > Using qemu version: $(QEMU_CHECKOUT)"
@echo "< ! > Fetching qemu ..."
mkdir -p $(TOOLS_ROOT)
cd $(TOOLS_ROOT); git clone https://gitlab.com/qemu-project/qemu.git;
cd $@; git submodule init; git submodule update --recursive
cd $(TOOLS_ROOT); git clone https://gitlab.com/qemu-project/qemu.git --quiet;
cd $@; git checkout -b $(QEMU_CHECKOUT) $(QEMU_CHECKOUT) 1> /dev/null 2> /dev/null
@echo "< / > Done !"

$(TOOLS_ROOT)/qemu/build/: $(TOOLS_ROOT)/qemu/

$(QEMU_OUT_PATH): $(QEMU_PATH)
@echo "< ! > Building qemu ..."
@echo "< ? > Please be patient as this might take a while ..."
cd $<; ./configure
make -j $(N_JOBS) -C $<
cd $<; ./configure --prefix=$(QEMU_OUT_PATH) --target-list=$(QEMU_TLIST) 2> /dev/null 1> /dev/null
make -j $(N_JOBS) -C $< install 2> /dev/null 1> /dev/null
@echo "< ! > Cleaning up build space ..."
rm -rf $(QEMU_PATH)
@echo "< ! > Adding load_qemu alias to bashrc ..."
@echo "< ! > run 'load_qemu' before trying to launch qemu!"
echo "alias load_qemu='export PATH=\"\$$PATH\":$@/build/'" >> ~/.bashrc
echo "alias load_qemu='export PATH=\"\$$PATH\":$@/bin/'" >> ~/.bashrc
@echo "< / > Done !"

clean_qemu:
@echo "< ! > Removing cc-qemu installation ..."
rm -rf $(QEMU_OUT_PATH) $(QEMU_PATH)
@echo "< / > Done!"
2 changes: 1 addition & 1 deletion src/include/visor/terravisor/cc_os/cc_os_tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @brief TASK infrastructure
*
*/
typedef uintptr_t cc_os_task_t;
typedef uint16_t cc_os_task_t;

/*****************************************************
* MACROS
Expand Down
2 changes: 1 addition & 1 deletion src/include/visor/terravisor/cc_os/utils/cc_os_sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct cc_sched_tcb
wres_t wait_res; ///> Wait Task resource
link_t ready_link; ///> Ready Linked List Pointers
link_t wait_link; ///> Wait Linked List Pointers
uintptr_t task_id; ///> Task ID assigned
uint16_t task_id; ///> Task ID assigned
#if CC_OS_ANTI_DEADLOCK
size_t task_wd_ticks; ///> Tick down counter for Anti Deadlock system
#endif /* CC_OS_ANTI_DEADLOCK */
Expand Down
9 changes: 3 additions & 6 deletions src/visor/terravisor/services/kernel/cc_os_sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ status_t _cc_sched_node_detach(cc_sched_tcb_t *node_ptr, uint8_t link_type)
void _cc_sched_send_back_of_task_prio(cc_sched_tcb_t *node_ptr)
{
cc_sched_tcb_t * ref_ptr = g_sched_ctrl.ready_list_head;
bool least_prio = true;
if(ref_ptr != CC_OS_NULL_PTR)
{
if (node_ptr == ref_ptr)
Expand All @@ -291,6 +290,7 @@ void _cc_sched_send_back_of_task_prio(cc_sched_tcb_t *node_ptr)
return;
}

bool least_prio = true;
/* Find an optimal space */
while(node_ptr->priority >= ref_ptr->priority)
{
Expand Down Expand Up @@ -339,9 +339,10 @@ void _cc_sched_send_back_of_task_prio(cc_sched_tcb_t *node_ptr)
void _cc_os_pre_sched(cc_os_args args)
{
cc_sched_ctrl_t * sched_ctrl = (cc_sched_ctrl_t *) args;

sched_ctrl->curr_task->task_status = cc_sched_task_status_ready;
__cc_sched_wait_list_adjustment(sched_ctrl);
__cc_sched_deadlock_adjustment_and_detection(sched_ctrl);
_cc_sched_send_back_of_task_prio(sched_ctrl->curr_task);
}

/**
Expand Down Expand Up @@ -455,8 +456,6 @@ static void __cc_sched_algo_round_robin_fn(cc_sched_ctrl_t * sched_ctrl)
/* do waitlist adjustment */
cc_sched_tcb_t * ptr = sched_ctrl->curr_task->ready_link.next;

__cc_sched_wait_list_adjustment(sched_ctrl);

if (ptr == sched_ctrl->ready_list_head)
{
/* IDLE Task */
Expand All @@ -472,8 +471,6 @@ static void __cc_sched_algo_round_robin_fn(cc_sched_ctrl_t * sched_ctrl)
static void __cc_sched_algo_priority_driven_fn(cc_sched_ctrl_t * sched_ctrl)
{
/* do waitlist adjustment */
__cc_sched_wait_list_adjustment(sched_ctrl);

cc_sched_tcb_t * ptr = sched_ctrl->ready_list_head->ready_link.prev;
if(ptr != CC_OS_NULL_PTR)
{
Expand Down
10 changes: 6 additions & 4 deletions src/visor/terravisor/services/kernel/cc_os_tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extern void _cc_sched_send_to_wait(cc_sched_ctrl_t *sched_ctrl, cc_sched_tcb_t *
extern void _cc_sched_send_to_pause(cc_sched_ctrl_t * sched_ctrl, cc_sched_tcb_t * ptr);
extern void _cc_sched_send_to_resume(cc_sched_ctrl_t *sched_ctrl, cc_sched_tcb_t *ptr);
extern void _cc_sched_send_back_of_task_prio(cc_sched_tcb_t *node_ptr);
extern void _cc_os_scheduler_despatch(void);
extern void _cc_os_pre_sched(cc_os_args args);
/*****************************************************
* GLOBAL EXTERNS VARIABLES
Expand All @@ -49,15 +50,15 @@ extern cc_sched_tcb_t *g_cc_os_tcb_list;
#endif

#if CC_OS_DYNAMIC == false
uint8_t _cc_os_stack[CC_OS_IDLE_STACK_LEN];
uint8_t _cc_os_stack[CC_OS_IDLE_TASK_STACK_LEN];
#else
uint8_t *_cc_os_stack = CC_OS_NULL_PTR;
#endif
cc_os_task_t cc_os_idle_task;
/*****************************************************
* STATIC VARIABLES
*****************************************************/
static size_t __cc_os_task_id_gen = false;
static uint16_t __cc_os_task_id_gen = false;
/*****************************************************
* STATIC FUNCTION DEFINATIONS
*****************************************************/
Expand All @@ -67,7 +68,7 @@ static void __cc_init_scheduler(void)
return;
}

static size_t __cc_os_task_id_generate()
static uint16_t __cc_os_task_id_generate()
{
__cc_os_task_id_gen++;
return __cc_os_task_id_gen;
Expand Down Expand Up @@ -205,12 +206,12 @@ status_t cc_os_add_task(
status_t cc_os_del_task(cc_os_task_t cc_os_task)
{
cc_sched_tcb_t * ptr = __cc_os_get_tcb_using_task_id(cc_os_task);
CC_OS_ASSERT_IF_FALSE(ptr->task_func != &_cc_os_idle_task_fn);

if (ptr == CC_OS_NULL_PTR)
{
ptr = g_sched_ctrl.curr_task;
}
CC_OS_ASSERT_IF_FALSE(ptr->task_func != &_cc_os_idle_task_fn);
/* Code to handle first node */
if (ptr == g_sched_ctrl.ready_list_head)
{
Expand Down Expand Up @@ -414,6 +415,7 @@ void cc_os_task_wait(const size_t ticks)

void cc_os_task_yield()
{
_cc_os_scheduler_despatch();
return;
}

Expand Down

0 comments on commit 9f9b6dd

Please sign in to comment.