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