1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Inlined Routines from the Stack Handler |
---|
5 | * |
---|
6 | * This file contains the static inline implementation of the inlined |
---|
7 | * routines from the Stack Handler. |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * COPYRIGHT (c) 1989-2006. |
---|
12 | * On-Line Applications Research Corporation (OAR). |
---|
13 | * |
---|
14 | * The license and distribution terms for this file may be |
---|
15 | * found in the file LICENSE in this distribution or at |
---|
16 | * http://www.rtems.org/license/LICENSE. |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _RTEMS_SCORE_STACKIMPL_H |
---|
20 | #define _RTEMS_SCORE_STACKIMPL_H |
---|
21 | |
---|
22 | #include <rtems/score/stack.h> |
---|
23 | |
---|
24 | #ifdef __cplusplus |
---|
25 | extern "C" { |
---|
26 | #endif |
---|
27 | |
---|
28 | /** |
---|
29 | * @addtogroup ScoreStack |
---|
30 | */ |
---|
31 | /**@{**/ |
---|
32 | |
---|
33 | /** |
---|
34 | * This routine initializes the_stack record to indicate that |
---|
35 | * size bytes of memory starting at starting_address have been |
---|
36 | * reserved for a stack. |
---|
37 | */ |
---|
38 | RTEMS_INLINE_ROUTINE void _Stack_Initialize ( |
---|
39 | Stack_Control *the_stack, |
---|
40 | void *starting_address, |
---|
41 | size_t size |
---|
42 | ) |
---|
43 | { |
---|
44 | the_stack->area = starting_address; |
---|
45 | the_stack->size = size; |
---|
46 | } |
---|
47 | |
---|
48 | /** |
---|
49 | * This function returns the minimum stack size configured |
---|
50 | * for this application. |
---|
51 | * |
---|
52 | * @return This method returns the minimum stack size; |
---|
53 | */ |
---|
54 | RTEMS_INLINE_ROUTINE uint32_t _Stack_Minimum (void) |
---|
55 | { |
---|
56 | return rtems_minimum_stack_size; |
---|
57 | } |
---|
58 | |
---|
59 | /** |
---|
60 | * This function returns true if size bytes is enough memory for |
---|
61 | * a valid stack area on this processor, and false otherwise. |
---|
62 | * |
---|
63 | * @param[in] size is the stack size to check |
---|
64 | * |
---|
65 | * @return This method returns true if the stack is large enough. |
---|
66 | */ |
---|
67 | RTEMS_INLINE_ROUTINE bool _Stack_Is_enough ( |
---|
68 | size_t size |
---|
69 | ) |
---|
70 | { |
---|
71 | return ( size >= _Stack_Minimum() ); |
---|
72 | } |
---|
73 | |
---|
74 | /** |
---|
75 | * This function returns the appropriate stack size given the requested |
---|
76 | * size. If the requested size is below the minimum, then the minimum |
---|
77 | * configured stack size is returned. |
---|
78 | * |
---|
79 | * @param[in] size is the stack size to check |
---|
80 | * |
---|
81 | * @return This method returns the appropriate stack size. |
---|
82 | */ |
---|
83 | RTEMS_INLINE_ROUTINE size_t _Stack_Ensure_minimum ( |
---|
84 | size_t size |
---|
85 | ) |
---|
86 | { |
---|
87 | if ( size >= _Stack_Minimum() ) |
---|
88 | return size; |
---|
89 | return _Stack_Minimum(); |
---|
90 | } |
---|
91 | |
---|
92 | /** @} */ |
---|
93 | |
---|
94 | #ifdef __cplusplus |
---|
95 | } |
---|
96 | #endif |
---|
97 | |
---|
98 | #endif |
---|
99 | /* end of include file */ |
---|