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

4.104.114.95
Last change on this file since ebe61382 was ebe61382, checked in by Joel Sherrill <joel.sherrill@…>, on 11/30/07 at 21:49:41

2007-11-30 Joel Sherrill <joel.sherrill@…>

  • rtems/src/barrierdelete.c, rtems/src/barrierrelease.c, rtems/src/barriertranslatereturncode.c, rtems/src/barrierwait.c, rtems/src/clockget.c, rtems/src/dpmemdelete.c, rtems/src/dpmemexternal2internal.c, rtems/src/dpmeminternal2external.c, rtems/src/eventsend.c, rtems/src/eventtimeout.c, rtems/src/msgqbroadcast.c, rtems/src/msgqdelete.c, rtems/src/msgqflush.c, rtems/src/msgqgetnumberpending.c, rtems/src/msgqreceive.c, rtems/src/msgqsend.c, rtems/src/msgqurgent.c, rtems/src/partdelete.c, rtems/src/partgetbuffer.c, rtems/src/partreturnbuffer.c, rtems/src/ratemoncancel.c, rtems/src/ratemondelete.c, rtems/src/ratemongetstatistics.c, rtems/src/ratemongetstatus.c, rtems/src/ratemonperiod.c, rtems/src/ratemonresetstatistics.c, rtems/src/ratemontimeout.c, rtems/src/semdelete.c, rtems/src/semflush.c, rtems/src/semobtain.c, rtems/src/semrelease.c, rtems/src/semtranslatereturncode.c, rtems/src/signalsend.c, rtems/src/taskdelete.c, rtems/src/taskgetnote.c, rtems/src/taskissuspended.c, rtems/src/taskrestart.c, rtems/src/taskresume.c, rtems/src/tasksetnote.c, rtems/src/tasksetpriority.c, rtems/src/taskstart.c, rtems/src/tasksuspend.c, rtems/src/taskvariableadd.c, rtems/src/taskvariabledelete.c, rtems/src/taskvariableget.c, rtems/src/timercancel.c, rtems/src/timerdelete.c, rtems/src/timerfirewhen.c, rtems/src/timergetinfo.c, rtems/src/timerreset.c, rtems/src/timerserverfireafter.c, rtems/src/timerserverfirewhen.c: Restructured all code with the switch (location) pattern so that OBJECTS_LOCAL is first and we can fall into it and the OBJECTS_ERROR case breaks to a return RTEMS_INVALID_ID. This eliminates the return RTEMS_INTERNAL_ERROR at the bottom of each of these files which was unreachable and untestable code. This resulted in a code savings of approximately 20 bytes per file on the SPARC/ERC32.
  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 *  Dual Port Memory Manager
3 *
4 *  COPYRIGHT (c) 1989-2007.
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
62    case OBJECTS_LOCAL:
63      ending = _Addresses_Subtract( internal, the_port->internal_base );
64      if ( ending > the_port->length )
65        *external = internal;
66      else
67        *external = _Addresses_Add_offset( the_port->external_base,
68                                           ending );
69      _Thread_Enable_dispatch();
70      return RTEMS_SUCCESSFUL;
71
72#if defined(RTEMS_MULTIPROCESSING)
73    case OBJECTS_REMOTE:        /* this error cannot be returned */
74#endif
75    case OBJECTS_ERROR:
76      break;
77  }
78
79  return RTEMS_INVALID_ID;
80}
Note: See TracBrowser for help on using the repository browser.