1 | /** |
---|
2 | * @file rtems/rtems/region.inl |
---|
3 | * |
---|
4 | * This file contains the macro implementation of the inlined |
---|
5 | * routines from the Region Manager. |
---|
6 | */ |
---|
7 | |
---|
8 | /* COPYRIGHT (c) 1989-2008. |
---|
9 | * On-Line Applications Research Corporation (OAR). |
---|
10 | * |
---|
11 | * The license and distribution terms for this file may be |
---|
12 | * found in the file LICENSE in this distribution or at |
---|
13 | * http://www.rtems.com/license/LICENSE. |
---|
14 | * |
---|
15 | * $Id$ |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef _RTEMS_RTEMS_REGION_H |
---|
19 | # error "Never use <rtems/rtems/region.inl> directly; include <rtems/rtems/region.h> instead." |
---|
20 | #endif |
---|
21 | |
---|
22 | #ifndef _RTEMS_RTEMS_REGION_INL |
---|
23 | #define _RTEMS_RTEMS_REGION_INL |
---|
24 | |
---|
25 | /** |
---|
26 | * @addtogroup ClassicRegion |
---|
27 | * @{ |
---|
28 | */ |
---|
29 | |
---|
30 | /** |
---|
31 | * @brief Region_Allocate |
---|
32 | * |
---|
33 | * This function allocates a region control block from |
---|
34 | * the inactive chain of free region control blocks. |
---|
35 | */ |
---|
36 | RTEMS_INLINE_ROUTINE Region_Control *_Region_Allocate( void ) |
---|
37 | { |
---|
38 | return (Region_Control *) _Objects_Allocate( &_Region_Information ); |
---|
39 | } |
---|
40 | |
---|
41 | /** |
---|
42 | * @brief Region_Free |
---|
43 | * |
---|
44 | * This routine frees a region control block to the |
---|
45 | * inactive chain of free region control blocks. |
---|
46 | */ |
---|
47 | RTEMS_INLINE_ROUTINE void _Region_Free ( |
---|
48 | Region_Control *the_region |
---|
49 | ) |
---|
50 | { |
---|
51 | _Objects_Free( &_Region_Information, &the_region->Object ); |
---|
52 | } |
---|
53 | |
---|
54 | /** |
---|
55 | * @brief Region_Get |
---|
56 | * |
---|
57 | * This function maps region IDs to region control blocks. |
---|
58 | * If ID corresponds to a local region, then it returns |
---|
59 | * the_region control pointer which maps to ID and location |
---|
60 | * is set to OBJECTS_LOCAL. Otherwise, location is set |
---|
61 | * to OBJECTS_ERROR and the_region is undefined. |
---|
62 | */ |
---|
63 | RTEMS_INLINE_ROUTINE Region_Control *_Region_Get ( |
---|
64 | Objects_Id id, |
---|
65 | Objects_Locations *location |
---|
66 | ) |
---|
67 | { |
---|
68 | return (Region_Control *) |
---|
69 | _Objects_Get_no_protection( &_Region_Information, id, location ); |
---|
70 | } |
---|
71 | |
---|
72 | /** |
---|
73 | * @brief Region_Allocate_segment |
---|
74 | * |
---|
75 | * This function attempts to allocate a segment from the_region. |
---|
76 | * If successful, it returns the address of the allocated segment. |
---|
77 | * Otherwise, it returns NULL. |
---|
78 | */ |
---|
79 | RTEMS_INLINE_ROUTINE void *_Region_Allocate_segment ( |
---|
80 | Region_Control *the_region, |
---|
81 | uint32_t size |
---|
82 | ) |
---|
83 | { |
---|
84 | return _Heap_Allocate( &the_region->Memory, size ); |
---|
85 | } |
---|
86 | |
---|
87 | /** |
---|
88 | * @brief Region_Free_segment |
---|
89 | * |
---|
90 | * This function frees the_segment to the_region. |
---|
91 | */ |
---|
92 | RTEMS_INLINE_ROUTINE bool _Region_Free_segment ( |
---|
93 | Region_Control *the_region, |
---|
94 | void *the_segment |
---|
95 | ) |
---|
96 | { |
---|
97 | return _Heap_Free( &the_region->Memory, the_segment ); |
---|
98 | } |
---|
99 | |
---|
100 | /** |
---|
101 | * @brief Region_Is_null |
---|
102 | * |
---|
103 | * This function returns TRUE if the_region is NULL and FALSE otherwise. |
---|
104 | */ |
---|
105 | RTEMS_INLINE_ROUTINE bool _Region_Is_null ( |
---|
106 | Region_Control *the_region |
---|
107 | ) |
---|
108 | { |
---|
109 | return ( the_region == NULL ); |
---|
110 | } |
---|
111 | |
---|
112 | /**@}*/ |
---|
113 | |
---|
114 | #endif |
---|
115 | /* end of include file */ |
---|