source: rtems-docs/c-user/dual_ports_memory_manager.rst @ 4da4a15

4.115
Last change on this file since 4da4a15 was 4da4a15, checked in by Chris Johns <chrisj@…>, on 11/09/16 at 00:42:10

c-user: Fix header levels. Minor fixes.

  • Property mode set to 100644
File size: 9.2 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.. raw:: latex
98
99   \clearpage
100
101.. _rtems_port_create:
102
103PORT_CREATE - Create a port
104---------------------------
105.. index:: create a port
106.. index:: rtems_port_create
107
108CALLING SEQUENCE:
109    .. code-block:: c
110
111        rtems_status_code rtems_port_create(
112            rtems_name  name,
113            void       *internal_start,
114            void       *external_start,
115            uint32_t    length,
116            rtems_id   *id
117        );
118
119DIRECTIVE STATUS CODES:
120    .. list-table::
121     :class: rtems-table
122
123     * - ``RTEMS_SUCCESSFUL``
124       - port created successfully
125     * - ``RTEMS_INVALID_NAME``
126       - invalid port name
127     * - ``RTEMS_INVALID_ADDRESS``
128       - address not on four byte boundary
129     * - ``RTEMS_INVALID_ADDRESS``
130       - ``id`` is NULL
131     * - ``RTEMS_TOO_MANY``
132       - too many DP memory areas created
133
134DESCRIPTION:
135    This directive creates a port which resides on the local node for the
136    specified DPMA.  The assigned port id is returned in id.  This port id is
137    used as an argument to other dual-ported memory manager directives to
138    convert addresses within this DPMA.
139
140    For control and maintenance of the port, RTEMS allocates and initializes an
141    DPCB from the DPCB free pool.  Thus memory from the dual-ported memory area
142    is not used to store the DPCB.
143
144NOTES:
145    The internal_address and external_address parameters must be on a four byte
146    boundary.
147
148    This directive will not cause the calling task to be preempted.
149
150.. raw:: latex
151
152   \clearpage
153
154.. _rtems_port_ident:
155
156PORT_IDENT - Get ID of a port
157-----------------------------
158.. index:: get ID of a port
159.. index:: obtain ID of a port
160.. index:: rtems_port_ident
161
162CALLING SEQUENCE:
163    .. code-block:: c
164
165        rtems_status_code rtems_port_ident(
166            rtems_name  name,
167            rtems_id   *id
168        );
169
170DIRECTIVE STATUS CODES:
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
181DESCRIPTION:
182    This directive obtains the port id associated with the specified name to be
183    acquired.  If the port name is not unique, then the port id will match one
184    of the DPMAs with that name.  However, this port id is not guaranteed to
185    correspond to the desired DPMA.  The port id is used to access this DPMA in
186    other dual-ported memory area related directives.
187
188NOTES:
189    This directive will not cause the running task to be preempted.
190
191.. raw:: latex
192
193   \clearpage
194
195.. _rtems_port_delete:
196
197PORT_DELETE - Delete a port
198---------------------------
199.. index:: delete a port
200.. index:: rtems_port_delete
201
202CALLING SEQUENCE:
203    .. code-block:: c
204
205        rtems_status_code rtems_port_delete(
206            rtems_id id
207        );
208
209DIRECTIVE STATUS CODES:
210    .. list-table::
211     :class: rtems-table
212
213     * - ``RTEMS_SUCCESSFUL``
214       - port deleted successfully
215     * - ``RTEMS_INVALID_ID``
216       - invalid port id
217
218DESCRIPTION:
219    This directive deletes the dual-ported memory area specified by id.  The
220    DPCB for the deleted dual-ported memory area is reclaimed by RTEMS.
221
222NOTES:
223    This directive will not cause the calling task to be preempted.
224
225    The calling task does not have to be the task that created the port.  Any
226    local task that knows the port id can delete the port.
227
228.. raw:: latex
229
230   \clearpage
231
232.. _rtems_port_external_to_internal:
233
234PORT_EXTERNAL_TO_INTERNAL - Convert external to internal address
235----------------------------------------------------------------
236.. index:: convert external to internal address
237.. index:: rtems_port_external_to_internal
238
239CALLING SEQUENCE:
240    .. code-block:: c
241
242        rtems_status_code rtems_port_external_to_internal(
243            rtems_id   id,
244            void      *external,
245            void     **internal
246        );
247
248DIRECTIVE STATUS CODES:
249    .. list-table::
250     :class: rtems-table
251
252     * - ``RTEMS_INVALID_ADDRESS``
253       - ``internal`` is NULL
254     * - ``RTEMS_SUCCESSFUL``
255       - successful conversion
256
257DESCRIPTION:
258    This directive converts a dual-ported memory address from external to
259    internal representation for the specified port.  If the given external
260    address is invalid for the specified port, then the internal address is set
261    to the given external address.
262
263NOTES:
264    This directive is callable from an ISR.
265
266    This directive will not cause the calling task to be preempted.
267
268.. raw:: latex
269
270   \clearpage
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.. index:: rtems_port_internal_to_external
278
279CALLING SEQUENCE:
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
288DIRECTIVE STATUS CODES:
289    .. list-table::
290     :class: rtems-table
291
292     * - ``RTEMS_INVALID_ADDRESS``
293       - ``external`` is NULL
294     * - ``RTEMS_SUCCESSFUL``
295       - successful conversion
296
297DESCRIPTION:
298    This directive converts a dual-ported memory address from internal to
299    external representation so that it can be passed to owner of the DPMA
300    represented by the specified port.  If the given internal address is an
301    invalid dual-ported address, then the external address is set to the given
302    internal address.
303
304NOTES:
305    This directive is callable from an ISR.
306
307    This directive will not cause the calling task to be preempted.
Note: See TracBrowser for help on using the repository browser.