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

5
Last change on this file since e8e914b3 was e8e914b3, checked in by Sebastian Huber <sebastian.huber@…>, on 11/08/18 at 09:37:22

rtems: Move internal structures to regiondata.h

Update #3598.

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