source: rtems-docs/c_user/dual_ports_memory_manager.rst @ 25d55d4

4.115
Last change on this file since 25d55d4 was 25d55d4, checked in by Chris Johns <chrisj@…>, on 02/18/16 at 04:41:28

Change code to code-block.

  • Property mode set to 100644
File size: 8.7 KB
Line 
1.. COMMENT: COPYRIGHT (c) 1988-2008.
2.. COMMENT: On-Line Applications Research Corporation (OAR).
3.. COMMENT: All rights reserved.
4
5Dual-Ported Memory Manager
6##########################
7
8.. index:: ports
9.. index:: dual ported memory
10
11Introduction
12============
13
14The dual-ported memory manager provides a mechanism for converting addresses
15between internal and external representations for multiple dual-ported memory
16areas (DPMA).  The directives provided by the dual-ported memory manager are:
17
18- rtems_port_create_ - Create a port
19
20- rtems_port_ident_ - Get ID of a port
21
22- rtems_port_delete_ - Delete a port
23
24- rtems_port_external_to_internal_ - Convert external to internal address
25
26- rtems_port_internal_to_external_ - Convert internal to external address
27
28Background
29==========
30.. index:: dual ported memory, definition
31.. index:: external addresses, definition
32.. index:: internal addresses, definition
33
34A dual-ported memory area (DPMA) is an contiguous block of RAM owned by a
35particular processor but which can be accessed by other processors in the
36system.  The owner accesses the memory using internal addresses, while other
37processors must use external addresses.  RTEMS defines a port as a particular
38mapping of internal and external addresses.
39
40There are two system configurations in which dual-ported memory is commonly
41found.  The first is tightly-coupled multiprocessor computer systems where the
42dual-ported memory is shared between all nodes and is used for inter-node
43communication.  The second configuration is computer systems with intelligent
44peripheral controllers.  These controllers typically utilize the DPMA for
45high-performance data transfers.
46
47Operations
48==========
49
50Creating a Port
51---------------
52
53The ``rtems_port_create`` directive creates a port into a DPMA with the
54user-defined name.  The user specifies the association between internal and
55external representations for the port being created.  RTEMS allocates a
56Dual-Ported Memory Control Block (DPCB) from the DPCB free list to maintain the
57newly created DPMA.  RTEMS also generates a unique dual-ported memory port ID
58which is returned to the calling task.  RTEMS does not initialize the
59dual-ported memory area or access any memory within it.
60
61Obtaining Port IDs
62------------------
63
64When a port is created, RTEMS generates a unique port ID and assigns it to the
65created port until it is deleted.  The port ID may be obtained by either of two
66methods.  First, as the result of an invocation of the``rtems_port_create``
67directive, the task ID is stored in a user provided location.  Second, the port
68ID may be obtained later using the ``rtems_port_ident`` directive.  The port ID
69is used by other dual-ported memory manager directives to access this port.
70
71Converting an Address
72---------------------
73
74The ``rtems_port_external_to_internal`` directive is used to convert an address
75from external to internal representation for the specified port.  The
76``rtems_port_internal_to_external`` directive is used to convert an address
77from internal to external representation for the specified port.  If an attempt
78is made to convert an address which lies outside the specified DPMA, then the
79address to be converted will be returned.
80
81Deleting a DPMA Port
82--------------------
83
84A port can be removed from the system and returned to RTEMS with the
85``rtems_port_delete`` directive.  When a port is deleted, its control block is
86returned to the DPCB free list.
87
88Directives
89==========
90
91This section details the dual-ported memory manager's directives.  A subsection
92is dedicated to each of this manager's directives and describes the calling
93sequence, related constants, usage, and status codes.
94
95.. _rtems_port_create:
96
97PORT_CREATE - Create a port
98---------------------------
99.. index:: create a port
100
101**CALLING SEQUENCE:**
102
103.. index:: rtems_port_create
104
105.. code-block:: c
106
107    rtems_status_code rtems_port_create(
108        rtems_name  name,
109        void       *internal_start,
110        void       *external_start,
111        uint32_t    length,
112        rtems_id   *id
113    );
114
115**DIRECTIVE STATUS CODES:**
116
117.. list-table::
118 :class: rtems-table
119
120 * - ``RTEMS_SUCCESSFUL``
121   - port created successfully
122 * - ``RTEMS_INVALID_NAME``
123   - invalid port name
124 * - ``RTEMS_INVALID_ADDRESS``
125   - address not on four byte boundary
126 * - ``RTEMS_INVALID_ADDRESS``
127   - ``id`` is NULL
128 * - ``RTEMS_TOO_MANY``
129   - too many DP memory areas created
130
131**DESCRIPTION:**
132
133This directive creates a port which resides on the local node for the specified
134DPMA.  The assigned port id is returned in id.  This port id is used as an
135argument to other dual-ported memory manager directives to convert addresses
136within this DPMA.
137
138For control and maintenance of the port, RTEMS allocates and initializes an
139DPCB from the DPCB free pool.  Thus memory from the dual-ported memory area is
140not used to store the DPCB.
141
142**NOTES:**
143
144The internal_address and external_address parameters must be on a four byte
145boundary.
146
147This directive will not cause the calling task to be preempted.
148
149.. _rtems_port_ident:
150
151PORT_IDENT - Get ID of a port
152-----------------------------
153.. index:: get ID of a port
154.. index:: obtain ID of a port
155
156**CALLING SEQUENCE:**
157
158.. index:: rtems_port_ident
159
160.. code-block:: c
161
162    rtems_status_code rtems_port_ident(
163        rtems_name  name,
164        rtems_id   \*id
165    );
166
167**DIRECTIVE STATUS CODES:**
168
169.. list-table::
170 :class: rtems-table
171
172 * - ``RTEMS_SUCCESSFUL``
173   - port identified successfully
174 * - ``RTEMS_INVALID_ADDRESS``
175   - ``id`` is NULL
176 * - ``RTEMS_INVALID_NAME``
177   - port name not found
178
179**DESCRIPTION:**
180
181This directive obtains the port id associated with the specified name to be
182acquired.  If the port name is not unique, then the port id will match one of
183the DPMAs with that name.  However, this port id is not guaranteed to
184correspond to the desired DPMA.  The port id is used to access this DPMA in
185other dual-ported memory area related directives.
186
187**NOTES:**
188
189This directive will not cause the running task to be preempted.
190
191.. _rtems_port_delete:
192
193PORT_DELETE - Delete a port
194---------------------------
195.. index:: delete a port
196
197**CALLING SEQUENCE:**
198
199.. index:: rtems_port_delete
200
201.. code-block:: c
202
203    rtems_status_code rtems_port_delete(
204        rtems_id id
205    );
206
207**DIRECTIVE STATUS CODES:**
208
209.. list-table::
210 :class: rtems-table
211
212 * - ``RTEMS_SUCCESSFUL``
213   - port deleted successfully
214 * - ``RTEMS_INVALID_ID``
215   - invalid port id
216
217**DESCRIPTION:**
218
219This directive deletes the dual-ported memory area specified by id.  The DPCB
220for the deleted dual-ported memory area is reclaimed by RTEMS.
221
222**NOTES:**
223
224This directive will not cause the calling task to be preempted.
225
226The calling task does not have to be the task that created the port.  Any local
227task that knows the port id can delete the port.
228
229.. _rtems_port_external_to_internal:
230
231PORT_EXTERNAL_TO_INTERNAL - Convert external to internal address
232----------------------------------------------------------------
233.. index:: convert external to internal address
234
235**CALLING SEQUENCE:**
236
237.. index:: rtems_port_external_to_internal
238
239.. code-block:: c
240
241    rtems_status_code rtems_port_external_to_internal(
242        rtems_id   id,
243        void      *external,
244        void     **internal
245    );
246
247**DIRECTIVE STATUS CODES:**
248
249.. list-table::
250 :class: rtems-table
251
252 * - ``RTEMS_INVALID_ADDRESS``
253   - ``internal`` is NULL
254 * - ``RTEMS_SUCCESSFUL``
255   - successful conversion
256
257**DESCRIPTION:**
258
259This directive converts a dual-ported memory address from external to internal
260representation for the specified port.  If the given external address is
261invalid for the specified port, then the internal address is set to the given
262external address.
263
264**NOTES:**
265
266This directive is callable from an ISR.
267
268This directive will not cause the calling task to be preempted.
269
270.. _rtems_port_internal_to_external:
271
272PORT_INTERNAL_TO_EXTERNAL - Convert internal to external address
273----------------------------------------------------------------
274.. index:: convert internal to external address
275
276**CALLING SEQUENCE:**
277
278.. index:: rtems_port_internal_to_external
279
280.. code-block:: c
281
282    rtems_status_code rtems_port_internal_to_external(
283        rtems_id   id,
284        void      *internal,
285        void     **external
286    );
287
288**DIRECTIVE STATUS CODES:**
289
290.. list-table::
291 :class: rtems-table
292
293 * - ``RTEMS_INVALID_ADDRESS``
294   - ``external`` is NULL
295 * - ``RTEMS_SUCCESSFUL``
296   - successful conversion
297
298**DESCRIPTION:**
299
300This directive converts a dual-ported memory address from internal to external
301representation so that it can be passed to owner of the DPMA represented by the
302specified port.  If the given internal address is an invalid dual-ported
303address, then the external address is set to the given internal address.
304
305**NOTES:**
306
307This directive is callable from an ISR.
308
309This directive will not cause the calling task to be preempted.
Note: See TracBrowser for help on using the repository browser.