1 | /** |
---|
2 | * @file rtems/score/wkspace.h |
---|
3 | * |
---|
4 | * @brief Information Related to the RAM Workspace |
---|
5 | * |
---|
6 | * This include file contains information related to the |
---|
7 | * RAM Workspace. This Handler provides mechanisms which can be used to |
---|
8 | * define, initialize and manipulate the workspace. |
---|
9 | */ |
---|
10 | |
---|
11 | /* |
---|
12 | * COPYRIGHT (c) 1989-2009. |
---|
13 | * On-Line Applications Research Corporation (OAR). |
---|
14 | * |
---|
15 | * The license and distribution terms for this file may be |
---|
16 | * found in the file LICENSE in this distribution or at |
---|
17 | * http://www.rtems.org/license/LICENSE. |
---|
18 | */ |
---|
19 | |
---|
20 | #ifndef _RTEMS_SCORE_WKSPACE_H |
---|
21 | #define _RTEMS_SCORE_WKSPACE_H |
---|
22 | |
---|
23 | #include <rtems/score/heap.h> |
---|
24 | #include <rtems/score/interr.h> |
---|
25 | |
---|
26 | #ifdef __cplusplus |
---|
27 | extern "C" { |
---|
28 | #endif |
---|
29 | |
---|
30 | /** |
---|
31 | * @defgroup ScoreWorkspace Workspace Handler |
---|
32 | * |
---|
33 | * @ingroup Score |
---|
34 | * |
---|
35 | * This handler encapsulates functionality related to the management of |
---|
36 | * the RTEMS Executive Workspace. |
---|
37 | */ |
---|
38 | /**@{*/ |
---|
39 | |
---|
40 | /** |
---|
41 | * @brief Executive workspace control. |
---|
42 | * |
---|
43 | * This is the heap control structure used to manage the RTEMS Executive |
---|
44 | * Workspace. |
---|
45 | */ |
---|
46 | SCORE_EXTERN Heap_Control _Workspace_Area; |
---|
47 | |
---|
48 | /** |
---|
49 | * @brief Initilize workspace handler. |
---|
50 | * |
---|
51 | * This routine performs the initialization necessary for this handler. |
---|
52 | */ |
---|
53 | void _Workspace_Handler_initialization( |
---|
54 | Heap_Area *areas, |
---|
55 | size_t area_count, |
---|
56 | Heap_Initialization_or_extend_handler extend |
---|
57 | ); |
---|
58 | |
---|
59 | /** |
---|
60 | * @brief Allocate memory from workspace. |
---|
61 | * |
---|
62 | * This routine returns the address of a block of memory of size |
---|
63 | * bytes. If a block of the appropriate size cannot be allocated |
---|
64 | * from the workspace, then NULL is returned. |
---|
65 | * |
---|
66 | * @param size is the requested size |
---|
67 | * |
---|
68 | * @retval a pointer to the requested memory or NULL. |
---|
69 | */ |
---|
70 | void *_Workspace_Allocate( |
---|
71 | size_t size |
---|
72 | ); |
---|
73 | |
---|
74 | /** |
---|
75 | * @brief Allocate aligned memory from workspace. |
---|
76 | * |
---|
77 | * @param[in] size The size of the requested memory. |
---|
78 | * @param[in] alignment The alignment of the requested memory. |
---|
79 | * |
---|
80 | * @retval NULL Not enough resources. |
---|
81 | * @retval other The memory area begin. |
---|
82 | */ |
---|
83 | void *_Workspace_Allocate_aligned( size_t size, size_t alignment ); |
---|
84 | |
---|
85 | /** |
---|
86 | * @brief Free memory to the workspace. |
---|
87 | * |
---|
88 | * This function frees the specified block of memory. If the block |
---|
89 | * belongs to the Workspace and can be successfully freed, then |
---|
90 | * true is returned. Otherwise false is returned. |
---|
91 | * |
---|
92 | * @param block is the memory to free |
---|
93 | * |
---|
94 | * @note If @a block is equal to NULL, then the request is ignored. |
---|
95 | * This allows the caller to not worry about whether or not |
---|
96 | * a pointer is NULL. |
---|
97 | */ |
---|
98 | |
---|
99 | void _Workspace_Free( |
---|
100 | void *block |
---|
101 | ); |
---|
102 | |
---|
103 | /** |
---|
104 | * @brief Workspace allocate or fail with fatal error. |
---|
105 | * |
---|
106 | * This routine returns the address of a block of memory of @a size |
---|
107 | * bytes. If a block of the appropriate size cannot be allocated |
---|
108 | * from the workspace, then the internal error handler is invoked. |
---|
109 | * |
---|
110 | * @param[in] size is the desired number of bytes to allocate |
---|
111 | * @retval If successful, the starting address of the allocated memory |
---|
112 | */ |
---|
113 | void *_Workspace_Allocate_or_fatal_error( |
---|
114 | size_t size |
---|
115 | ); |
---|
116 | |
---|
117 | /** |
---|
118 | * @brief Duplicates string with memory from the workspace. |
---|
119 | * |
---|
120 | * @param[in] string is the pointer to a zero terminated string. |
---|
121 | * @param[in] len is the length of the string (equal to strlen(string)). |
---|
122 | * |
---|
123 | * @retval NULL Not enough memory. |
---|
124 | * @retval other Duplicated string. |
---|
125 | */ |
---|
126 | char *_Workspace_String_duplicate( |
---|
127 | const char *string, |
---|
128 | size_t len |
---|
129 | ); |
---|
130 | |
---|
131 | /**@}*/ |
---|
132 | |
---|
133 | #ifdef __cplusplus |
---|
134 | } |
---|
135 | #endif |
---|
136 | |
---|
137 | #endif |
---|
138 | /* end of include file */ |
---|