1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #20240 from benpicco/cpu/atmega-no_thread

cpu/avr8_common: fix build with !core_thread
This commit is contained in:
benpicco 2024-01-09 22:13:30 +00:00 committed by GitHub
commit 2e3037c3aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 3 deletions

View File

@ -106,8 +106,11 @@ void kernel_init(void)
main_trampoline, NULL, "main"); main_trampoline, NULL, "main");
} }
else { else {
/* RIOT without threads */
irq_enable(); irq_enable();
main_trampoline(NULL); main_trampoline(NULL);
while (1) {}
return;
} }
cpu_switch_context_exit(); cpu_switch_context_exit();

View File

@ -260,6 +260,10 @@ void NORETURN avr8_enter_thread_mode(void)
void thread_yield_higher(void) void thread_yield_higher(void)
{ {
if (!IS_USED(MODULE_CORE_THREAD)) {
return;
}
if (irq_is_in() == 0) { if (irq_is_in() == 0) {
avr8_context_save(); avr8_context_save();
sched_run(); sched_run();
@ -278,7 +282,8 @@ void avr8_exit_isr(void)
__asm__ volatile ("" : : : "memory"); __asm__ volatile ("" : : : "memory");
/* schedule should switch context when returning from a non nested interrupt */ /* schedule should switch context when returning from a non nested interrupt */
if (sched_context_switch_request && avr8_state_irq_count == 0) { if (sched_context_switch_request && avr8_state_irq_count == 0 &&
IS_USED(MODULE_CORE_THREAD)) {
avr8_context_save(); avr8_context_save();
sched_run(); sched_run();
avr8_context_restore(); avr8_context_restore();

View File

@ -156,7 +156,8 @@ void isr_cpu_switch_context_exit(void)
ucontext_t *ctx; ucontext_t *ctx;
DEBUG("isr_cpu_switch_context_exit\n"); DEBUG("isr_cpu_switch_context_exit\n");
if ((sched_context_switch_request == 1) || (thread_get_active() == NULL)) { if (((sched_context_switch_request == 1) || (thread_get_active() == NULL))
&& IS_USED(MODULE_CORE_THREAD)) {
sched_run(); sched_run();
} }
@ -210,7 +211,11 @@ void isr_thread_yield(void)
native_irq_handler(); native_irq_handler();
} }
if (!IS_USED(MODULE_CORE_THREAD)) {
return;
}
sched_run(); sched_run();
/* Use intermediate cast to uintptr_t to silence -Wcast-align. /* Use intermediate cast to uintptr_t to silence -Wcast-align.
* stacks are manually word aligned in thread_static_init() */ * stacks are manually word aligned in thread_static_init() */
ucontext_t *ctx = (ucontext_t *)(uintptr_t)(thread_get_active()->sp); ucontext_t *ctx = (ucontext_t *)(uintptr_t)(thread_get_active()->sp);

View File

@ -84,7 +84,9 @@ USEMODULE += $(filter cortexm_svc, $(FEATURES_USED))
# select core_idle_thread if the feature no_idle_thread is *not* used # select core_idle_thread if the feature no_idle_thread is *not* used
ifeq (, $(filter no_idle_thread, $(FEATURES_USED))) ifeq (, $(filter no_idle_thread, $(FEATURES_USED)))
USEMODULE += core_idle_thread ifneq (,$(filter core_thread, $(USEMODULE)))
USEMODULE += core_idle_thread
endif
endif endif
# use mpu_stack_guard if the feature is used # use mpu_stack_guard if the feature is used