Blame view

RIOT/core/include/arch/thread_arch.h 2.32 KB
fb11e647   vrobic   reseau statique a...
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
  /*
   * Copyright (C) 2014 Freie Universitรคt Berlin
   *
   * 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.
   */
  
  /**
   * @ingroup     core_arch
   * @{
   *
   * @file
   * @brief       Architecture dependent kernel interface for handling and managing threads
   *
   * @author      Hauke Petersen <hauke.petersen@fu-berlin.de>
   */
  
  #ifndef THREAD_ARCH_H
  #define THREAD_ARCH_H
  
  #include "kernel_defines.h"
  
  #ifdef __cplusplus
   extern "C" {
  #endif
  
  /**
   * @name Define the mapping between the architecture independent interfaces
   *       and the kernel internal interfaces
   *
   * This mapping is done for compatibility of existing platforms,
   * 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
  #define thread_yield_higher             thread_arch_yield
  #endif
  /** @} */
  
  /**
   * @brief Prototype for a thread entry function
   */
  typedef void *(*thread_task_func_t)(void *arg);
  
  /**
   * @brief Initialize a thread's stack
   *
   * @param[in] task_func     pointer to the thread's code
   * @param[in] arg           argument to task_func
   * @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
   */
  char *thread_arch_stack_init(thread_task_func_t task_func, void *arg, void *stack_start, int stack_size);
  
  /**
   * @brief   Get the number of bytes used on the ISR stack
   */
  int thread_arch_isr_stack_usage(void);
  
  /**
   * @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);
  
  /**
   * @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
   */
  void thread_arch_start_threading(void) NORETURN;
  
  /**
   * @brief Pause the current thread and schedule the next pending, if available
   */
  void thread_arch_yield(void);
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif /* THREAD_ARCH_H */
  /** @} */