summaryrefslogtreecommitdiffstats
path: root/c/src/exec/rtems/macros/part.inl
blob: f593acc5774e8ea76b0ae66487294a49b2fdd4a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*  part.inl
 *
 *  This file contains the macro implementation of all inlined routines
 *  in the Partition Manager.
 *
 *  COPYRIGHT (c) 1989-1997.
 *  On-Line Applications Research Corporation (OAR).
 *  Copyright assigned to U.S. Government, 1994.
 *
 *  The license and distribution terms for this file may in
 *  the file LICENSE in this distribution or at
 *  http://www.OARcorp.com/rtems/license.html.
 *
 *  $Id$
 */

#ifndef __PARTITION_inl
#define __PARTITION_inl

/*PAGE
 *
 *  _Partition_Allocate_buffer
 *
 */

#define _Partition_Allocate_buffer( _the_partition ) \
  _Chain_Get( &(_the_partition)->Memory )

/*PAGE
 *
 *  _Partition_Free_buffer
 *
 */

#define _Partition_Free_buffer( _the_partition, _the_buffer ) \
  _Chain_Append( &(_the_partition)->Memory, (_the_buffer) )

/*PAGE
 *
 *  _Partition_Is_buffer_on_boundary
 *
 */

#define _Partition_Is_buffer_on_boundary( _the_buffer, _the_partition ) \
  ((((unsigned32) _Addresses_Subtract( \
                    (_the_buffer), \
                    (_the_partition)->starting_address ) \
                  ) % \
                  (_the_partition)->buffer_size) == 0)

/*PAGE
 *
 *  _Partition_Is_buffer_valid
 *
 */

#define _Partition_Is_buffer_valid( _the_buffer, _the_partition ) \
  ( \
    _Addresses_Is_in_range( \
      (_the_buffer), \
      (_the_partition)->starting_address, \
      _Addresses_Add_offset( \
         (_the_partition)->starting_address, \
         (_the_partition)->length \
      ) \
    ) && \
    _Partition_Is_buffer_on_boundary( (_the_buffer), (_the_partition) ) \
  )

/*PAGE
 *
 *  _Partition_Is_buffer_size_aligned
 *
 */

#define _Partition_Is_buffer_size_aligned( _buffer_size ) \
  ((_buffer_size) % CPU_PARTITION_ALIGNMENT == 0)

/*PAGE
 *
 *  _Partition_Allocate
 *
 */

#define _Partition_Allocate() \
  (Partition_Control *) _Objects_Allocate( &_Partition_Information )

/*PAGE
 *
 *  _Partition_Free
 *
 */

#define _Partition_Free( _the_partition ) \
  _Objects_Free( &_Partition_Information, &(_the_partition)->Object )

/*PAGE
 *
 *  _Partition_Get
 *
 */

#define _Partition_Get( _id, _location ) \
  (Partition_Control *) \
    _Objects_Get( &_Partition_Information, (_id), (_location) )

/*PAGE
 *
 *  _Partition_Is_null
 *
 */

#define _Partition_Is_null( _the_partition ) \
   ( (_the_partition) == NULL  )

#endif
/* end of include file */