source: rtems-docs/c-user/dual_ports_memory_manager.rst @ 72a62ad

4.115
Last change on this file since 72a62ad was 72a62ad, checked in by Chris Johns <chrisj@…>, on 11/03/16 at 05:58:08

Rename all manuals with an _ to have a -. It helps released naming of files.

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