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.com/license/LICENSE. |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _RTEMS_SCORE_STACK_H |
---|
20 | # error "Never use <rtems/score/stack.inl> directly; include <rtems/score/stack.h> instead." |
---|
21 | #endif |
---|
22 | |
---|
23 | #ifndef _RTEMS_SCORE_STACK_INL |
---|
24 | #define _RTEMS_SCORE_STACK_INL |
---|
25 | |
---|
26 | #include <rtems/score/basedefs.h> /* RTEMS_INLINE_ROUTINE */ |
---|
27 | |
---|
28 | /** |
---|
29 | * @addtogroup ScoreStack |
---|
30 | * |
---|
31 | * @{ |
---|
32 | */ |
---|
33 | |
---|
34 | /** |
---|
35 | * This routine initializes the_stack record to indicate that |
---|
36 | * size bytes of memory starting at starting_address have been |
---|
37 | * reserved for a stack. |
---|
38 | */ |
---|
39 | RTEMS_INLINE_ROUTINE void _Stack_Initialize ( |
---|
40 | Stack_Control *the_stack, |
---|
41 | void *starting_address, |
---|
42 | size_t size |
---|
43 | ) |
---|
44 | { |
---|
45 | the_stack->area = starting_address; |
---|
46 | the_stack->size = size; |
---|
47 | } |
---|
48 | |
---|
49 | /** |
---|
50 | * This function returns the minimum stack size configured |
---|
51 | * for this application. |
---|
52 | * |
---|
53 | * @return This method returns the minimum stack size; |
---|
54 | */ |
---|
55 | RTEMS_INLINE_ROUTINE uint32_t _Stack_Minimum (void) |
---|
56 | { |
---|
57 | return rtems_minimum_stack_size; |
---|
58 | } |
---|
59 | |
---|
60 | /** |
---|
61 | * This function returns true if size bytes is enough memory for |
---|
62 | * a valid stack area on this processor, and false otherwise. |
---|
63 | * |
---|
64 | * @param[in] size is the stack size to check |
---|
65 | * |
---|
66 | * @return This method returns true if the stack is large enough. |
---|
67 | */ |
---|
68 | RTEMS_INLINE_ROUTINE bool _Stack_Is_enough ( |
---|
69 | size_t size |
---|
70 | ) |
---|
71 | { |
---|
72 | return ( size >= _Stack_Minimum() ); |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * This function returns the appropriate stack size given the requested |
---|
77 | * size. If the requested size is below the minimum, then the minimum |
---|
78 | * configured stack size is returned. |
---|
79 | * |
---|
80 | * @param[in] size is the stack size to check |
---|
81 | * |
---|
82 | * @return This method returns the appropriate stack size. |
---|
83 | */ |
---|
84 | RTEMS_INLINE_ROUTINE size_t _Stack_Ensure_minimum ( |
---|
85 | size_t size |
---|
86 | ) |
---|
87 | { |
---|
88 | if ( size >= _Stack_Minimum() ) |
---|
89 | return size; |
---|
90 | return _Stack_Minimum(); |
---|
91 | } |
---|
92 | |
---|
93 | /** @} */ |
---|
94 | |
---|
95 | #endif |
---|
96 | /* end of include file */ |
---|