| /* nanokernel_footprint.c - nanokernel footprint */ |
| |
| /* |
| * Copyright (c) 2013-2014 Wind River Systems, Inc. |
| * |
| * SPDX-License-Identifier: Apache-2.0 |
| */ |
| |
| #include <zephyr.h> |
| #include <toolchain.h> |
| |
| volatile int i = 0; /* counter used by background task */ |
| |
| #ifndef TEST_min |
| |
| #include <misc/printk.h> |
| #include <stdio.h> |
| |
| #define IRQ_LINE 11 /* just some random value w/o driver conflicts */ |
| #define IRQ_PRIORITY 3 |
| #define TEST_SOFT_INT 64 |
| |
| #ifdef TEST_max |
| #define FIBER_STACK_SIZE 1024 |
| #else |
| #define FIBER_STACK_SIZE 512 |
| #endif /* TEST_max */ |
| |
| #ifdef TEST_max |
| #define MESSAGE "Running maximal nanokernel configuration\n" |
| #else |
| #define MESSAGE "Running regular nanokernel configuration\n" |
| #endif /* TEST_max */ |
| |
| typedef void* (*pfunc) (void*); |
| |
| /* stack used by fiber */ |
| static char __stack pStack[FIBER_STACK_SIZE]; |
| |
| static pfunc func_array[] = { |
| /* timers */ |
| (pfunc)k_timer_init, |
| (pfunc)k_timer_stop, |
| (pfunc)k_timer_status_get, |
| (pfunc)k_timer_status_sync, |
| (pfunc)k_timer_remaining_get, |
| (pfunc)k_uptime_get, |
| (pfunc)k_uptime_get_32, |
| (pfunc)k_uptime_delta, |
| (pfunc)k_uptime_delta_32, |
| |
| /* semaphores */ |
| (pfunc)k_sem_init, |
| (pfunc)k_sem_take, |
| (pfunc)k_sem_give, |
| (pfunc)k_sem_reset, |
| (pfunc)k_sem_count_get, |
| |
| #ifdef TEST_max |
| /* stacks */ |
| (pfunc)k_stack_init, |
| (pfunc)k_stack_push, |
| (pfunc)k_stack_pop, |
| |
| /* queues */ |
| (pfunc)k_queue_init, |
| (pfunc)k_queue_append, |
| (pfunc)k_queue_prepend, |
| (pfunc)k_queue_append_list, |
| (pfunc)k_queue_merge_slist, |
| (pfunc)k_queue_get, |
| #endif |
| }; |
| |
| /** |
| * |
| * @brief Dummy ISR |
| * |
| * @return N/A |
| */ |
| |
| void dummyIsr(void *unused) |
| { |
| ARG_UNUSED(unused); |
| } |
| |
| /** |
| * |
| * @brief Trivial fiber |
| * |
| * @param message Message to be printed. |
| * @param arg1 Unused. |
| * |
| * @return N/A |
| */ |
| |
| static void fiberEntry(int message, int arg1) |
| { |
| ARG_UNUSED(arg1); |
| |
| #ifdef TEST_max |
| printf("%s", (char *)message); |
| #else |
| printk("%s", (char *)message); |
| #endif /* TEST_max */ |
| } |
| |
| #endif /* !TEST_min */ |
| |
| /** |
| * |
| * @brief Mainline for background task |
| * |
| * This routine simply increments a global counter. |
| * (Gdb can be used to observe the counter as it increases.) |
| * |
| * @return N/A |
| */ |
| |
| void main(void) |
| { |
| #ifdef TEST_reg |
| IRQ_CONNECT(IRQ_LINE, IRQ_PRIORITY, dummyIsr, NULL, 0); |
| #endif |
| #ifndef TEST_min |
| /* start a trivial fiber */ |
| task_fiber_start(pStack, FIBER_STACK_SIZE, fiberEntry, (int) MESSAGE, |
| (int) func_array, 10, 0); |
| #endif /* !TEST_min */ |
| |
| while (1) { |
| i++; |
| } |
| } |