source: rtems/cpukit/include/rtems/rtems/regionimpl.h

Last change on this file was b07c721, checked in by Andreas Dachsberger <andreas.dachsberger@…>, on Mar 28, 2019 at 12:27:05 PM

doxygen: Restructured cpukit/include/rtems/rtems

Update #3706.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ClassicRegionImpl
5 *
6 * @brief Classic Region Manager Implementation
7 */
8
9/* COPYRIGHT (c) 1989-2008.
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.org/license/LICENSE.
15 */
16
17#ifndef _RTEMS_RTEMS_REGIONIMPL_H
18#define _RTEMS_RTEMS_REGIONIMPL_H
19
20#include <rtems/rtems/regiondata.h>
21#include <rtems/score/apimutex.h>
22#include <rtems/score/heapimpl.h>
23#include <rtems/score/objectimpl.h>
24#include <rtems/score/threadqimpl.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/**
31 * @defgroup ClassicRegionImpl Classic Region Manager Implementation
32 *
33 * @ingroup RTEMSInternalClassic
34 *
35 * @{
36 */
37
38#define REGION_OF_THREAD_QUEUE_QUEUE( queue ) \
39  RTEMS_CONTAINER_OF( queue, Region_Control, Wait_queue.Queue )
40
41/**
42 *  @brief Region_Allocate
43 *
44 *  This function allocates a region control block from
45 *  the inactive chain of free region control blocks.
46 */
47RTEMS_INLINE_ROUTINE Region_Control *_Region_Allocate( void )
48{
49  return (Region_Control *) _Objects_Allocate( &_Region_Information );
50}
51
52/**
53 *  @brief Region_Free
54 *
55 *  This routine frees a region control block to the
56 *  inactive chain of free region control blocks.
57 */
58RTEMS_INLINE_ROUTINE void _Region_Free (
59  Region_Control *the_region
60)
61{
62  _Thread_queue_Destroy( &the_region->Wait_queue );
63  _Objects_Free( &_Region_Information, &the_region->Object );
64}
65
66RTEMS_INLINE_ROUTINE Region_Control *_Region_Get_and_lock( Objects_Id id )
67{
68  Region_Control *the_region;
69
70  _RTEMS_Lock_allocator();
71
72  the_region = (Region_Control *)
73    _Objects_Get_no_protection( id, &_Region_Information );
74
75  if ( the_region != NULL ) {
76    /* Keep allocator lock */
77    return the_region;
78  }
79
80  _RTEMS_Unlock_allocator();
81  return NULL;
82}
83
84RTEMS_INLINE_ROUTINE void _Region_Unlock( Region_Control *the_region )
85{
86  (void) the_region;
87  _RTEMS_Unlock_allocator();
88}
89
90/**
91 *  @brief Region_Allocate_segment
92 *
93 *  This function attempts to allocate a segment from the_region.
94 *  If successful, it returns the address of the allocated segment.
95 *  Otherwise, it returns NULL.
96 */
97RTEMS_INLINE_ROUTINE void *_Region_Allocate_segment (
98  Region_Control *the_region,
99  uintptr_t       size
100)
101{
102  return _Heap_Allocate( &the_region->Memory, size );
103}
104
105/**
106 *  @brief Region_Free_segment
107 *
108 *  This function frees the_segment to the_region.
109 */
110RTEMS_INLINE_ROUTINE bool _Region_Free_segment (
111  Region_Control *the_region,
112  void           *the_segment
113)
114{
115  return _Heap_Free( &the_region->Memory, the_segment );
116}
117
118/**
119 *  @brief Process Region Queue
120 *
121 *  This is a helper routine which is invoked any time memory is
122 *  freed.  It looks at the set of waiting tasks and attempts to
123 *  satisfy all outstanding requests.
124 *
125 *  @param[in] the_region is the the region
126 */
127extern void _Region_Process_queue(Region_Control *the_region);
128
129/**@}*/
130
131#ifdef __cplusplus
132}
133#endif
134
135#endif
136/* end of include file */
Note: See TracBrowser for help on using the repository browser.