source: rtems/cpukit/rtems/src/dpmeminternal2external.c @ a29d2e7

4.104.114.84.95
Last change on this file since a29d2e7 was 1095ec1, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/18/05 at 09:03:45

Include config.h.

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