Skip to content

Commit

Permalink
tests: object_footprint: add missing file
Browse files Browse the repository at this point in the history
Change-Id: I2d26f0770ac81482d70a8101c22745b2baef64ae
Signed-off-by: Anas Nashif <[email protected]>
  • Loading branch information
nashif committed Mar 24, 2017
1 parent e994b0a commit 898c8b6
Showing 1 changed file with 129 additions and 0 deletions.
129 changes: 129 additions & 0 deletions tests/benchmarks/object_footprint/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
* Copyright (c) 2015 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr.h>
#include <toolchain.h>


#include <misc/printk.h>
#include <stdio.h>

#ifdef CONFIG_OBJECTS_WHILELOOP
volatile int i;
#endif

#define IRQ_LINE 10
#define IRQ_PRIORITY 3
#define TEST_SOFT_INT 64
#define TEST_IRQ_OFFLOAD_VECTOR 32

#define THREAD_STACK_SIZE CONFIG_THREAD_STACK_SIZE

typedef void * (*pfunc) (void *);

/* variables */

#define MESSAGE "Running maximal kernel configuration\n"

/* stack used by thread */
#ifdef CONFIG_OBJECTS_THREAD
static char __stack pStack[THREAD_STACK_SIZE];
#endif

/* pointer array ensures specified functions are linked into the image */
volatile pfunc func_array[] = {
/* timer functions */
#ifdef CONFIG_OBJECTS_TIMER
(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,
#endif

/* semaphore functions */
#ifdef CONFIG_OBJECTS_SEMAPHORE
(pfunc)k_sem_init,
(pfunc)k_sem_take,
(pfunc)k_sem_give,
(pfunc)k_sem_reset,
(pfunc)k_sem_count_get,
#endif

/* LIFO functions */
#ifdef CONFIG_OBJECTS_LIFO
(pfunc)k_queue_prepend,
(pfunc)k_queue_init,
(pfunc)k_queue_get,
#endif
/* stack functions */
#ifdef CONFIG_OBJECTS_STACK
(pfunc)k_stack_init,
(pfunc)k_stack_push,
(pfunc)k_stack_pop,
#endif
/* FIFO functions */
#ifdef CONFIG_OBJECTS_FIFO
(pfunc)k_queue_prepend,
(pfunc)k_queue_init,
(pfunc)k_queue_get,
#endif

};

void dummy_isr(void *unused)
{
ARG_UNUSED(unused);
}

#ifdef CONFIG_OBJECTS_THREAD

/**
*
* @brief Trivial thread
*
* @param message Message to be printed.
* @param arg1 Unused.
*
* @return N/A
*/
static void thread_entry(void *arg1, void *arg2, void *arg3)
{
ARG_UNUSED(arg2);
ARG_UNUSED(arg3);
printk("%s\n", (char *)arg1);
}
#endif



void main(void)
{
#ifdef CONFIG_OBJECTS_PRINTK
printk("Using printk\n");
#endif

#if CONFIG_STATIC_ISR
IRQ_CONNECT(IRQ_LINE, IRQ_PRIORITY, dummy_isr, NULL, 0);
#endif

#ifdef CONFIG_OBJECTS_THREAD
/* start a trivial fiber */
k_thread_spawn(pStack, THREAD_STACK_SIZE, thread_entry, MESSAGE, (void *)func_array,
NULL, 10, 0, K_NO_WAIT);
#endif

#ifdef CONFIG_OBJECTS_WHILELOOP
i = 0;
while (1) {
i++;
}
#endif
}

0 comments on commit 898c8b6

Please sign in to comment.