source: rtems/c/src/exec/rtems/src/dpmeminternal2external.c @ 1dc030f

4.104.114.84.95
Last change on this file since 1dc030f was 1dc030f, checked in by Joel Sherrill <joel.sherrill@…>, on 05/17/99 at 23:18:20

Dual-Ported Memory Manager split into one routine per file.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 *  Dual Port Memory Manager
3 *
4 *  COPYRIGHT (c) 1989-1998.
5 *  On-Line Applications Research Corporation (OAR).
6 *  Copyright assigned to U.S. Government, 1994.
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <rtems/system.h>
16#include <rtems/rtems/status.h>
17#include <rtems/rtems/support.h>
18#include <rtems/score/address.h>
19#include <rtems/rtems/dpmem.h>
20#include <rtems/score/object.h>
21#include <rtems/score/thread.h>
22#include <rtems/rtems/dpmem.h>
23
24/*PAGE
25 *
26 *  rtems_port_internal_to_external
27 *
28 *  This directive converts an internal dual-ported memory address to an
29 *  external dual-ported memory address.  If the given internal address
30 *  is an invalid dual-ported address, then the external address is set
31 *  to the given internal address.
32 *
33 *  Input parameters:
34 *    id       - id of dual-ported memory object
35 *    internal - internal address to set
36 *    external - pointer to external address
37 *
38 *  Output parameters:
39 *    external          - external address
40 *    RTEMS_SUCCESSFUL - always succeeds
41 */
42
43rtems_status_code rtems_port_internal_to_external(
44  Objects_Id   id,
45  void        *internal,
46  void       **external
47)
48{
49  register Dual_ported_memory_Control *the_port;
50  Objects_Locations                    location;
51  unsigned32                           ending;
52
53  the_port = _Dual_ported_memory_Get( id, &location );
54  switch ( location ) {
55    case OBJECTS_REMOTE:        /* this error cannot be returned */
56      return RTEMS_INTERNAL_ERROR;
57
58    case OBJECTS_ERROR:
59      return RTEMS_INVALID_ID;
60
61    case OBJECTS_LOCAL:
62      ending = _Addresses_Subtract( internal, the_port->internal_base );
63      if ( ending > the_port->length )
64        *external = internal;
65      else
66        *external = _Addresses_Add_offset( the_port->external_base,
67                                           ending );
68      _Thread_Enable_dispatch();
69      return RTEMS_SUCCESSFUL;
70  }
71
72  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
73}
Note: See TracBrowser for help on using the repository browser.