OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [rtems/] [src/] [dpmemexternal2internal.c] - Blame information for rev 274

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: dpmemexternal2internal.c,v 1.2 2001-09-27 11:59:19 chris Exp $
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
 
42
rtems_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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.