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