1 | /** |
---|
2 | * @file rtems/rtems/part.h |
---|
3 | * |
---|
4 | * This include file contains all the constants and structures associated |
---|
5 | * with the Partition Manager. This manager provides facilities to |
---|
6 | * dynamically allocate memory in fixed-sized units which are returned |
---|
7 | * as buffers. |
---|
8 | * |
---|
9 | * Directives provided are: |
---|
10 | * |
---|
11 | * - create a partition |
---|
12 | * - get an ID of a partition |
---|
13 | * - delete a partition |
---|
14 | * - get a buffer from a partition |
---|
15 | * - return a buffer to a partition |
---|
16 | */ |
---|
17 | |
---|
18 | /* COPYRIGHT (c) 1989-2008. |
---|
19 | * On-Line Applications Research Corporation (OAR). |
---|
20 | * |
---|
21 | * The license and distribution terms for this file may be |
---|
22 | * found in the file LICENSE in this distribution or at |
---|
23 | * http://www.rtems.com/license/LICENSE. |
---|
24 | * |
---|
25 | * $Id$ |
---|
26 | */ |
---|
27 | |
---|
28 | #ifndef _RTEMS_RTEMS_PART_H |
---|
29 | #define _RTEMS_RTEMS_PART_H |
---|
30 | |
---|
31 | /** |
---|
32 | * This constant is defined to extern most of the time when using |
---|
33 | * this header file. However by defining it to nothing, the data |
---|
34 | * declared in this header file can be instantiated. This is done |
---|
35 | * in a single per manager file. |
---|
36 | */ |
---|
37 | #ifndef RTEMS_PART_EXTERN |
---|
38 | #define RTEMS_PART_EXTERN extern |
---|
39 | #endif |
---|
40 | |
---|
41 | #ifdef __cplusplus |
---|
42 | extern "C" { |
---|
43 | #endif |
---|
44 | |
---|
45 | #include <rtems/score/address.h> |
---|
46 | #include <rtems/score/object.h> |
---|
47 | #include <rtems/rtems/attr.h> |
---|
48 | #include <rtems/rtems/status.h> |
---|
49 | #include <rtems/rtems/support.h> |
---|
50 | #include <rtems/rtems/types.h> |
---|
51 | |
---|
52 | /** |
---|
53 | * @defgroup ClassicPart Partitions |
---|
54 | * |
---|
55 | * @ingroup ClassicRTEMS |
---|
56 | * |
---|
57 | * This encapsulates functionality related to the |
---|
58 | * Classic API Partition Manager. |
---|
59 | */ |
---|
60 | /**@{*/ |
---|
61 | |
---|
62 | /** |
---|
63 | * The following defines the control block used to manage each partition. |
---|
64 | */ |
---|
65 | typedef struct { |
---|
66 | /** This field is the object management portion of a Partition instance. */ |
---|
67 | Objects_Control Object; |
---|
68 | /** This field is the physical starting address of the Partition. */ |
---|
69 | void *starting_address; |
---|
70 | /** This field is the size of the Partition in bytes. */ |
---|
71 | intptr_t length; |
---|
72 | /** This field is the size of each buffer in bytes */ |
---|
73 | uint32_t buffer_size; |
---|
74 | /** This field is the attribute set provided at create time. */ |
---|
75 | rtems_attribute attribute_set; |
---|
76 | /** This field is the of allocated buffers. */ |
---|
77 | uint32_t number_of_used_blocks; |
---|
78 | /** This field is the chain used to manage unallocated buffers. */ |
---|
79 | Chain_Control Memory; |
---|
80 | } Partition_Control; |
---|
81 | |
---|
82 | /** |
---|
83 | * The following defines the information control block used to |
---|
84 | * manage this class of objects. |
---|
85 | */ |
---|
86 | RTEMS_PART_EXTERN Objects_Information _Partition_Information; |
---|
87 | |
---|
88 | /** |
---|
89 | * @brief Partition_Manager_initialization |
---|
90 | * |
---|
91 | * This routine performs the initialization necessary for this manager. |
---|
92 | */ |
---|
93 | void _Partition_Manager_initialization(void); |
---|
94 | |
---|
95 | /** |
---|
96 | * @brief rtems_partition_create |
---|
97 | * |
---|
98 | * This routine implements the rtems_partition_create directive. The |
---|
99 | * partition will have the name name. The memory area managed by |
---|
100 | * the partition is of length bytes and starts at starting_address. |
---|
101 | * The memory area will be divided into as many buffers of |
---|
102 | * buffer_size bytes as possible. The attribute_set determines if |
---|
103 | * the partition is global or local. It returns the id of the |
---|
104 | * created partition in ID. |
---|
105 | */ |
---|
106 | rtems_status_code rtems_partition_create( |
---|
107 | rtems_name name, |
---|
108 | void *starting_address, |
---|
109 | uint32_t length, |
---|
110 | uint32_t buffer_size, |
---|
111 | rtems_attribute attribute_set, |
---|
112 | Objects_Id *id |
---|
113 | ); |
---|
114 | |
---|
115 | /** |
---|
116 | * @brief rtems_partition_ident |
---|
117 | * |
---|
118 | * This routine implements the rtems_partition_ident directive. |
---|
119 | * This directive returns the partition ID associated with name. |
---|
120 | * If more than one partition is named name, then the partition |
---|
121 | * to which the ID belongs is arbitrary. node indicates the |
---|
122 | * extent of the search for the ID of the partition named name. |
---|
123 | * The search can be limited to a particular node or allowed to |
---|
124 | * encompass all nodes. |
---|
125 | */ |
---|
126 | rtems_status_code rtems_partition_ident( |
---|
127 | rtems_name name, |
---|
128 | uint32_t node, |
---|
129 | Objects_Id *id |
---|
130 | ); |
---|
131 | |
---|
132 | /** |
---|
133 | * @brief rtems_partition_delete |
---|
134 | * |
---|
135 | * This routine implements the rtems_partition_delete directive. The |
---|
136 | * partition indicated by ID is deleted. |
---|
137 | */ |
---|
138 | rtems_status_code rtems_partition_delete( |
---|
139 | Objects_Id id |
---|
140 | ); |
---|
141 | |
---|
142 | /** |
---|
143 | * @brief rtems_partition_get_buffer |
---|
144 | * |
---|
145 | * This routine implements the rtems_partition_get_buffer directive. It |
---|
146 | * attempts to allocate a buffer from the partition associated with ID. |
---|
147 | * If a buffer is allocated, its address is returned in buffer. |
---|
148 | */ |
---|
149 | rtems_status_code rtems_partition_get_buffer( |
---|
150 | Objects_Id id, |
---|
151 | void **buffer |
---|
152 | ); |
---|
153 | |
---|
154 | /** |
---|
155 | * @brief rtems_partition_return_buffer |
---|
156 | * |
---|
157 | * This routine implements the rtems_partition_return_buffer directive. It |
---|
158 | * frees the buffer to the partition associated with ID. The buffer must |
---|
159 | * have been previously allocated from the same partition. |
---|
160 | */ |
---|
161 | rtems_status_code rtems_partition_return_buffer( |
---|
162 | Objects_Id id, |
---|
163 | void *buffer |
---|
164 | ); |
---|
165 | |
---|
166 | #ifndef __RTEMS_APPLICATION__ |
---|
167 | #include <rtems/rtems/part.inl> |
---|
168 | #endif |
---|
169 | #if defined(RTEMS_MULTIPROCESSING) |
---|
170 | #include <rtems/rtems/partmp.h> |
---|
171 | #endif |
---|
172 | |
---|
173 | #ifdef __cplusplus |
---|
174 | } |
---|
175 | #endif |
---|
176 | |
---|
177 | /**@}*/ |
---|
178 | |
---|
179 | #endif |
---|
180 | /* end of include file */ |
---|