/*
|
/*
|
* Dual Port Memory Manager
|
* Dual Port Memory Manager
|
*
|
*
|
* COPYRIGHT (c) 1989-1999.
|
* COPYRIGHT (c) 1989-1999.
|
* On-Line Applications Research Corporation (OAR).
|
* On-Line Applications Research Corporation (OAR).
|
*
|
*
|
* The license and distribution terms for this file may be
|
* The license and distribution terms for this file may be
|
* found in the file LICENSE in this distribution or at
|
* found in the file LICENSE in this distribution or at
|
* http://www.OARcorp.com/rtems/license.html.
|
* http://www.OARcorp.com/rtems/license.html.
|
*
|
*
|
* $Id: dpmemexternal2internal.c,v 1.2 2001-09-27 11:59:19 chris Exp $
|
* $Id: dpmemexternal2internal.c,v 1.2 2001-09-27 11:59:19 chris Exp $
|
*/
|
*/
|
|
|
#include <rtems/system.h>
|
#include <rtems/system.h>
|
#include <rtems/rtems/status.h>
|
#include <rtems/rtems/status.h>
|
#include <rtems/rtems/support.h>
|
#include <rtems/rtems/support.h>
|
#include <rtems/score/address.h>
|
#include <rtems/score/address.h>
|
#include <rtems/rtems/dpmem.h>
|
#include <rtems/rtems/dpmem.h>
|
#include <rtems/score/object.h>
|
#include <rtems/score/object.h>
|
#include <rtems/score/thread.h>
|
#include <rtems/score/thread.h>
|
#include <rtems/rtems/dpmem.h>
|
#include <rtems/rtems/dpmem.h>
|
|
|
/*PAGE
|
/*PAGE
|
*
|
*
|
* rtems_port_external_to_internal
|
* rtems_port_external_to_internal
|
*
|
*
|
* This directive converts an external dual-ported memory address to an
|
* This directive converts an external dual-ported memory address to an
|
* internal dual-ported memory address. If the given external address
|
* internal dual-ported memory address. If the given external address
|
* is an invalid dual-ported address, then the internal address is set
|
* is an invalid dual-ported address, then the internal address is set
|
* to the given external address.
|
* to the given external address.
|
*
|
*
|
* Input parameters:
|
* Input parameters:
|
* id - id of dp memory object
|
* id - id of dp memory object
|
* external - external address
|
* external - external address
|
* internal - pointer of internal address to set
|
* internal - pointer of internal address to set
|
*
|
*
|
* Output parameters:
|
* Output parameters:
|
* internal - internal address
|
* internal - internal address
|
* RTEMS_SUCCESSFUL - always succeeds
|
* RTEMS_SUCCESSFUL - always succeeds
|
*/
|
*/
|
|
|
rtems_status_code rtems_port_external_to_internal(
|
rtems_status_code rtems_port_external_to_internal(
|
Objects_Id id,
|
Objects_Id id,
|
void *external,
|
void *external,
|
void **internal
|
void **internal
|
)
|
)
|
{
|
{
|
register Dual_ported_memory_Control *the_port;
|
register Dual_ported_memory_Control *the_port;
|
Objects_Locations location;
|
Objects_Locations location;
|
unsigned32 ending;
|
unsigned32 ending;
|
|
|
the_port = _Dual_ported_memory_Get( id, &location );
|
the_port = _Dual_ported_memory_Get( id, &location );
|
switch ( location ) {
|
switch ( location ) {
|
case OBJECTS_REMOTE: /* this error cannot be returned */
|
case OBJECTS_REMOTE: /* this error cannot be returned */
|
return RTEMS_INTERNAL_ERROR;
|
return RTEMS_INTERNAL_ERROR;
|
|
|
case OBJECTS_ERROR:
|
case OBJECTS_ERROR:
|
return RTEMS_INVALID_ID;
|
return RTEMS_INVALID_ID;
|
|
|
case OBJECTS_LOCAL:
|
case OBJECTS_LOCAL:
|
ending = _Addresses_Subtract( external, the_port->external_base );
|
ending = _Addresses_Subtract( external, the_port->external_base );
|
if ( ending > the_port->length )
|
if ( ending > the_port->length )
|
*internal = external;
|
*internal = external;
|
else
|
else
|
*internal = _Addresses_Add_offset( the_port->internal_base,
|
*internal = _Addresses_Add_offset( the_port->internal_base,
|
ending );
|
ending );
|
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
return RTEMS_SUCCESSFUL;
|
return RTEMS_SUCCESSFUL;
|
}
|
}
|
|
|
return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
|
return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
|
}
|
}
|
|
|