Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | /* 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
/* LIFOs */
(pfunc)k_lifo_init,
(pfunc)k_lifo_put,
(pfunc)k_lifo_get,
/* stacks */
(pfunc)k_stack_init,
(pfunc)k_stack_push,
(pfunc)k_stack_pop,
/* FIFOs */
(pfunc)k_fifo_init,
(pfunc)k_fifo_put,
(pfunc)k_fifo_put_list,
(pfunc)k_fifo_put_slist,
(pfunc)k_fifo_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++;
}
}
|