source:
rtems/cpukit/rtems/src/dpmeminternal2external.c
@
17bbadd
Last change on this file since 17bbadd was 17bbadd, checked in by Joel Sherrill <joel.sherrill@…>, on 05/06/04 at 19:20:04 | |
---|---|
|
|
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 | #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_internal_to_external |
26 | * |
27 | * This directive converts an internal dual-ported memory address to an |
28 | * external dual-ported memory address. If the given internal address |
29 | * is an invalid dual-ported address, then the external address is set |
30 | * to the given internal address. |
31 | * |
32 | * Input parameters: |
33 | * id - id of dual-ported memory object |
34 | * internal - internal address to set |
35 | * external - pointer to external address |
36 | * |
37 | * Output parameters: |
38 | * external - external address |
39 | * RTEMS_SUCCESSFUL - always succeeds |
40 | */ |
41 | |
42 | rtems_status_code rtems_port_internal_to_external( |
43 | Objects_Id id, |
44 | void *internal, |
45 | void **external |
46 | ) |
47 | { |
48 | register Dual_ported_memory_Control *the_port; |
49 | Objects_Locations location; |
50 | unsigned32 ending; |
51 | |
52 | if ( !external ) |
53 | return RTEMS_INVALID_ADDRESS; |
54 | |
55 | the_port = _Dual_ported_memory_Get( id, &location ); |
56 | switch ( location ) { |
57 | case OBJECTS_REMOTE: /* this error cannot be returned */ |
58 | return RTEMS_INTERNAL_ERROR; |
59 | |
60 | case OBJECTS_ERROR: |
61 | return RTEMS_INVALID_ID; |
62 | |
63 | case OBJECTS_LOCAL: |
64 | ending = _Addresses_Subtract( internal, the_port->internal_base ); |
65 | if ( ending > the_port->length ) |
66 | *external = internal; |
67 | else |
68 | *external = _Addresses_Add_offset( the_port->external_base, |
69 | ending ); |
70 | _Thread_Enable_dispatch(); |
71 | return RTEMS_SUCCESSFUL; |
72 | } |
73 | |
74 | return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ |
75 | } |
Note: See TracBrowser
for help on using the repository browser.