source: rtems/cpukit/rtems/include/rtems/rtems/support.h @ 88c74ab

4.115
Last change on this file since 88c74ab was 88c74ab, checked in by Sebastian Huber <sebastian.huber@…>, on 07/25/13 at 13:10:11

score: Merge tod implementation into one file

Delete TOD_MICROSECONDS_PER_SECOND, TOD_MICROSECONDS_TO_TICKS() and
TOD_MILLISECONDS_TO_TICKS().

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/**
2 * @file
3 *
4 * @defgroup ClassicRTEMSWorkspace Workspace
5 *
6 * @ingroup ClassicRTEMS
7 * @brief Classic API support.
8 */
9
10/* COPYRIGHT (c) 1989-2008.
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_RTEMS_SUPPORT_H
19#define _RTEMS_RTEMS_SUPPORT_H
20
21#include <rtems/rtems/types.h>
22#include <rtems/config.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/**
29 * @addtogroup ClassicRTEMS
30 */
31/**@{**/
32
33/**
34 * @brief Returns the number of micro seconds for the milli seconds value @a _ms.
35 */
36#define RTEMS_MILLISECONDS_TO_MICROSECONDS(_ms) ((uint32_t)(_ms) * 1000UL)
37
38/**
39 * @brief Returns the number of ticks for the milli seconds value @a _ms.
40 */
41#define RTEMS_MILLISECONDS_TO_TICKS(_ms) \
42       (RTEMS_MILLISECONDS_TO_MICROSECONDS(_ms) / \
43          rtems_configuration_get_microseconds_per_tick())
44
45/**
46 * @brief Returns the number of ticks for the micro seconds value @a _us.
47 */
48#define RTEMS_MICROSECONDS_TO_TICKS(_us) \
49       ((_us) / rtems_configuration_get_microseconds_per_tick())
50
51/**
52 * @brief Returns @c true if the name is valid, and @c false otherwise.
53 */
54RTEMS_INLINE_ROUTINE bool rtems_is_name_valid (
55  rtems_name name
56)
57{
58  return ( name != 0 );
59}
60
61/**
62 * @brief Breaks the object name into the four component characters @a c1,
63 * @a c2, @a c3, and @a c4.
64 */
65RTEMS_INLINE_ROUTINE void rtems_name_to_characters(
66  rtems_name    name,
67  char         *c1,
68  char         *c2,
69  char         *c3,
70  char         *c4
71)
72{
73  *c1 = (char) ((name >> 24) & 0xff);
74  *c2 = (char) ((name >> 16) & 0xff);
75  *c3 = (char) ((name >> 8) & 0xff);
76  *c4 = (char) ( name & 0xff);
77}
78
79/** @} */
80
81/**
82 * @defgroup ClassicRTEMSWorkspace Workspace
83 *
84 * @ingroup ClassicRTEMS
85 *
86 * Workspace definitions.
87 */
88/**@{**/
89
90/**
91 * @brief Gets Workspace Information
92 *
93 * Returns information about the heap that is used as the RTEMS Executive
94 * Workspace in @a the_info.
95 *
96 * Returns @c true if successful, and @a false otherwise.
97 */
98bool rtems_workspace_get_information(
99  Heap_Information_block  *the_info
100);
101
102/**
103 * @brief Allocates Memory from the Workspace
104 *
105 * A number of @a bytes bytes will be allocated from the RTEMS Executive
106 * Workspace and returned in @a pointer.
107 *
108 * Returns @c true if successful, and @a false otherwise.
109 */
110bool rtems_workspace_allocate(
111  size_t   bytes,
112  void   **pointer
113);
114
115/**
116 * @brief Frees Memory Allocated from the Workspace
117 *
118 * This frees the memory indicated by @a pointer that was allocated from the
119 * RTEMS Executive Workspace.
120 *
121 * Returns @c true if successful, and @a false otherwise.
122 */
123bool rtems_workspace_free(
124  void *pointer
125);
126
127/**
128 * @brief Greedy allocate that empties the workspace.
129 *
130 * Afterwards the heap has at most @a block_count allocatable blocks of sizes
131 * specified by @a block_sizes.  The @a block_sizes must point to an array with
132 * @a block_count members.  All other blocks are used.
133 *
134 * @see rtems_workspace_greedy_free().
135 */
136void *rtems_workspace_greedy_allocate(
137  const uintptr_t *block_sizes,
138  size_t block_count
139);
140
141/**
142 * @brief Greedy allocate all blocks except the largest free block.
143 *
144 * Afterwards the heap has at most one allocatable block.  This block is the
145 * largest free block if it exists.  The allocatable size of this block is
146 * stored in @a allocatable_size.  All other blocks are used.
147 *
148 * @see rtems_workspace_greedy_free().
149 */
150void *rtems_workspace_greedy_allocate_all_except_largest(
151  uintptr_t *allocatable_size
152);
153
154/**
155 * @brief Frees space of a greedy allocation.
156 *
157 * The @a opaque argument must be the return value of
158 * rtems_workspace_greedy_allocate() or
159 * rtems_workspace_greedy_allocate_all_except_largest().
160 */
161void rtems_workspace_greedy_free( void *opaque );
162
163/** @} */
164
165#ifdef __cplusplus
166}
167#endif
168
169#endif
170/* end of include file */
Note: See TracBrowser for help on using the repository browser.