source: rtems/cpukit/rtems/src/dpmemexternal2internal.c @ 8ef3818

4.104.114.84.95
Last change on this file since 8ef3818 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • Property mode set to 100644
File size: 2.0 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.OARcorp.com/rtems/license.html.
10 *
11 *  $Id$
12 */
13
14#include <rtems/system.h>
15#include <rtems/rtems/status.h>
16#include <rtems/rtems/support.h>
17#include <rtems/score/address.h>
18#include <rtems/rtems/dpmem.h>
19#include <rtems/score/object.h>
20#include <rtems/score/thread.h>
21#include <rtems/rtems/dpmem.h>
22
23/*PAGE
24 *
25 *  rtems_port_external_to_internal
26 *
27 *  This directive converts an external dual-ported memory address to an
28 *  internal dual-ported memory address.  If the given external address
29 *  is an invalid dual-ported address, then the internal address is set
30 *  to the given external address.
31 *
32 *  Input parameters:
33 *    id       - id of dp memory object
34 *    external - external address
35 *    internal - pointer of internal address to set
36 *
37 *  Output parameters:
38 *    internal          - internal address
39 *    RTEMS_SUCCESSFUL - always succeeds
40 */
41
42rtems_status_code rtems_port_external_to_internal(
43  Objects_Id   id,
44  void        *external,
45  void       **internal
46)
47{
48  register Dual_ported_memory_Control *the_port;
49  Objects_Locations                    location;
50  unsigned32                           ending;
51
52  the_port = _Dual_ported_memory_Get( id, &location );
53  switch ( location ) {
54    case OBJECTS_REMOTE:        /* this error cannot be returned */
55      return RTEMS_INTERNAL_ERROR;
56
57    case OBJECTS_ERROR:
58      return RTEMS_INVALID_ID;
59
60    case OBJECTS_LOCAL:
61      ending = _Addresses_Subtract( external, the_port->external_base );
62      if ( ending > the_port->length )
63        *internal = external;
64      else
65        *internal = _Addresses_Add_offset( the_port->internal_base,
66                                           ending );
67      _Thread_Enable_dispatch();
68      return RTEMS_SUCCESSFUL;
69  }
70
71  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
72}
Note: See TracBrowser for help on using the repository browser.