2014-03-17 17:59:06 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Freie Universität Berlin
|
|
|
|
*
|
2014-08-23 15:43:13 +02:00
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
2014-03-17 17:59:06 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup core_arch
|
|
|
|
* @{
|
|
|
|
*
|
2015-05-22 07:34:41 +02:00
|
|
|
* @file
|
2014-03-17 17:59:06 +01:00
|
|
|
* @brief Architecture dependent kernel interface for handling and managing threads
|
|
|
|
*
|
|
|
|
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
|
|
|
*/
|
|
|
|
|
2015-03-26 17:07:04 +01:00
|
|
|
#ifndef THREAD_ARCH_H
|
|
|
|
#define THREAD_ARCH_H
|
2014-03-17 17:59:06 +01:00
|
|
|
|
2016-03-09 01:27:23 +01:00
|
|
|
#include "kernel_defines.h"
|
2014-10-13 14:44:28 +02:00
|
|
|
|
2014-10-09 01:18:16 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2014-03-17 17:59:06 +01:00
|
|
|
/**
|
|
|
|
* @name Define the mapping between the architecture independent interfaces
|
|
|
|
* and the kernel internal interfaces
|
2014-05-14 10:46:15 +02:00
|
|
|
*
|
|
|
|
* This mapping is done for compatibility of existing platforms,
|
2014-03-17 17:59:06 +01:00
|
|
|
* new platforms should always use the *_arch_* interfaces.
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#ifdef COREIF_NG
|
|
|
|
#define thread_stack_init thread_arch_stack_init
|
|
|
|
#define thread_print_stack thread_arch_print_stack
|
|
|
|
#define cpu_switch_context_exit thread_arch_start_threading
|
2014-10-18 01:24:49 +02:00
|
|
|
#define thread_yield_higher thread_arch_yield
|
2014-03-17 17:59:06 +01:00
|
|
|
#endif
|
|
|
|
/** @} */
|
|
|
|
|
2016-02-27 01:12:02 +01:00
|
|
|
/**
|
|
|
|
* @brief Prototype for a thread entry function
|
|
|
|
*/
|
|
|
|
typedef void *(*thread_task_func_t)(void *arg);
|
2014-03-17 17:59:06 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Initialize a thread's stack
|
|
|
|
*
|
|
|
|
* @param[in] task_func pointer to the thread's code
|
2014-03-04 20:20:01 +01:00
|
|
|
* @param[in] arg argument to task_func
|
2014-03-17 17:59:06 +01:00
|
|
|
* @param[in] stack_start pointer to the start address of the thread
|
|
|
|
* @param[in] stack_size the maximum size of the stack
|
|
|
|
*
|
|
|
|
* @return pointer to the new top of the stack
|
|
|
|
*/
|
2014-10-19 23:10:14 +02:00
|
|
|
char *thread_arch_stack_init(thread_task_func_t task_func, void *arg, void *stack_start, int stack_size);
|
2014-03-17 17:59:06 +01:00
|
|
|
|
2016-06-01 20:35:00 +02:00
|
|
|
/**
|
|
|
|
* @brief Get the number of bytes used on the ISR stack
|
|
|
|
*/
|
|
|
|
int thread_arch_isr_stack_usage(void);
|
|
|
|
|
2016-06-20 15:27:09 +02:00
|
|
|
/**
|
|
|
|
* @brief Get the current ISR stack pointer
|
|
|
|
*/
|
|
|
|
void *thread_arch_isr_stack_pointer(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the start of the ISR stack
|
|
|
|
*/
|
|
|
|
void *thread_arch_isr_stack_start(void);
|
|
|
|
|
2014-03-17 17:59:06 +01:00
|
|
|
/**
|
|
|
|
* @brief Print the current stack to stdout
|
|
|
|
*/
|
|
|
|
void thread_arch_stack_print(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Start threading by loading a threads initial information from the stack
|
|
|
|
*/
|
2014-06-05 21:01:35 +02:00
|
|
|
void thread_arch_start_threading(void) NORETURN;
|
2014-03-17 17:59:06 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Pause the current thread and schedule the next pending, if available
|
|
|
|
*/
|
|
|
|
void thread_arch_yield(void);
|
|
|
|
|
2014-10-09 01:18:16 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2014-03-17 17:59:06 +01:00
|
|
|
|
2015-03-26 17:07:04 +01:00
|
|
|
#endif /* THREAD_ARCH_H */
|
2014-03-17 17:59:06 +01:00
|
|
|
/** @} */
|